0
0
Fork 0

Add details to error response for POST /api/v1/accounts in REST API (#15803)

This commit is contained in:
Eugen Rochko 2021-03-01 04:59:13 +01:00 committed by GitHub
parent b4cb8c3c83
commit 9aa37b32c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 72 additions and 23 deletions

View file

@ -17,7 +17,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
let(:blocked_email) { true }
it 'calls errors.add' do
expect(errors).to have_received(:add).with(:email, I18n.t('users.blocked_email_provider'))
expect(errors).to have_received(:add).with(:email, :blocked)
end
end
@ -25,7 +25,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
let(:blocked_email) { false }
it 'not calls errors.add' do
expect(errors).not_to have_received(:add).with(:email, I18n.t('users.blocked_email_provider'))
expect(errors).not_to have_received(:add).with(:email, :blocked)
end
end
end

View file

@ -13,7 +13,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do
let(:account) { double(username: username, errors: errors) }
let(:errors ) { double(add: nil) }
context '@username.nil?' do
context '@username.blank?' do
let(:username) { nil }
it 'not calls errors.add' do
@ -21,14 +21,14 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do
end
end
context '!@username.nil?' do
let(:username) { '' }
context '!@username.blank?' do
let(:username) { 'f' }
context 'reserved_username?' do
let(:reserved_username) { true }
it 'calls erros.add' do
expect(errors).to have_received(:add).with(:username, I18n.t('accounts.reserved_username'))
expect(errors).to have_received(:add).with(:username, :reserved)
end
end