2023-05-05 03:37:42 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
2023-05-23 23:08:26 +09:00
|
|
|
require 'mastodon/cli/settings'
|
2023-05-05 03:37:42 +09:00
|
|
|
|
2023-05-24 18:55:40 +09:00
|
|
|
describe Mastodon::CLI::Settings do
|
2023-12-01 21:00:34 +09:00
|
|
|
it_behaves_like 'CLI Command'
|
2023-05-24 18:55:40 +09:00
|
|
|
|
2023-05-05 03:37:42 +09:00
|
|
|
describe 'subcommand "registrations"' do
|
2023-12-07 22:49:14 +09:00
|
|
|
subject { cli.invoke(action, arguments, options) }
|
|
|
|
|
2023-05-23 23:08:26 +09:00
|
|
|
let(:cli) { Mastodon::CLI::Registrations.new }
|
2023-12-07 22:49:14 +09:00
|
|
|
let(:arguments) { [] }
|
|
|
|
let(:options) { {} }
|
2023-05-05 03:37:42 +09:00
|
|
|
|
|
|
|
before do
|
|
|
|
Setting.registrations_mode = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#open' do
|
2023-12-07 22:49:14 +09:00
|
|
|
let(:action) { :open }
|
|
|
|
|
2023-12-11 19:23:45 +09:00
|
|
|
it 'changes "registrations_mode" to "open" and displays success' do
|
2023-12-07 22:49:14 +09:00
|
|
|
expect { subject }
|
2023-12-11 19:23:45 +09:00
|
|
|
.to change(Setting, :registrations_mode).from(nil).to('open')
|
|
|
|
.and output_results('OK')
|
2023-05-05 03:37:42 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#approved' do
|
2023-12-07 22:49:14 +09:00
|
|
|
let(:action) { :approved }
|
|
|
|
|
2023-12-11 19:23:45 +09:00
|
|
|
it 'changes "registrations_mode" to "approved" and displays success' do
|
2023-12-07 22:49:14 +09:00
|
|
|
expect { subject }
|
2023-12-11 19:23:45 +09:00
|
|
|
.to change(Setting, :registrations_mode).from(nil).to('approved')
|
|
|
|
.and output_results('OK')
|
2023-05-05 03:37:42 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with --require-reason' do
|
2023-12-07 22:49:14 +09:00
|
|
|
let(:options) { { require_reason: true } }
|
2023-05-05 03:37:42 +09:00
|
|
|
|
2023-12-11 19:23:45 +09:00
|
|
|
it 'changes registrations_mode and require_invite_text' do
|
|
|
|
expect { subject }
|
|
|
|
.to change(Setting, :registrations_mode).from(nil).to('approved')
|
|
|
|
.and change(Setting, :require_invite_text).from(false).to(true)
|
2023-05-05 03:37:42 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#close' do
|
2023-12-07 22:49:14 +09:00
|
|
|
let(:action) { :close }
|
|
|
|
|
2023-12-11 19:23:45 +09:00
|
|
|
it 'changes "registrations_mode" to "none" and displays success' do
|
2023-12-07 22:49:14 +09:00
|
|
|
expect { subject }
|
2023-12-11 19:23:45 +09:00
|
|
|
.to change(Setting, :registrations_mode).from(nil).to('none')
|
|
|
|
.and output_results('OK')
|
2023-05-05 03:37:42 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|