Add destroy def and unit test

This commit is contained in:
Lou 2021-05-10 22:06:12 +02:00
commit fc38057172
3 changed files with 25 additions and 1 deletions

View file

@ -75,4 +75,22 @@ class Api::V1::TasksControllerTest < ActionDispatch::IntegrationTest
as: :json
assert_response :forbidden
end
# DESTROY
test "should destroy task" do
assert_difference "Task.count", -1 do
delete api_v1_activity_task_url(@activity, @task),
headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
as: :json
end
assert_response :no_content
end
test "should not destroy task" do
assert_no_difference('Task.count') do
delete api_v1_activity_task_url(@activity, @task),
as: :json
end
assert_response :forbidden
end
end