Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `README.md`: Upstream updated copyright year, we don't mention it so kept our version. - `app/controllers/admin/dashboard_controller.rb`: Not really a conflict, upstream change (removing the spam checker) too close to glitch-soc changes. Ported upstream changes. - `app/models/form/admin_settings.rb`: Same. - `app/services/remove_status_service.rb`: Same. - `app/views/admin/settings/edit.html.haml`: Same. - `config/settings.yml`: Same. - `config/environments/production.rb`: Not a real conflict, upstream added a default HTTP header, but we have extra headers in glitch-soc. Added the header.
This commit is contained in:
@@ -9,23 +9,36 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
|
||||
|
||||
before do
|
||||
allow(user).to receive(:valid_invitation?) { false }
|
||||
allow_any_instance_of(described_class).to receive(:blocked_email?) { blocked_email }
|
||||
described_class.new.validate(user)
|
||||
allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email }
|
||||
end
|
||||
|
||||
context 'blocked_email?' do
|
||||
subject { described_class.new.validate(user); errors }
|
||||
|
||||
context 'when e-mail provider is blocked' do
|
||||
let(:blocked_email) { true }
|
||||
|
||||
it 'calls errors.add' do
|
||||
expect(errors).to have_received(:add).with(:email, :blocked)
|
||||
it 'adds error' do
|
||||
expect(subject).to have_received(:add).with(:email, :blocked)
|
||||
end
|
||||
end
|
||||
|
||||
context '!blocked_email?' do
|
||||
context 'when e-mail provider is not blocked' do
|
||||
let(:blocked_email) { false }
|
||||
|
||||
it 'not calls errors.add' do
|
||||
expect(errors).not_to have_received(:add).with(:email, :blocked)
|
||||
it 'does not add errors' do
|
||||
expect(subject).not_to have_received(:add).with(:email, :blocked)
|
||||
end
|
||||
|
||||
context 'when canonical e-mail is blocked' do
|
||||
let(:other_user) { Fabricate(:user, email: 'i.n.f.o@mail.com') }
|
||||
|
||||
before do
|
||||
other_user.account.suspend!
|
||||
end
|
||||
|
||||
it 'adds error' do
|
||||
expect(subject).to have_received(:add).with(:email, :taken)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user