From 81a04ac25cb5a25d8501e59a16b272a6b4e177f0 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 22 Mar 2024 17:25:36 +0100 Subject: [PATCH] Improve specs for severed relationships (#29688) --- spec/features/severed_relationships_spec.rb | 24 +++++++++++++++++++++ spec/requests/severed_relationships_spec.rb | 24 --------------------- spec/services/block_domain_service_spec.rb | 5 ++++- 3 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 spec/features/severed_relationships_spec.rb delete mode 100644 spec/requests/severed_relationships_spec.rb diff --git a/spec/features/severed_relationships_spec.rb b/spec/features/severed_relationships_spec.rb new file mode 100644 index 0000000000..b933398a08 --- /dev/null +++ b/spec/features/severed_relationships_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe 'Severed relationships page' do + include ProfileStories + + describe 'GET severed_relationships#index' do + before do + as_a_logged_in_user + + event = Fabricate(:relationship_severance_event) + Fabricate.times(3, :severed_relationship, local_account: bob.account, relationship_severance_event: event) + Fabricate(:account_relationship_severance_event, account: bob.account, relationship_severance_event: event) + end + + it 'returns http success' do + visit severed_relationships_path + + expect(page).to have_title(I18n.t('settings.severed_relationships')) + expect(page).to have_link(href: following_severed_relationship_path(AccountRelationshipSeveranceEvent.first, format: :csv)) + end + end +end diff --git a/spec/requests/severed_relationships_spec.rb b/spec/requests/severed_relationships_spec.rb deleted file mode 100644 index 05a48ca349..0000000000 --- a/spec/requests/severed_relationships_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe 'Severed relationships page' do - include RoutingHelper - - describe 'GET severed_relationships#index' do - let(:user) { Fabricate(:user) } - let(:event) { Fabricate(:account_relationship_severance_event, account: user.account) } - - before do - sign_in user - - Fabricate.times(3, :severed_relationship, local_account: user.account, relationship_severance_event: event.relationship_severance_event) - end - - it 'returns http success' do - get severed_relationships_path - - expect(response).to have_http_status(200) - end - end -end diff --git a/spec/services/block_domain_service_spec.rb b/spec/services/block_domain_service_spec.rb index 26f80eaf62..d4f0c042d4 100644 --- a/spec/services/block_domain_service_spec.rb +++ b/spec/services/block_domain_service_spec.rb @@ -19,7 +19,7 @@ RSpec.describe BlockDomainService do bystander.follow!(local_account) end - it 'creates a domain block, suspends remote accounts with appropriate suspension date, records severed relationships', :aggregate_failures do + it 'creates a domain block, suspends remote accounts with appropriate suspension date, records severed relationships and sends notification', :aggregate_failures do subject.call(DomainBlock.create!(domain: 'evil.org', severity: :suspend)) expect(DomainBlock.blocked?('evil.org')).to be true @@ -42,6 +42,9 @@ RSpec.describe BlockDomainService do expect(severed_relationships.count).to eq 2 expect(severed_relationships[0].relationship_severance_event).to eq severed_relationships[1].relationship_severance_event expect(severed_relationships.map { |rel| [rel.account, rel.target_account] }).to contain_exactly([bystander, local_account], [local_account, bad_account]) + + # Sends severed relationships notification + expect(LocalNotificationWorker).to have_enqueued_sidekiq_job(local_account.id, anything, 'AccountRelationshipSeveranceEvent', 'severed_relationships') end end