Commit e5b32f3c authored by Boyan Tabakov's avatar Boyan Tabakov

Fix user API tests succeeding for the wrong reason

The requests were missing multiple required attributes, while testing for single attribute missing.
Added test for checking username as required attribute.
parent 56404451
...@@ -110,17 +110,22 @@ describe API::API, api: true do ...@@ -110,17 +110,22 @@ describe API::API, api: true do
end end
it 'should return 400 error if name not given' do it 'should return 400 error if name not given' do
post api('/users', admin), email: 'test@example.com', password: 'pass1234' post api('/users', admin), attributes_for(:user).except(:name)
expect(response.status).to eq(400) expect(response.status).to eq(400)
end end
it 'should return 400 error if password not given' do it 'should return 400 error if password not given' do
post api('/users', admin), email: 'test@example.com', name: 'test' post api('/users', admin), attributes_for(:user).except(:password)
expect(response.status).to eq(400) expect(response.status).to eq(400)
end end
it "should return 400 error if email not given" do it 'should return 400 error if email not given' do
post api('/users', admin), password: 'pass1234', name: 'test' post api('/users', admin), attributes_for(:user).except(:email)
expect(response.status).to eq(400)
end
it 'should return 400 error if username not given' do
post api('/users', admin), attributes_for(:user).except(:username)
expect(response.status).to eq(400) expect(response.status).to eq(400)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment