Fix test (remove it), and add other unit test on def show
This commit is contained in:
parent
bfda3e561b
commit
3e6506c7d7
1 changed files with 6 additions and 11 deletions
|
|
@ -27,6 +27,11 @@ class Api::V1::TasksControllerTest < ActionDispatch::IntegrationTest
|
|||
headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
|
||||
as: :json
|
||||
assert_response :success
|
||||
|
||||
json_response = JSON.parse(self.response.body)
|
||||
assert_equal @task.name, json_response['data']['attributes']['name']
|
||||
assert_equal @task.user_id, json_response['data']['attributes']['user_id']
|
||||
assert_equal @task.activity_id, json_response['data']['attributes']['activity_id']
|
||||
end
|
||||
|
||||
test "should not access show" do
|
||||
|
|
@ -46,7 +51,7 @@ class Api::V1::TasksControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_response :created
|
||||
end
|
||||
|
||||
test "should forbid create task - not logged in" do
|
||||
test "should forbid create task" do
|
||||
assert_no_difference("Task.count") do
|
||||
post api_v1_activity_tasks_url(@activity),
|
||||
params: { task: { name: @task.name, description: @task.description, user_id: @user, activity_id: @activity } },
|
||||
|
|
@ -54,14 +59,4 @@ class Api::V1::TasksControllerTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
test "should forbid create task - missing user or activity id" do
|
||||
assert_no_difference("Task.count") do
|
||||
post api_v1_activity_tasks_url(@activity),
|
||||
params: { task: { name: @task.name, description: @task.description } },
|
||||
headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
|
||||
as: :json
|
||||
end
|
||||
assert_response :forbidden
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue