Fix RSpec/MessageSpies cop (#27751)

This commit is contained in:
Matt Jankowski authored and GitHub committed 2023-11-07 09:46:28 +00:00
1 parent ae0d551d33
commit 49e2772064
19 files changed
+162 -94

No files matched your search

@@ -18,21 +18,8 @@ RSpec.describe Admin::AccountsController do
end
it 'filters with parameters' do
new = AccountFilter.method(:new)
expect(AccountFilter).to receive(:new) do |params|
h = params.to_h
expect(h[:origin]).to eq 'local'
expect(h[:by_domain]).to eq 'domain'
expect(h[:status]).to eq 'active'
expect(h[:username]).to eq 'username'
expect(h[:display_name]).to eq 'display name'
expect(h[:email]).to eq 'local-part@domain'
expect(h[:ip]).to eq '0.0.0.42'
new.call({})
end
account_filter = instance_double(AccountFilter, results: Account.all)
allow(AccountFilter).to receive(:new).and_return(account_filter)
get :index, params: {
origin: 'local',
@@ -43,6 +30,18 @@ RSpec.describe Admin::AccountsController do
email: 'local-part@domain',
ip: '0.0.0.42',
}
expect(AccountFilter).to have_received(:new) do |params|
h = params.to_h
expect(h[:origin]).to eq 'local'
expect(h[:by_domain]).to eq 'domain'
expect(h[:status]).to eq 'active'
expect(h[:username]).to eq 'username'
expect(h[:display_name]).to eq 'display name'
expect(h[:email]).to eq 'local-part@domain'
expect(h[:ip]).to eq '0.0.0.42'
end
end
it 'paginates accounts' do