Merge commit '82e477b184b5666fff7fb55933dce22ca2925db8' into glitch-soc/merge-upstream
Conflicts: - `db/migrate/20180831171112_create_bookmarks.rb`: Upstream ran a lint fix on this file, but this file is different in glitch-soc because the feature was added much earlier. Ran the lint fix on our own version of the file.
This commit is contained in:
@@ -166,10 +166,11 @@ RSpec.describe Admin::DomainBlocksController do
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
let!(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
||||
let(:subject) do
|
||||
subject do
|
||||
post :update, params: { :id => domain_block.id, :domain_block => { domain: 'example.com', severity: new_severity }, 'confirm' => '' }
|
||||
end
|
||||
|
||||
let!(:remote_account) { Fabricate(:account, domain: 'example.com') }
|
||||
let(:domain_block) { Fabricate(:domain_block, domain: 'example.com', severity: original_severity) }
|
||||
|
||||
before do
|
||||
|
@@ -88,10 +88,11 @@ describe Api::BaseController do
|
||||
Mastodon::NotPermittedError => 403,
|
||||
}.each do |error, code|
|
||||
it "Handles error class of #{error}" do
|
||||
expect(FakeService).to receive(:new).and_raise(error)
|
||||
allow(FakeService).to receive(:new).and_raise(error)
|
||||
|
||||
get 'error'
|
||||
expect(response).to have_http_status(code)
|
||||
expect(FakeService).to have_received(:new)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -16,7 +16,7 @@ RSpec.describe Api::V1::MediaController do
|
||||
describe 'with paperclip errors' do
|
||||
context 'when imagemagick cant identify the file type' do
|
||||
it 'returns http 422' do
|
||||
expect_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Errors::NotIdentifiedByImageMagickError)
|
||||
allow_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Errors::NotIdentifiedByImageMagickError)
|
||||
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
@@ -25,7 +25,7 @@ RSpec.describe Api::V1::MediaController do
|
||||
|
||||
context 'when there is a generic error' do
|
||||
it 'returns http 422' do
|
||||
expect_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Error)
|
||||
allow_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Error)
|
||||
post :create, params: { file: fixture_file_upload('attachment.jpg', 'image/jpeg') }
|
||||
|
||||
expect(response).to have_http_status(500)
|
||||
|
@@ -15,20 +15,22 @@ RSpec.describe Auth::RegistrationsController do
|
||||
it 'redirects if it is in single user mode while it is open for registration' do
|
||||
Fabricate(:account)
|
||||
Setting.registrations_mode = 'open'
|
||||
expect(Rails.configuration.x).to receive(:single_user_mode).and_return(true)
|
||||
allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true)
|
||||
|
||||
get path
|
||||
|
||||
expect(response).to redirect_to '/'
|
||||
expect(Rails.configuration.x).to have_received(:single_user_mode)
|
||||
end
|
||||
|
||||
it 'redirects if it is not open for registration while it is not in single user mode' do
|
||||
Setting.registrations_mode = 'none'
|
||||
expect(Rails.configuration.x).to receive(:single_user_mode).and_return(false)
|
||||
allow(Rails.configuration.x).to receive(:single_user_mode).and_return(false)
|
||||
|
||||
get path
|
||||
|
||||
expect(response).to redirect_to '/'
|
||||
expect(Rails.configuration.x).to have_received(:single_user_mode)
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -104,7 +104,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
||||
post :create,
|
||||
params: { form_two_factor_confirmation: { otp_attempt: '123456' } },
|
||||
session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
end.to not_change { user.reload.otp_secret }
|
||||
end.to(not_change { user.reload.otp_secret })
|
||||
end
|
||||
|
||||
it 'renders the new view' do
|
||||
|
@@ -63,7 +63,7 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController do
|
||||
expect do
|
||||
post :create, session: { challenge_passed_at: Time.now.utc }
|
||||
end.to not_change { user.reload.otp_secret }
|
||||
.and change { session[:new_otp_secret] }
|
||||
.and(change { session[:new_otp_secret] })
|
||||
|
||||
expect(response).to redirect_to(new_settings_two_factor_authentication_confirmation_path)
|
||||
end
|
||||
@@ -80,7 +80,7 @@ describe Settings::TwoFactorAuthentication::OtpAuthenticationController do
|
||||
expect do
|
||||
post :create, session: { challenge_passed_at: Time.now.utc }
|
||||
end.to not_change { user.reload.otp_secret }
|
||||
.and change { session[:new_otp_secret] }
|
||||
.and(change { session[:new_otp_secret] })
|
||||
|
||||
expect(response).to redirect_to(new_settings_two_factor_authentication_confirmation_path)
|
||||
end
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
Fabrication.manager.load_definitions if Fabrication.manager.empty?
|
||||
|
@@ -78,19 +78,17 @@ describe ApplicationHelper do
|
||||
|
||||
describe 'open_registrations?' do
|
||||
it 'returns true when open for registrations' do
|
||||
without_partial_double_verification do
|
||||
expect(Setting).to receive(:registrations_mode).and_return('open')
|
||||
end
|
||||
allow(Setting).to receive(:[]).with('registrations_mode').and_return('open')
|
||||
|
||||
expect(helper.open_registrations?).to be true
|
||||
expect(Setting).to have_received(:[]).with('registrations_mode')
|
||||
end
|
||||
|
||||
it 'returns false when closed for registrations' do
|
||||
without_partial_double_verification do
|
||||
expect(Setting).to receive(:registrations_mode).and_return('none')
|
||||
end
|
||||
allow(Setting).to receive(:[]).with('registrations_mode').and_return('none')
|
||||
|
||||
expect(helper.open_registrations?).to be false
|
||||
expect(Setting).to have_received(:[]).with('registrations_mode')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -297,8 +295,9 @@ describe ApplicationHelper do
|
||||
|
||||
it 'returns site title on production environment' do
|
||||
Setting.site_title = 'site title'
|
||||
expect(Rails.env).to receive(:production?).and_return(true)
|
||||
allow(Rails.env).to receive(:production?).and_return(true)
|
||||
expect(helper.title).to eq 'site title'
|
||||
expect(Rails.env).to have_received(:production?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -23,7 +23,7 @@ describe StatusFilter do
|
||||
|
||||
context 'when status policy does not allow show' do
|
||||
it 'filters the status' do
|
||||
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||
allow_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||
|
||||
expect(filter).to be_filtered
|
||||
end
|
||||
@@ -74,7 +74,7 @@ describe StatusFilter do
|
||||
|
||||
context 'when status policy does not allow show' do
|
||||
it 'filters the status' do
|
||||
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||
allow_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
||||
|
||||
expect(filter).to be_filtered
|
||||
end
|
||||
|
@@ -18,10 +18,13 @@ describe StatusFinder do
|
||||
|
||||
it 'raises an error if action is not :show' do
|
||||
recognized = Rails.application.routes.recognize_path(url)
|
||||
expect(recognized).to receive(:[]).with(:action).and_return(:create)
|
||||
expect(Rails.application.routes).to receive(:recognize_path).with(url).and_return(recognized)
|
||||
allow(recognized).to receive(:[]).with(:action).and_return(:create)
|
||||
allow(Rails.application.routes).to receive(:recognize_path).with(url).and_return(recognized)
|
||||
|
||||
expect { subject.status }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
|
||||
expect(Rails.application.routes).to have_received(:recognize_path)
|
||||
expect(recognized).to have_received(:[])
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -27,13 +27,14 @@ describe WebfingerResource do
|
||||
recognized = Rails.application.routes.recognize_path(resource)
|
||||
allow(recognized).to receive(:[]).with(:controller).and_return('accounts')
|
||||
allow(recognized).to receive(:[]).with(:username).and_return('alice')
|
||||
expect(recognized).to receive(:[]).with(:action).and_return('create')
|
||||
allow(recognized).to receive(:[]).with(:action).and_return('create')
|
||||
|
||||
expect(Rails.application.routes).to receive(:recognize_path).with(resource).and_return(recognized).at_least(:once)
|
||||
|
||||
expect do
|
||||
described_class.new(resource).username
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(recognized).to have_received(:[]).exactly(3).times
|
||||
end
|
||||
|
||||
it 'raises with a string that doesnt start with URL' do
|
||||
|
@@ -4,11 +4,11 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountMigration do
|
||||
describe 'validations' do
|
||||
subject { described_class.new(account: source_account, acct: target_acct) }
|
||||
|
||||
let(:source_account) { Fabricate(:account) }
|
||||
let(:target_acct) { target_account.acct }
|
||||
|
||||
let(:subject) { described_class.new(account: source_account, acct: target_acct) }
|
||||
|
||||
context 'with valid properties' do
|
||||
let(:target_account) { Fabricate(:account, username: 'target', domain: 'remote.org') }
|
||||
|
||||
|
@@ -20,7 +20,9 @@ RSpec.describe Account do
|
||||
end
|
||||
|
||||
context 'when the account is of a local user' do
|
||||
let!(:subject) { Fabricate(:user, email: 'foo+bar@domain.org').account }
|
||||
subject { local_user_account }
|
||||
|
||||
let!(:local_user_account) { Fabricate(:user, email: 'foo+bar@domain.org').account }
|
||||
|
||||
it 'creates a canonical domain block' do
|
||||
subject.suspend!
|
||||
|
@@ -7,7 +7,7 @@ describe RelationshipFilter do
|
||||
|
||||
describe '#results' do
|
||||
context 'when default params are used' do
|
||||
let(:subject) do
|
||||
subject do
|
||||
described_class.new(account, 'order' => 'active').results
|
||||
end
|
||||
|
||||
|
@@ -93,7 +93,7 @@ RSpec.describe UserRole do
|
||||
|
||||
describe '#computed_permissions' do
|
||||
context 'when the role is nobody' do
|
||||
let(:subject) { described_class.nobody }
|
||||
subject { described_class.nobody }
|
||||
|
||||
it 'returns none' do
|
||||
expect(subject.computed_permissions).to eq UserRole::Flags::NONE
|
||||
@@ -101,7 +101,7 @@ RSpec.describe UserRole do
|
||||
end
|
||||
|
||||
context 'when the role is everyone' do
|
||||
let(:subject) { described_class.everyone }
|
||||
subject { described_class.everyone }
|
||||
|
||||
it 'returns permissions' do
|
||||
expect(subject.computed_permissions).to eq subject.permissions
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe AccountModerationNotePolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe AccountPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
let(:alice) { Fabricate(:account) }
|
||||
|
@@ -4,8 +4,9 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe BackupPolicy do
|
||||
let(:subject) { described_class }
|
||||
let(:john) { Fabricate(:account) }
|
||||
subject { described_class }
|
||||
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
permissions :create? do
|
||||
context 'when not user_signed_in?' do
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe CustomEmojiPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe DomainBlockPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe EmailDomainBlockPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe InstancePolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe InvitePolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:user).account }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe RelayPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe ReportNotePolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe ReportPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe SettingsPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe TagPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -4,7 +4,8 @@ require 'rails_helper'
|
||||
require 'pundit/rspec'
|
||||
|
||||
RSpec.describe UserPolicy do
|
||||
let(:subject) { described_class }
|
||||
subject { described_class }
|
||||
|
||||
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
|
||||
let(:john) { Fabricate(:account) }
|
||||
|
||||
|
@@ -113,11 +113,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
||||
end
|
||||
|
||||
context 'when discovering many subdomains in a short timeframe' do
|
||||
before do
|
||||
stub_const 'ActivityPub::ProcessAccountService::SUBDOMAINS_RATELIMIT', 5
|
||||
end
|
||||
|
||||
let(:subject) do
|
||||
subject do
|
||||
8.times do |i|
|
||||
domain = "test#{i}.testdomain.com"
|
||||
json = {
|
||||
@@ -129,6 +125,10 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
stub_const 'ActivityPub::ProcessAccountService::SUBDOMAINS_RATELIMIT', 5
|
||||
end
|
||||
|
||||
it 'creates at least some accounts' do
|
||||
expect { subject }.to change { Account.remote.count }.by_at_least(2)
|
||||
end
|
||||
|
@@ -70,7 +70,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
||||
let(:forwarder) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/other_account') }
|
||||
|
||||
it 'does not process payload if no signature exists' do
|
||||
expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil)
|
||||
allow_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil)
|
||||
expect(ActivityPub::Activity).to_not receive(:factory)
|
||||
|
||||
subject.call(json, forwarder)
|
||||
@@ -79,7 +79,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
||||
it 'processes payload with actor if valid signature exists' do
|
||||
payload['signature'] = { 'type' => 'RsaSignature2017' }
|
||||
|
||||
expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(actor)
|
||||
allow_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(actor)
|
||||
expect(ActivityPub::Activity).to receive(:factory).with(instance_of(Hash), actor, instance_of(Hash))
|
||||
|
||||
subject.call(json, forwarder)
|
||||
@@ -88,7 +88,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
||||
it 'does not process payload if invalid signature exists' do
|
||||
payload['signature'] = { 'type' => 'RsaSignature2017' }
|
||||
|
||||
expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil)
|
||||
allow_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil)
|
||||
expect(ActivityPub::Activity).to_not receive(:factory)
|
||||
|
||||
subject.call(json, forwarder)
|
||||
|
@@ -214,11 +214,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
||||
end
|
||||
|
||||
it 'does not create any edits' do
|
||||
expect { subject.call(status, json) }.to_not change { status.reload.edits.pluck(&:id) }
|
||||
expect { subject.call(status, json) }.to_not(change { status.reload.edits.pluck(&:id) })
|
||||
end
|
||||
|
||||
it 'does not update the text, spoiler_text or edited_at' do
|
||||
expect { subject.call(status, json) }.to_not change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] }
|
||||
expect { subject.call(status, json) }.to_not(change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] })
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -52,7 +52,7 @@ RSpec.describe PostStatusService, type: :service do
|
||||
end
|
||||
|
||||
it 'does not change statuses count' do
|
||||
expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not change { [account.statuses_count, previous_status.replies_count] }
|
||||
expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not(change { [account.statuses_count, previous_status.replies_count] })
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -14,7 +14,7 @@ RSpec.describe UnallowDomainService, type: :service do
|
||||
|
||||
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
|
||||
@@ -40,7 +40,7 @@ RSpec.describe UnallowDomainService, type: :service do
|
||||
|
||||
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
|
||||
|
@@ -3,6 +3,7 @@
|
||||
if ENV['DISABLE_SIMPLECOV'] != 'true'
|
||||
require 'simplecov'
|
||||
SimpleCov.start 'rails' do
|
||||
add_filter 'lib/linter'
|
||||
add_group 'Policies', 'app/policies'
|
||||
add_group 'Presenters', 'app/presenters'
|
||||
add_group 'Serializers', 'app/serializers'
|
||||
|
@@ -11,14 +11,15 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
|
||||
|
||||
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
|
||||
|
||||
@@ -26,7 +27,8 @@ RSpec.describe BlacklistedEmailValidator, type: :validator 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
|
||||
@@ -37,7 +39,8 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
|
||||
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
|
||||
|
Reference in New Issue
Block a user