DEV: Return the right response code and error message.

Follow up to d1dbafebbc4b21c2a6714cd19c0ba05fac7717c4.

Also remove test that is a duplicate of
867c1a5ac9355aadef35d60fd9c7aa4ebd0eda25.
This commit is contained in:
Guo Xiang Tan
2019-05-10 07:33:02 +08:00
parent 4a1755b780
commit ce15f085c6
2 changed files with 7 additions and 14 deletions

View File

@ -787,21 +787,12 @@ describe PostsController do
raw: 'this is test body',
category: 'invalid'
}
expect(response.status).to eq(404)
end
it 'can create topics with an empty category param' do
user = Fabricate(:admin)
master_key = ApiKey.create_master_key.key
expect(response.status).to eq(400)
post "/posts.json", params: {
api_username: user.username,
api_key: master_key,
title: 'title for a topic without a category',
raw: 'body for my topic without a category',
category: ''
}
expect(response.status).to eq(200)
expect(JSON.parse(response.body)["errors"]).to include(
I18n.t("invalid_params", message: "category")
)
end
end