Skip to content

Commit

Permalink
Fix RSpec/SubjectStub cop (#25550)
Browse files Browse the repository at this point in the history
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
  • Loading branch information
mjankowski and ClearlyClaire committed Jul 12, 2023
1 parent 7824df0 commit 74806de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
5 changes: 0 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,6 @@ RSpec/StubbedMock:
- 'spec/lib/webfinger_resource_spec.rb'
- 'spec/services/activitypub/process_collection_service_spec.rb'

RSpec/SubjectStub:
Exclude:
- 'spec/services/unallow_domain_service_spec.rb'
- 'spec/validators/blacklisted_email_validator_spec.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/ApplicationController:
Exclude:
Expand Down
4 changes: 2 additions & 2 deletions spec/services/unallow_domain_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

context 'with limited federation mode' do
before do
allow(subject).to receive(:whitelist_mode?).and_return(true)
allow(Rails.configuration.x).to receive(:whitelist_mode).and_return(true)
end

describe '#call' do
Expand All @@ -40,7 +40,7 @@

context 'without limited federation mode' do
before do
allow(subject).to receive(:whitelist_mode?).and_return(false)
allow(Rails.configuration.x).to receive(:whitelist_mode).and_return(false)
end

describe '#call' do
Expand Down
11 changes: 7 additions & 4 deletions spec/validators/blacklisted_email_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@

before do
allow(user).to receive(:valid_invitation?).and_return(false)
allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email }
allow(EmailDomainBlock).to receive(:block?) { blocked_email }
end

context 'when e-mail provider is blocked' do
let(:blocked_email) { true }

it 'adds error' do
expect(subject).to have_received(:add).with(:email, :blocked)
described_class.new.validate(user)
expect(errors).to have_received(:add).with(:email, :blocked).once
end
end

context 'when e-mail provider is not blocked' do
let(:blocked_email) { false }

it 'does not add errors' do
expect(subject).to_not have_received(:add).with(:email, :blocked)
described_class.new.validate(user)
expect(errors).to_not have_received(:add)
end

context 'when canonical e-mail is blocked' do
Expand All @@ -37,7 +39,8 @@
end

it 'adds error' do
expect(subject).to have_received(:add).with(:email, :taken)
described_class.new.validate(user)
expect(errors).to have_received(:add).with(:email, :taken).once
end
end
end
Expand Down

0 comments on commit 74806de

Please sign in to comment.