Add details
to error response for POST /api/v1/accounts
in REST API (#15803)
This commit is contained in:
parent
b4cb8c3c83
commit
9aa37b32c3
12 changed files with 72 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue