Adds some unit tests

This commit is contained in:
Lou 2021-05-12 20:07:55 +02:00
commit 84d0b296fb

View file

@ -27,6 +27,12 @@ class Api::V1::RecordsControllerTest < ActionDispatch::IntegrationTest
headers: { Authorization: JsonWebToken.encode(user_id: @record.user_id) },
as: :json
assert_response :success
json_response = JSON.parse(self.response.body)
assert_equal @record.duration, json_response['data']['attributes']['duration']
assert_equal @record.user_id, json_response['data']['attributes']['user_id']
assert_equal @record.task_id, json_response['data']['attributes']['task_id']
assert_equal @record.is_handled, json_response['data']['attributes']['is_handled']
end
test "should not access show" do
@ -34,4 +40,5 @@ class Api::V1::RecordsControllerTest < ActionDispatch::IntegrationTest
as: :json
assert_response :forbidden
end
end