mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 01:41:08 +00:00
Select preset warning in spec
This commit is contained in:
parent
25f1a515f8
commit
18a045e221
|
@ -3,7 +3,11 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AccountWarningPreset do
|
RSpec.describe AccountWarningPreset do
|
||||||
describe 'alphabetical' do
|
describe 'Validations' do
|
||||||
|
it { is_expected.to validate_presence_of(:text) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '.alphabetical' do
|
||||||
let(:first) { Fabricate(:account_warning_preset, title: 'aaa', text: 'aaa') }
|
let(:first) { Fabricate(:account_warning_preset, title: 'aaa', text: 'aaa') }
|
||||||
let(:second) { Fabricate(:account_warning_preset, title: 'bbb', text: 'aaa') }
|
let(:second) { Fabricate(:account_warning_preset, title: 'bbb', text: 'aaa') }
|
||||||
let(:third) { Fabricate(:account_warning_preset, title: 'bbb', text: 'bbb') }
|
let(:third) { Fabricate(:account_warning_preset, title: 'bbb', text: 'bbb') }
|
||||||
|
@ -14,4 +18,29 @@ RSpec.describe AccountWarningPreset do
|
||||||
expect(results).to eq([first, second, third])
|
expect(results).to eq([first, second, third])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#to_label' do
|
||||||
|
subject { Fabricate.build(:account_warning_preset, title:, text:).to_label }
|
||||||
|
|
||||||
|
let(:title) { nil }
|
||||||
|
let(:text) { 'Preset text' }
|
||||||
|
|
||||||
|
context 'when title is blank' do
|
||||||
|
it { is_expected.to eq('Preset text') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when title is present' do
|
||||||
|
let(:title) { 'Title' }
|
||||||
|
|
||||||
|
it { is_expected.to eq('Title - Preset text') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when text is longer than limit' do
|
||||||
|
let(:title) { 'Title' }
|
||||||
|
|
||||||
|
before { stub_const('AccountWarningPreset::LABEL_TEXT_LENGTH', 10) }
|
||||||
|
|
||||||
|
it { is_expected.to eq('Title - Preset ...') }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ RSpec.describe 'Admin Account Actions' do
|
||||||
|
|
||||||
describe 'Creating a new account action on an account' do
|
describe 'Creating a new account action on an account' do
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
let!(:account_warning_preset) { Fabricate :account_warning_preset }
|
||||||
|
|
||||||
it 'creates the action and redirects to the account page' do
|
it 'creates the action and redirects to the account page' do
|
||||||
visit new_admin_account_action_path(account_id: account.id)
|
visit new_admin_account_action_path(account_id: account.id)
|
||||||
|
@ -23,6 +24,7 @@ RSpec.describe 'Admin Account Actions' do
|
||||||
|
|
||||||
# Valid submission
|
# Valid submission
|
||||||
choose(option: 'silence')
|
choose(option: 'silence')
|
||||||
|
select account_warning_preset.to_label, from: 'admin_account_action_warning_preset_id'
|
||||||
expect { submit_form }
|
expect { submit_form }
|
||||||
.to change { account.strikes.count }.by(1)
|
.to change { account.strikes.count }.by(1)
|
||||||
expect(page)
|
expect(page)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user