Add spec for missing username value in create account API (#37057)
This commit is contained in:
parent
e6b0cdcc83
commit
dbf8d77cbb
@ -96,6 +96,28 @@ RSpec.describe '/api/v1/accounts' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when missing username value' do
|
||||||
|
subject do
|
||||||
|
post '/api/v1/accounts', headers: headers, params: { password: '12345678', email: 'hello@world.tld', agreement: 'true' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http unprocessable entity with username error message' do
|
||||||
|
expect { subject }
|
||||||
|
.to not_change(User, :count)
|
||||||
|
.and not_change(Account, :count)
|
||||||
|
|
||||||
|
expect(response)
|
||||||
|
.to have_http_status(422)
|
||||||
|
expect(response.media_type)
|
||||||
|
.to eq('application/json')
|
||||||
|
expect(response.parsed_body)
|
||||||
|
.to include(
|
||||||
|
error: /Validation failed/,
|
||||||
|
details: include(username: contain_exactly(include(error: 'ERR_BLANK', description: /can't be blank/)))
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when age verification is enabled' do
|
context 'when age verification is enabled' do
|
||||||
before do
|
before do
|
||||||
Setting.min_age = 16
|
Setting.min_age = 16
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user