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