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