1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-05 10:18:45 +09:00
YuruToot/spec/lib/mastodon/cli/settings_spec.rb

62 lines
1.7 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
require 'mastodon/cli/settings'
describe Mastodon::CLI::Settings do
it_behaves_like 'CLI Command'
describe 'subcommand "registrations"' do
subject { cli.invoke(action, arguments, options) }
let(:cli) { Mastodon::CLI::Registrations.new }
let(:arguments) { [] }
let(:options) { {} }
before do
Setting.registrations_mode = nil
end
describe '#open' do
let(:action) { :open }
it 'changes "registrations_mode" to "open" and displays success' do
expect { subject }
.to change(Setting, :registrations_mode).from(nil).to('open')
.and output_results('OK')
end
end
describe '#approved' do
let(:action) { :approved }
it 'changes "registrations_mode" to "approved" and displays success' do
expect { subject }
.to change(Setting, :registrations_mode).from(nil).to('approved')
.and output_results('OK')
end
context 'with --require-reason' do
let(:options) { { require_reason: true } }
it 'changes registrations_mode and require_invite_text' do
expect { subject }
.to output_results('OK')
.and change(Setting, :registrations_mode).from(nil).to('approved')
.and change(Setting, :require_invite_text).from(false).to(true)
end
end
end
describe '#close' do
let(:action) { :close }
it 'changes "registrations_mode" to "none" and displays success' do
expect { subject }
.to change(Setting, :registrations_mode).from(nil).to('none')
.and output_results('OK')
end
end
end
end