forked from treehouse/mastodon
Fix test-related issues (#17888)
* Remove obsolete RSS::Serializer test Since #17828, RSS::Serializer no longer has specific code for deleted statuses, but it is never called on deleted statuses anyway. * Rename erroneously-named test files * Fix failing test * Fix test deprecation warnings * Update CircleCI Ruby orb 1.4.0 has a bug that does not match all the test files due to incorrect globbingrebase/4.0.0rc2
parent
56edc6552f
commit
30658924a8
|
@ -1,7 +1,7 @@
|
||||||
version: 2.1
|
version: 2.1
|
||||||
|
|
||||||
orbs:
|
orbs:
|
||||||
ruby: circleci/ruby@1.4.0
|
ruby: circleci/ruby@1.4.1
|
||||||
node: circleci/node@5.0.1
|
node: circleci/node@5.0.1
|
||||||
|
|
||||||
executors:
|
executors:
|
||||||
|
|
|
@ -194,9 +194,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #unblock_email' do
|
describe 'POST #unblock_email' do
|
||||||
subject do
|
subject { post :unblock_email, params: { id: account.id } }
|
||||||
-> { post :unblock_email, params: { id: account.id } }
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:current_user) { Fabricate(:user, admin: admin) }
|
let(:current_user) { Fabricate(:user, admin: admin) }
|
||||||
let(:account) { Fabricate(:account, suspended: true) }
|
let(:account) { Fabricate(:account, suspended: true) }
|
||||||
|
@ -206,11 +204,11 @@ RSpec.describe Admin::AccountsController, type: :controller do
|
||||||
let(:admin) { true }
|
let(:admin) { true }
|
||||||
|
|
||||||
it 'succeeds in removing email blocks' do
|
it 'succeeds in removing email blocks' do
|
||||||
is_expected.to change { CanonicalEmailBlock.where(reference_account: account).count }.from(1).to(0)
|
expect { subject }.to change { CanonicalEmailBlock.where(reference_account: account).count }.from(1).to(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to admin account path' do
|
it 'redirects to admin account path' do
|
||||||
subject.call
|
subject
|
||||||
expect(response).to redirect_to admin_account_path(account.id)
|
expect(response).to redirect_to admin_account_path(account.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -219,7 +217,7 @@ RSpec.describe Admin::AccountsController, type: :controller do
|
||||||
let(:admin) { false }
|
let(:admin) { false }
|
||||||
|
|
||||||
it 'fails to remove avatar' do
|
it 'fails to remove avatar' do
|
||||||
subject.call
|
subject
|
||||||
expect(response).to have_http_status :forbidden
|
expect(response).to have_http_status :forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,16 @@ require 'rails_helper'
|
||||||
describe Settings::Exports::BookmarksController do
|
describe Settings::Exports::BookmarksController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
describe 'GET #index' do
|
let(:user) { Fabricate(:user) }
|
||||||
it 'returns a csv of the bookmarked toots' do
|
let(:account) { Fabricate(:account, domain: 'foo.bar') }
|
||||||
user = Fabricate(:user)
|
let(:status) { Fabricate(:status, account: account, uri: 'https://foo.bar/statuses/1312') }
|
||||||
user.account.bookmarks.create!(status: Fabricate(:status, uri: 'https://foo.bar/statuses/1312'))
|
|
||||||
|
|
||||||
|
describe 'GET #index' do
|
||||||
|
before do
|
||||||
|
user.account.bookmarks.create!(status: status)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a csv of the bookmarked toots' do
|
||||||
sign_in user, scope: :user
|
sign_in user, scope: :user
|
||||||
get :index, format: :csv
|
get :index, format: :csv
|
||||||
|
|
|
@ -13,13 +13,6 @@ describe RSS::Serializer do
|
||||||
|
|
||||||
subject { RSS::Serializer.new.send(:status_title, status) }
|
subject { RSS::Serializer.new.send(:status_title, status) }
|
||||||
|
|
||||||
context 'if destroyed?' do
|
|
||||||
it 'returns "#{account.acct} deleted status"' do
|
|
||||||
status.destroy!
|
|
||||||
expect(subject).to eq "#{account.acct} deleted status"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'on a toot with long text' do
|
context 'on a toot with long text' do
|
||||||
let(:text) { "This toot's text is longer than the allowed number of characters" }
|
let(:text) { "This toot's text is longer than the allowed number of characters" }
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AfterBlockService, type: :service do
|
RSpec.describe AfterBlockService, type: :service do
|
||||||
subject do
|
subject { described_class.new.call(account, target_account) }
|
||||||
-> { described_class.new.call(account, target_account) }
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
let(:target_account) { Fabricate(:account) }
|
let(:target_account) { Fabricate(:account) }
|
||||||
|
@ -24,7 +22,7 @@ RSpec.describe AfterBlockService, type: :service do
|
||||||
FeedManager.instance.push_to_home(account, other_account_status)
|
FeedManager.instance.push_to_home(account, other_account_status)
|
||||||
FeedManager.instance.push_to_home(account, other_account_reblog)
|
FeedManager.instance.push_to_home(account, other_account_reblog)
|
||||||
|
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
Redis.current.zrange(home_timeline_key, 0, -1)
|
Redis.current.zrange(home_timeline_key, 0, -1)
|
||||||
}.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
|
}.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
|
||||||
end
|
end
|
||||||
|
@ -43,7 +41,7 @@ RSpec.describe AfterBlockService, type: :service do
|
||||||
FeedManager.instance.push_to_list(list, other_account_status)
|
FeedManager.instance.push_to_list(list, other_account_status)
|
||||||
FeedManager.instance.push_to_list(list, other_account_reblog)
|
FeedManager.instance.push_to_list(list, other_account_reblog)
|
||||||
|
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
Redis.current.zrange(list_timeline_key, 0, -1)
|
Redis.current.zrange(list_timeline_key, 0, -1)
|
||||||
}.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
|
}.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,12 +23,10 @@ RSpec.describe DeleteAccountService, type: :service do
|
||||||
|
|
||||||
let!(:account_note) { Fabricate(:account_note, account: account) }
|
let!(:account_note) { Fabricate(:account_note, account: account) }
|
||||||
|
|
||||||
subject do
|
subject { described_class.new.call(account) }
|
||||||
-> { described_class.new.call(account) }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'deletes associated owned records' do
|
it 'deletes associated owned records' do
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
[
|
[
|
||||||
account.statuses,
|
account.statuses,
|
||||||
account.media_attachments,
|
account.media_attachments,
|
||||||
|
@ -43,7 +41,7 @@ RSpec.describe DeleteAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes associated target records' do
|
it 'deletes associated target records' do
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
[
|
[
|
||||||
AccountPin.where(target_account: account),
|
AccountPin.where(target_account: account),
|
||||||
].map(&:count)
|
].map(&:count)
|
||||||
|
@ -51,7 +49,7 @@ RSpec.describe DeleteAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes associated target notifications' do
|
it 'deletes associated target notifications' do
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
[
|
[
|
||||||
'poll', 'favourite', 'status', 'mention', 'follow'
|
'poll', 'favourite', 'status', 'mention', 'follow'
|
||||||
].map { |type| Notification.where(type: type).count }
|
].map { |type| Notification.where(type: type).count }
|
||||||
|
@ -73,7 +71,7 @@ RSpec.describe DeleteAccountService, type: :service do
|
||||||
let!(:local_follower) { Fabricate(:account) }
|
let!(:local_follower) { Fabricate(:account) }
|
||||||
|
|
||||||
it 'sends a delete actor activity to all known inboxes' do
|
it 'sends a delete actor activity to all known inboxes' do
|
||||||
subject.call
|
subject
|
||||||
expect(a_request(:post, "https://alice.com/inbox")).to have_been_made.once
|
expect(a_request(:post, "https://alice.com/inbox")).to have_been_made.once
|
||||||
expect(a_request(:post, "https://bob.com/inbox")).to have_been_made.once
|
expect(a_request(:post, "https://bob.com/inbox")).to have_been_made.once
|
||||||
end
|
end
|
||||||
|
@ -91,7 +89,7 @@ RSpec.describe DeleteAccountService, type: :service do
|
||||||
let!(:local_follower) { Fabricate(:account) }
|
let!(:local_follower) { Fabricate(:account) }
|
||||||
|
|
||||||
it 'sends a reject follow to follower inboxes' do
|
it 'sends a reject follow to follower inboxes' do
|
||||||
subject.call
|
subject
|
||||||
expect(a_request(:post, account.inbox_url)).to have_been_made.once
|
expect(a_request(:post, account.inbox_url)).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe MuteService, type: :service do
|
RSpec.describe MuteService, type: :service do
|
||||||
subject do
|
subject { described_class.new.call(account, target_account) }
|
||||||
-> { described_class.new.call(account, target_account) }
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
let(:target_account) { Fabricate(:account) }
|
let(:target_account) { Fabricate(:account) }
|
||||||
|
@ -21,45 +19,41 @@ RSpec.describe MuteService, type: :service do
|
||||||
FeedManager.instance.push_to_home(account, status)
|
FeedManager.instance.push_to_home(account, status)
|
||||||
FeedManager.instance.push_to_home(account, other_account_status)
|
FeedManager.instance.push_to_home(account, other_account_status)
|
||||||
|
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
Redis.current.zrange(home_timeline_key, 0, -1)
|
Redis.current.zrange(home_timeline_key, 0, -1)
|
||||||
}.from([status.id.to_s, other_account_status.id.to_s]).to([other_account_status.id.to_s])
|
}.from([status.id.to_s, other_account_status.id.to_s]).to([other_account_status.id.to_s])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'mutes account' do
|
it 'mutes account' do
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
account.muting?(target_account)
|
account.muting?(target_account)
|
||||||
}.from(false).to(true)
|
}.from(false).to(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without specifying a notifications parameter' do
|
context 'without specifying a notifications parameter' do
|
||||||
it 'mutes notifications from the account' do
|
it 'mutes notifications from the account' do
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
account.muting_notifications?(target_account)
|
account.muting_notifications?(target_account)
|
||||||
}.from(false).to(true)
|
}.from(false).to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a true notifications parameter' do
|
context 'with a true notifications parameter' do
|
||||||
subject do
|
subject { described_class.new.call(account, target_account, notifications: true) }
|
||||||
-> { described_class.new.call(account, target_account, notifications: true) }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'mutes notifications from the account' do
|
it 'mutes notifications from the account' do
|
||||||
is_expected.to change {
|
expect { subject }.to change {
|
||||||
account.muting_notifications?(target_account)
|
account.muting_notifications?(target_account)
|
||||||
}.from(false).to(true)
|
}.from(false).to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a false notifications parameter' do
|
context 'with a false notifications parameter' do
|
||||||
subject do
|
subject { described_class.new.call(account, target_account, notifications: false) }
|
||||||
-> { described_class.new.call(account, target_account, notifications: false) }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not mute notifications from the account' do
|
it 'does not mute notifications from the account' do
|
||||||
is_expected.to_not change {
|
expect { subject }.to_not change {
|
||||||
account.muting_notifications?(target_account)
|
account.muting_notifications?(target_account)
|
||||||
}.from(false)
|
}.from(false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe NotifyService, type: :service do
|
RSpec.describe NotifyService, type: :service do
|
||||||
subject do
|
subject { described_class.new.call(recipient, type, activity) }
|
||||||
-> { described_class.new.call(recipient, type, activity) }
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
let(:recipient) { user.account }
|
let(:recipient) { user.account }
|
||||||
|
@ -11,42 +9,42 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:activity) { Fabricate(:follow, account: sender, target_account: recipient) }
|
let(:activity) { Fabricate(:follow, account: sender, target_account: recipient) }
|
||||||
let(:type) { :follow }
|
let(:type) { :follow }
|
||||||
|
|
||||||
it { is_expected.to change(Notification, :count).by(1) }
|
it { expect { subject }.to change(Notification, :count).by(1) }
|
||||||
|
|
||||||
it 'does not notify when sender is blocked' do
|
it 'does not notify when sender is blocked' do
|
||||||
recipient.block!(sender)
|
recipient.block!(sender)
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not notify when sender is muted with hide_notifications' do
|
it 'does not notify when sender is muted with hide_notifications' do
|
||||||
recipient.mute!(sender, notifications: true)
|
recipient.mute!(sender, notifications: true)
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does notify when sender is muted without hide_notifications' do
|
it 'does notify when sender is muted without hide_notifications' do
|
||||||
recipient.mute!(sender, notifications: false)
|
recipient.mute!(sender, notifications: false)
|
||||||
is_expected.to change(Notification, :count)
|
expect { subject }.to change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not notify when sender\'s domain is blocked' do
|
it 'does not notify when sender\'s domain is blocked' do
|
||||||
recipient.block_domain!(sender.domain)
|
recipient.block_domain!(sender.domain)
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does still notify when sender\'s domain is blocked but sender is followed' do
|
it 'does still notify when sender\'s domain is blocked but sender is followed' do
|
||||||
recipient.block_domain!(sender.domain)
|
recipient.block_domain!(sender.domain)
|
||||||
recipient.follow!(sender)
|
recipient.follow!(sender)
|
||||||
is_expected.to change(Notification, :count)
|
expect { subject }.to change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not notify when sender is silenced and not followed' do
|
it 'does not notify when sender is silenced and not followed' do
|
||||||
sender.silence!
|
sender.silence!
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not notify when recipient is suspended' do
|
it 'does not notify when recipient is suspended' do
|
||||||
recipient.suspend!
|
recipient.suspend!
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for direct messages' do
|
context 'for direct messages' do
|
||||||
|
@ -61,7 +59,7 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:enabled) { true }
|
let(:enabled) { true }
|
||||||
|
|
||||||
it 'does not notify' do
|
it 'does not notify' do
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'if the message chain is initiated by recipient, but is not direct message' do
|
context 'if the message chain is initiated by recipient, but is not direct message' do
|
||||||
|
@ -70,7 +68,7 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
|
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
|
||||||
|
|
||||||
it 'does not notify' do
|
it 'does not notify' do
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,7 +79,7 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: dummy_reply)) }
|
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: dummy_reply)) }
|
||||||
|
|
||||||
it 'does not notify' do
|
it 'does not notify' do
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,7 +89,7 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
|
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
|
||||||
|
|
||||||
it 'does notify' do
|
it 'does notify' do
|
||||||
is_expected.to change(Notification, :count)
|
expect { subject }.to change(Notification, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -100,7 +98,7 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:enabled) { false }
|
let(:enabled) { false }
|
||||||
|
|
||||||
it 'does notify' do
|
it 'does notify' do
|
||||||
is_expected.to change(Notification, :count)
|
expect { subject }.to change(Notification, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -112,17 +110,17 @@ RSpec.describe NotifyService, type: :service do
|
||||||
|
|
||||||
it 'shows reblogs by default' do
|
it 'shows reblogs by default' do
|
||||||
recipient.follow!(sender)
|
recipient.follow!(sender)
|
||||||
is_expected.to change(Notification, :count)
|
expect { subject }.to change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows reblogs when explicitly enabled' do
|
it 'shows reblogs when explicitly enabled' do
|
||||||
recipient.follow!(sender, reblogs: true)
|
recipient.follow!(sender, reblogs: true)
|
||||||
is_expected.to change(Notification, :count)
|
expect { subject }.to change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows reblogs when disabled' do
|
it 'shows reblogs when disabled' do
|
||||||
recipient.follow!(sender, reblogs: false)
|
recipient.follow!(sender, reblogs: false)
|
||||||
is_expected.to change(Notification, :count)
|
expect { subject }.to change(Notification, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,12 +132,12 @@ RSpec.describe NotifyService, type: :service do
|
||||||
|
|
||||||
it 'does not notify when conversation is muted' do
|
it 'does not notify when conversation is muted' do
|
||||||
recipient.mute_conversation!(activity.status.conversation)
|
recipient.mute_conversation!(activity.status.conversation)
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not notify when it is a reply to a blocked user' do
|
it 'does not notify when it is a reply to a blocked user' do
|
||||||
recipient.block!(asshole)
|
recipient.block!(asshole)
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -147,7 +145,7 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:sender) { recipient }
|
let(:sender) { recipient }
|
||||||
|
|
||||||
it 'does not notify when recipient is the sender' do
|
it 'does not notify when recipient is the sender' do
|
||||||
is_expected.to_not change(Notification, :count)
|
expect { subject }.to_not change(Notification, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -163,7 +161,7 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:enabled) { true }
|
let(:enabled) { true }
|
||||||
|
|
||||||
it 'sends email' do
|
it 'sends email' do
|
||||||
is_expected.to change(ActionMailer::Base.deliveries, :count).by(1)
|
expect { subject }.to change(ActionMailer::Base.deliveries, :count).by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -171,7 +169,7 @@ RSpec.describe NotifyService, type: :service do
|
||||||
let(:enabled) { false }
|
let(:enabled) { false }
|
||||||
|
|
||||||
it "doesn't send email" do
|
it "doesn't send email" do
|
||||||
is_expected.to_not change(ActionMailer::Base.deliveries, :count).from(0)
|
expect { subject }.to_not change(ActionMailer::Base.deliveries, :count).from(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,9 +5,7 @@ RSpec.describe SuspendAccountService, type: :service do
|
||||||
let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account }
|
let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account }
|
||||||
let!(:list) { Fabricate(:list, account: local_follower) }
|
let!(:list) { Fabricate(:list, account: local_follower) }
|
||||||
|
|
||||||
subject do
|
subject { described_class.new.call(account) }
|
||||||
-> { described_class.new.call(account) }
|
|
||||||
end
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil)
|
allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil)
|
||||||
|
@ -18,13 +16,13 @@ RSpec.describe SuspendAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "unmerges from local followers' feeds" do
|
it "unmerges from local followers' feeds" do
|
||||||
subject.call
|
subject
|
||||||
expect(FeedManager.instance).to have_received(:unmerge_from_home).with(account, local_follower)
|
expect(FeedManager.instance).to have_received(:unmerge_from_home).with(account, local_follower)
|
||||||
expect(FeedManager.instance).to have_received(:unmerge_from_list).with(account, list)
|
expect(FeedManager.instance).to have_received(:unmerge_from_list).with(account, list)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'marks account as suspended' do
|
it 'marks account as suspended' do
|
||||||
is_expected.to change { account.suspended? }.from(false).to(true)
|
expect { subject }.to change { account.suspended? }.from(false).to(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,7 +49,7 @@ RSpec.describe SuspendAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends an update actor to followers and reporters' do
|
it 'sends an update actor to followers and reporters' do
|
||||||
subject.call
|
subject
|
||||||
expect(a_request(:post, remote_follower.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once
|
expect(a_request(:post, remote_follower.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once
|
||||||
expect(a_request(:post, remote_reporter.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once
|
expect(a_request(:post, remote_reporter.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once
|
||||||
end
|
end
|
||||||
|
@ -77,7 +75,7 @@ RSpec.describe SuspendAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends a reject follow' do
|
it 'sends a reject follow' do
|
||||||
subject.call
|
subject
|
||||||
expect(a_request(:post, account.inbox_url).with { |req| match_reject_follow_request(req, account, local_followee) }).to have_been_made.once
|
expect(a_request(:post, account.inbox_url).with { |req| match_reject_follow_request(req, account, local_followee) }).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,9 +5,7 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
||||||
let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account }
|
let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account }
|
||||||
let!(:list) { Fabricate(:list, account: local_follower) }
|
let!(:list) { Fabricate(:list, account: local_follower) }
|
||||||
|
|
||||||
subject do
|
subject { described_class.new.call(account) }
|
||||||
-> { described_class.new.call(account) }
|
|
||||||
end
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil)
|
allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil)
|
||||||
|
@ -33,7 +31,7 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'marks account as unsuspended' do
|
it 'marks account as unsuspended' do
|
||||||
is_expected.to change { account.suspended? }.from(true).to(false)
|
expect { subject }.to change { account.suspended? }.from(true).to(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
include_examples 'common behavior' do
|
include_examples 'common behavior' do
|
||||||
|
@ -47,13 +45,13 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "merges back into local followers' feeds" do
|
it "merges back into local followers' feeds" do
|
||||||
subject.call
|
subject
|
||||||
expect(FeedManager.instance).to have_received(:merge_into_home).with(account, local_follower)
|
expect(FeedManager.instance).to have_received(:merge_into_home).with(account, local_follower)
|
||||||
expect(FeedManager.instance).to have_received(:merge_into_list).with(account, list)
|
expect(FeedManager.instance).to have_received(:merge_into_list).with(account, list)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends an update actor to followers and reporters' do
|
it 'sends an update actor to followers and reporters' do
|
||||||
subject.call
|
subject
|
||||||
expect(a_request(:post, remote_follower.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once
|
expect(a_request(:post, remote_follower.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once
|
||||||
expect(a_request(:post, remote_reporter.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once
|
expect(a_request(:post, remote_reporter.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once
|
||||||
end
|
end
|
||||||
|
@ -75,18 +73,18 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 're-fetches the account' do
|
it 're-fetches the account' do
|
||||||
subject.call
|
subject
|
||||||
expect(resolve_account_service).to have_received(:call).with(account)
|
expect(resolve_account_service).to have_received(:call).with(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "merges back into local followers' feeds" do
|
it "merges back into local followers' feeds" do
|
||||||
subject.call
|
subject
|
||||||
expect(FeedManager.instance).to have_received(:merge_into_home).with(account, local_follower)
|
expect(FeedManager.instance).to have_received(:merge_into_home).with(account, local_follower)
|
||||||
expect(FeedManager.instance).to have_received(:merge_into_list).with(account, list)
|
expect(FeedManager.instance).to have_received(:merge_into_list).with(account, list)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'marks account as unsuspended' do
|
it 'marks account as unsuspended' do
|
||||||
is_expected.to change { account.suspended? }.from(true).to(false)
|
expect { subject }.to change { account.suspended? }.from(true).to(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -99,18 +97,18 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 're-fetches the account' do
|
it 're-fetches the account' do
|
||||||
subject.call
|
subject
|
||||||
expect(resolve_account_service).to have_received(:call).with(account)
|
expect(resolve_account_service).to have_received(:call).with(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not merge back into local followers' feeds" do
|
it "does not merge back into local followers' feeds" do
|
||||||
subject.call
|
subject
|
||||||
expect(FeedManager.instance).to_not have_received(:merge_into_home).with(account, local_follower)
|
expect(FeedManager.instance).to_not have_received(:merge_into_home).with(account, local_follower)
|
||||||
expect(FeedManager.instance).to_not have_received(:merge_into_list).with(account, list)
|
expect(FeedManager.instance).to_not have_received(:merge_into_list).with(account, list)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not mark the account as unsuspended' do
|
it 'does not mark the account as unsuspended' do
|
||||||
is_expected.not_to change { account.suspended? }
|
expect { subject }.not_to change { account.suspended? }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -120,12 +118,12 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 're-fetches the account' do
|
it 're-fetches the account' do
|
||||||
subject.call
|
subject
|
||||||
expect(resolve_account_service).to have_received(:call).with(account)
|
expect(resolve_account_service).to have_received(:call).with(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not merge back into local followers' feeds" do
|
it "does not merge back into local followers' feeds" do
|
||||||
subject.call
|
subject
|
||||||
expect(FeedManager.instance).to_not have_received(:merge_into_home).with(account, local_follower)
|
expect(FeedManager.instance).to_not have_received(:merge_into_home).with(account, local_follower)
|
||||||
expect(FeedManager.instance).to_not have_received(:merge_into_list).with(account, list)
|
expect(FeedManager.instance).to_not have_received(:merge_into_list).with(account, list)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue