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