|
@@ -0,0 +1,37 @@
|
|
1
|
+require "test_helper"
|
|
2
|
+
|
|
3
|
+class Api::V1::TasksControllerTest < ActionDispatch::IntegrationTest
|
|
4
|
+ setup do
|
|
5
|
+ @task = tasks(:one)
|
|
6
|
+ @activity = activities(:one)
|
|
7
|
+ @user = users(:one)
|
|
8
|
+ end
|
|
9
|
+
|
|
10
|
+ # INDEX
|
|
11
|
+ test "should access index" do
|
|
12
|
+ get api_v1_activity_tasks_url(@activity),
|
|
13
|
+ headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
|
|
14
|
+ as: :json
|
|
15
|
+ assert_response :success
|
|
16
|
+ end
|
|
17
|
+
|
|
18
|
+ test "should not access index" do
|
|
19
|
+ get api_v1_activity_tasks_url(@activity),
|
|
20
|
+ as: :json
|
|
21
|
+ assert_response :forbidden
|
|
22
|
+ end
|
|
23
|
+
|
|
24
|
+ # SHOW
|
|
25
|
+ test "should access show" do
|
|
26
|
+ get api_v1_activity_task_url(@activity, @task),
|
|
27
|
+ headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
|
|
28
|
+ as: :json
|
|
29
|
+ assert_response :success
|
|
30
|
+ end
|
|
31
|
+
|
|
32
|
+ test "should not access show" do
|
|
33
|
+ get api_v1_activity_task_url(@activity, @task),
|
|
34
|
+ as: :json
|
|
35
|
+ assert_response :forbidden
|
|
36
|
+ end
|
|
37
|
+end
|