Merge remote-tracking branch 'parent/main' into upstream-20240109
This commit is contained in:
commit
d35fa72842
333 changed files with 4444 additions and 2541 deletions
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::AccountModerationNotes' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
let(:target_account) { Fabricate(:account) }
|
||||
|
||||
before { sign_in current_user }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Accounts' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
|
|
|
@ -121,6 +121,6 @@ RSpec.describe 'Admin::Announcements' do
|
|||
end
|
||||
|
||||
def admin_user
|
||||
Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
|
||||
Fabricate(:admin_user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::CustomEmojis' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in current_user }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::DomainAllows' do
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
let(:domain) { 'host.example' }
|
||||
|
||||
before do
|
||||
|
|
|
@ -5,7 +5,7 @@ require 'rails_helper'
|
|||
RSpec.describe 'blocking domains through the moderation interface' do
|
||||
before do
|
||||
allow(DomainBlockWorker).to receive(:perform_async).and_return(true)
|
||||
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
|
||||
sign_in Fabricate(:admin_user), scope: :user
|
||||
end
|
||||
|
||||
context 'when silencing a new domain' do
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::EmailDomainBlocks' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe 'Admin Invites' do
|
|||
describe 'Invite interaction' do
|
||||
let!(:invite) { Fabricate(:invite, expires_at: nil) }
|
||||
|
||||
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::IpBlocks' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in current_user }
|
||||
|
||||
|
|
80
spec/system/admin/relays_spec.rb
Normal file
80
spec/system/admin/relays_spec.rb
Normal file
|
@ -0,0 +1,80 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Relays' do
|
||||
describe 'Managing relays' do
|
||||
before { sign_in Fabricate(:admin_user) }
|
||||
|
||||
describe 'Viewing relays' do
|
||||
let!(:relay) { Fabricate :relay }
|
||||
|
||||
it 'lists existing records' do
|
||||
visit admin_relays_path
|
||||
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.relays.title'))
|
||||
.and have_content(relay.inbox_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Creating a new relay' do
|
||||
it 'creates new record with valid attributes' do
|
||||
visit admin_relays_path
|
||||
|
||||
# Visit new page
|
||||
click_on I18n.t('admin.relays.setup')
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.relays.add_new'))
|
||||
|
||||
# Invalid submission
|
||||
fill_in 'relay_inbox_url', with: ''
|
||||
expect { submit_form }
|
||||
.to_not change(Relay, :count)
|
||||
expect(page)
|
||||
.to have_content(/errors below/)
|
||||
|
||||
# Valid submission
|
||||
fill_in 'relay_inbox_url', with: 'https://host.example/hooks/123'
|
||||
expect { submit_form }
|
||||
.to change(Relay, :count).by(1)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.relays.title'))
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.relays.save_and_enable')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Destroy a relay' do
|
||||
let!(:relay) { Fabricate :relay }
|
||||
|
||||
it 'removes the record' do
|
||||
visit admin_relays_path
|
||||
|
||||
expect { click_on I18n.t('admin.relays.delete') }
|
||||
.to change(Relay, :count).by(-1)
|
||||
expect { relay.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Toggle state of relay' do
|
||||
let!(:relay) { Fabricate :relay, state: :accepted }
|
||||
|
||||
it 'switches state as requested' do
|
||||
visit admin_relays_path
|
||||
|
||||
# Disable the initially enabled record
|
||||
expect { click_on I18n.t('admin.relays.disable') }
|
||||
.to change { relay.reload.accepted? }.to(false)
|
||||
|
||||
relay.update(state: :rejected)
|
||||
# Re-enable the record
|
||||
expect { click_on I18n.t('admin.relays.enable') }
|
||||
.to change { relay.reload.pending? }.to(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
130
spec/system/admin/report_notes_spec.rb
Normal file
130
spec/system/admin/report_notes_spec.rb
Normal file
|
@ -0,0 +1,130 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Report Notes' do
|
||||
let(:user) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
describe 'Creating notes' do
|
||||
context 'when report is unresolved' do
|
||||
let(:report) { Fabricate(:report, action_taken_at: nil, action_taken_by_account_id: nil) }
|
||||
|
||||
context 'when resolve is selected' do
|
||||
it 'creates a report note and resolves report' do
|
||||
visit admin_report_path(report)
|
||||
|
||||
fill_in 'report_note_content', with: 'Report note text'
|
||||
expect { submit_form }
|
||||
.to change(ReportNote, :count).by(1)
|
||||
expect(report.reload)
|
||||
.to be_action_taken
|
||||
expect(page)
|
||||
.to have_content(success_message)
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.reports.notes.create_and_resolve')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when resolve is not selected' do
|
||||
it 'creates a report note and does not resolve report' do
|
||||
visit admin_report_path(report)
|
||||
|
||||
fill_in 'report_note_content', with: 'Report note text'
|
||||
expect { submit_form }
|
||||
.to change(ReportNote, :count).by(1)
|
||||
expect(report.reload)
|
||||
.to_not be_action_taken
|
||||
expect(page)
|
||||
.to have_content(success_message)
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.reports.notes.create')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when report is resolved' do
|
||||
let(:report) { Fabricate(:report, action_taken_at: Time.current, action_taken_by_account_id: user.account.id) }
|
||||
|
||||
context 'when create_and_unresolve flag is on' do
|
||||
it 'creates a report note and unresolves report' do
|
||||
visit admin_report_path(report)
|
||||
|
||||
fill_in 'report_note_content', with: 'Report note text'
|
||||
expect { submit_form }
|
||||
.to change(ReportNote, :count).by(1)
|
||||
expect(report.reload)
|
||||
.to_not be_action_taken
|
||||
expect(page)
|
||||
.to have_content(success_message)
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.reports.notes.create_and_unresolve')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when create_and_unresolve flag is false' do
|
||||
it 'creates a report note and does not unresolve report' do
|
||||
visit admin_report_path(report)
|
||||
|
||||
fill_in 'report_note_content', with: 'Report note text'
|
||||
expect { submit_form }
|
||||
.to change(ReportNote, :count).by(1)
|
||||
expect(report.reload)
|
||||
.to be_action_taken
|
||||
expect(page)
|
||||
.to have_content(success_message)
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.reports.notes.create')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when content is not valid' do
|
||||
let(:report) { Fabricate(:report) }
|
||||
|
||||
it 'does not create a note' do
|
||||
visit admin_report_path(report)
|
||||
|
||||
fill_in 'report_note_content', with: ''
|
||||
expect { submit_form }
|
||||
.to_not change(ReportNote, :count)
|
||||
expect(page)
|
||||
.to have_content(/error below/)
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.reports.notes.create')
|
||||
end
|
||||
end
|
||||
|
||||
def success_message
|
||||
I18n.t('admin.report_notes.created_msg')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Removing notes' do
|
||||
let!(:report_note) { Fabricate(:report_note) }
|
||||
|
||||
it 'deletes note' do
|
||||
visit admin_report_path(report_note.report)
|
||||
|
||||
expect { delete_note }
|
||||
.to change(ReportNote, :count).by(-1)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.report_notes.destroyed_msg'))
|
||||
end
|
||||
|
||||
def delete_note
|
||||
click_on I18n.t('admin.reports.notes.delete')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -28,7 +28,7 @@ RSpec.describe 'Admin::Reset' do
|
|||
end
|
||||
|
||||
def admin_user
|
||||
Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
|
||||
Fabricate(:admin_user)
|
||||
end
|
||||
|
||||
def submit_reset
|
||||
|
|
83
spec/system/admin/rules_spec.rb
Normal file
83
spec/system/admin/rules_spec.rb
Normal file
|
@ -0,0 +1,83 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Rules' do
|
||||
describe 'Managing rules' do
|
||||
before { sign_in Fabricate(:admin_user) }
|
||||
|
||||
describe 'Viewing rules' do
|
||||
let!(:rule) { Fabricate :rule, text: 'This is a rule' }
|
||||
|
||||
it 'lists existing records' do
|
||||
visit admin_rules_path
|
||||
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.rules.title'))
|
||||
.and have_content(rule.text)
|
||||
|
||||
click_on(rule.text)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.rules.title'))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Creating a new rule' do
|
||||
it 'creates new record with valid attributes' do
|
||||
visit admin_rules_path
|
||||
|
||||
# Invalid submission
|
||||
fill_in 'rule_text', with: ''
|
||||
expect { submit_form }
|
||||
.to_not change(Rule, :count)
|
||||
expect(page)
|
||||
.to have_content(/error below/)
|
||||
|
||||
# Valid submission
|
||||
fill_in 'rule_text', with: 'No yelling on the bus!'
|
||||
expect { submit_form }
|
||||
.to change(Rule, :count).by(1)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.rules.title'))
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.rules.add_new')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Editing an existing rule' do
|
||||
let!(:rule) { Fabricate :rule, text: 'Rule text' }
|
||||
|
||||
it 'updates with valid attributes' do
|
||||
visit admin_rules_path
|
||||
|
||||
# Invalid submission
|
||||
click_on rule.text
|
||||
fill_in 'rule_text', with: ''
|
||||
expect { submit_form }
|
||||
.to_not change(rule.reload, :updated_at)
|
||||
|
||||
# Valid update
|
||||
fill_in 'rule_text', with: 'What day is this?'
|
||||
expect { submit_form }
|
||||
.to(change { rule.reload.text })
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Destroy a rule' do
|
||||
let!(:rule) { Fabricate :rule }
|
||||
|
||||
it 'removes the record' do
|
||||
visit admin_rules_path
|
||||
|
||||
expect { click_on I18n.t('admin.rules.delete') }
|
||||
.to change { rule.reload.discarded? }.to(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,7 +6,7 @@ RSpec.describe 'finding software updates through the admin interface' do
|
|||
before do
|
||||
Fabricate(:software_update, version: '99.99.99', type: 'major', urgent: true, release_notes: 'https://github.com/mastodon/mastodon/releases/v99')
|
||||
|
||||
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Owner')), scope: :user
|
||||
sign_in Fabricate(:owner_user), scope: :user
|
||||
end
|
||||
|
||||
it 'shows a link to the software updates page, which links to release notes' do
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Statuses' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe 'Admin Tags' do
|
|||
describe 'Tag interaction' do
|
||||
let!(:tag) { Fabricate(:tag, name: 'test') }
|
||||
|
||||
before { sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
before { sign_in Fabricate(:admin_user) }
|
||||
|
||||
it 'allows tags listing and editing' do
|
||||
visit admin_tags_path
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe 'Admin Terms of services' do
|
|||
describe 'Viewing terms of services index page' do
|
||||
let!(:terms) { Fabricate :terms_of_service, text: 'Test terms' }
|
||||
|
||||
before { sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
before { sign_in Fabricate(:admin_user) }
|
||||
|
||||
it 'allows tags listing and editing' do
|
||||
visit admin_terms_of_service_index_path
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Trends::Links::PreviewCardProviders' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Trends::Links' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Trends::Statuses' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin::Trends::Tags' do
|
||||
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
let(:current_user) { Fabricate(:admin_user) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
|
|
81
spec/system/admin/warning_presets_spec.rb
Normal file
81
spec/system/admin/warning_presets_spec.rb
Normal file
|
@ -0,0 +1,81 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin Warning Presets' do
|
||||
describe 'Managing warning presets' do
|
||||
before { sign_in Fabricate(:admin_user) }
|
||||
|
||||
describe 'Viewing warning presets' do
|
||||
let!(:account_warning_preset) { Fabricate :account_warning_preset, text: 'This is a preset' }
|
||||
|
||||
it 'lists existing records' do
|
||||
visit admin_warning_presets_path
|
||||
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.warning_presets.title'))
|
||||
.and have_content(account_warning_preset.text)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Creating a new account warning preset' do
|
||||
it 'creates new record with valid attributes' do
|
||||
visit admin_warning_presets_path
|
||||
|
||||
# Invalid submission
|
||||
fill_in 'account_warning_preset_text', with: ''
|
||||
expect { submit_form }
|
||||
.to_not change(AccountWarningPreset, :count)
|
||||
expect(page)
|
||||
.to have_content(/error below/)
|
||||
|
||||
# Valid submission
|
||||
fill_in 'account_warning_preset_text', with: 'You cant do that here'
|
||||
expect { submit_form }
|
||||
.to change(AccountWarningPreset, :count).by(1)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.warning_presets.title'))
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('admin.warning_presets.add_new')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Editing an existing account warning preset' do
|
||||
let!(:account_warning_preset) { Fabricate :account_warning_preset, text: 'Preset text' }
|
||||
|
||||
it 'updates with valid attributes' do
|
||||
visit admin_warning_presets_path
|
||||
|
||||
# Invalid submission
|
||||
click_on account_warning_preset.text
|
||||
fill_in 'account_warning_preset_text', with: ''
|
||||
expect { submit_form }
|
||||
.to_not change(account_warning_preset.reload, :updated_at)
|
||||
|
||||
# Valid update
|
||||
fill_in 'account_warning_preset_text', with: 'Updated text'
|
||||
expect { submit_form }
|
||||
.to(change { account_warning_preset.reload.text })
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('generic.save_changes')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Destroy an account warning preset' do
|
||||
let!(:account_warning_preset) { Fabricate :account_warning_preset }
|
||||
|
||||
it 'removes the record' do
|
||||
visit admin_warning_presets_path
|
||||
|
||||
expect { click_on I18n.t('admin.warning_presets.delete') }
|
||||
.to change(AccountWarningPreset, :count).by(-1)
|
||||
expect { account_warning_preset.reload }
|
||||
.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe 'Admin Webhooks' do
|
||||
describe 'Managing webhooks' do
|
||||
before { sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
before { sign_in Fabricate(:admin_user) }
|
||||
|
||||
describe 'Viewing webhooks' do
|
||||
let!(:webhook) { Fabricate :webhook }
|
||||
|
@ -77,7 +77,7 @@ RSpec.describe 'Admin Webhooks' do
|
|||
# Valid update
|
||||
fill_in 'webhook_url', with: 'https://host.example/new/value/123'
|
||||
expect { submit_form }
|
||||
.to_not change(webhook.reload, :url)
|
||||
.to(change { webhook.reload.url })
|
||||
end
|
||||
|
||||
def submit_form
|
||||
|
|
53
spec/system/disputes/appeals_spec.rb
Normal file
53
spec/system/disputes/appeals_spec.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Dispute Appeals' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let!(:admin) { Fabricate(:admin_user) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
describe 'Submitting an appeal', :inline_jobs do
|
||||
let(:strike) { Fabricate(:account_warning, target_account: user.account) }
|
||||
|
||||
it 'Submits the appeal and notifies admins' do
|
||||
visit disputes_strike_path(strike)
|
||||
|
||||
# Invalid with missing attribute
|
||||
fill_in 'appeal_text', with: ''
|
||||
emails = capture_emails do
|
||||
expect { submit_form }
|
||||
.to_not change(Appeal, :count)
|
||||
end
|
||||
expect(emails)
|
||||
.to be_empty
|
||||
expect(page)
|
||||
.to have_content(/can't be blank/)
|
||||
|
||||
# Valid with text
|
||||
fill_in 'appeal_text', with: 'It wasnt me this time!'
|
||||
emails = capture_emails do
|
||||
expect { submit_form }
|
||||
.to change(Appeal, :count).by(1)
|
||||
end
|
||||
expect(emails)
|
||||
.to contain_exactly(
|
||||
have_attributes(
|
||||
to: contain_exactly(admin.email),
|
||||
subject: eq(new_appeal_subject)
|
||||
)
|
||||
)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('disputes.strikes.appealed_msg'))
|
||||
end
|
||||
|
||||
def new_appeal_subject
|
||||
I18n.t('admin_mailer.new_appeal.subject', username: user.account.acct, instance: Rails.configuration.x.local_domain)
|
||||
end
|
||||
|
||||
def submit_form
|
||||
click_on I18n.t('disputes.strikes.appeals.submit')
|
||||
end
|
||||
end
|
||||
end
|
99
spec/system/settings/migrations_spec.rb
Normal file
99
spec/system/settings/migrations_spec.rb
Normal file
|
@ -0,0 +1,99 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings Migrations' do
|
||||
describe 'Viewing settings migrations' do
|
||||
let(:user) { Fabricate(:account, moved_to_account: moved_to_account).user }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
context 'when user does not have moved to account' do
|
||||
let(:moved_to_account) { nil }
|
||||
|
||||
it 'renders show page' do
|
||||
visit settings_migration_path
|
||||
|
||||
expect(page)
|
||||
.to have_content(I18n.t('settings.migrate'))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user has a moved to account' do
|
||||
let(:moved_to_account) { Fabricate(:account) }
|
||||
|
||||
it 'renders show page and account details' do
|
||||
visit settings_migration_path
|
||||
|
||||
expect(page)
|
||||
.to have_content(I18n.t('settings.migrate'))
|
||||
.and have_content(moved_to_account.pretty_acct)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Creating migrations' do
|
||||
let(:user) { Fabricate(:user, password: '12345678') }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
context 'when migration account is changed' do
|
||||
let(:acct) { Fabricate(:account, also_known_as: [ActivityPub::TagManager.instance.uri_for(user.account)]) }
|
||||
|
||||
it 'updates moved to account' do
|
||||
visit settings_migration_path
|
||||
|
||||
expect { fill_in_and_submit }
|
||||
.to(change { user.account.reload.moved_to_account_id }.to(acct.id))
|
||||
expect(page)
|
||||
.to have_content(I18n.t('settings.migrate'))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when acct is the current account' do
|
||||
let(:acct) { user.account }
|
||||
|
||||
it 'does not update the moved account', :aggregate_failures do
|
||||
visit settings_migration_path
|
||||
|
||||
expect { fill_in_and_submit }
|
||||
.to_not(change { user.account.reload.moved_to_account_id }.from(nil))
|
||||
expect(page)
|
||||
.to have_content(I18n.t('settings.migrate'))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when target account does not reference the account being moved from' do
|
||||
let(:acct) { Fabricate(:account, also_known_as: []) }
|
||||
|
||||
it 'does not update the moved account', :aggregate_failures do
|
||||
visit settings_migration_path
|
||||
|
||||
expect { fill_in_and_submit }
|
||||
.to_not(change { user.account.reload.moved_to_account_id }.from(nil))
|
||||
expect(page)
|
||||
.to have_content(I18n.t('settings.migrate'))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a recent migration already exists' do
|
||||
let(:acct) { Fabricate(:account, also_known_as: [ActivityPub::TagManager.instance.uri_for(user.account)]) }
|
||||
let(:moved_to) { Fabricate(:account, also_known_as: [ActivityPub::TagManager.instance.uri_for(user.account)]) }
|
||||
|
||||
before { user.account.migrations.create!(acct: moved_to.acct) }
|
||||
|
||||
it 'can not update the moved account', :aggregate_failures do
|
||||
visit settings_migration_path
|
||||
|
||||
expect(find_by_id('account_migration_acct'))
|
||||
.to be_disabled
|
||||
end
|
||||
end
|
||||
|
||||
def fill_in_and_submit
|
||||
fill_in 'account_migration_acct', with: acct.username
|
||||
fill_in 'account_migration_current_password', with: '12345678'
|
||||
click_on I18n.t('migrations.proceed_with_move')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue