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