|
@@ -0,0 +1,59 @@
|
|
1
|
+require "test_helper"
|
|
2
|
+
|
|
3
|
+class Api::V1::JoinedTeamUsersControllerTest < ActionDispatch::IntegrationTest
|
|
4
|
+ setup do
|
|
5
|
+ @joinedTeamUser = joined_team_users(:one)
|
|
6
|
+ @user = users(:one)
|
|
7
|
+ @team = teams(:one)
|
|
8
|
+ end
|
|
9
|
+
|
|
10
|
+ # INDEX
|
|
11
|
+ test "should access JoinedTeamUser index" do
|
|
12
|
+ get api_v1_joined_team_users_url,
|
|
13
|
+ headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
|
|
14
|
+ as: :json
|
|
15
|
+ assert_response :success
|
|
16
|
+ end
|
|
17
|
+
|
|
18
|
+ test "should forbid JoinedTeamUser index" do
|
|
19
|
+ get api_v1_joined_team_users_url,
|
|
20
|
+ as: :json
|
|
21
|
+ assert_response :forbidden
|
|
22
|
+ end
|
|
23
|
+
|
|
24
|
+ # SHOW
|
|
25
|
+ test "should show JoinedTeamUser" do
|
|
26
|
+ get api_v1_joined_team_users_url(@joinedTeamUser),
|
|
27
|
+ headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
|
|
28
|
+ as: :json
|
|
29
|
+ assert_response :success
|
|
30
|
+ end
|
|
31
|
+
|
|
32
|
+ test "should forbid show JoinedTeamUser" do
|
|
33
|
+ get api_v1_joined_team_users_url(@joinedTeamUser),
|
|
34
|
+ as: :json
|
|
35
|
+ assert_response :forbidden
|
|
36
|
+ end
|
|
37
|
+
|
|
38
|
+ # CREATE
|
|
39
|
+ test "should create joinedTeamUser" do
|
|
40
|
+ assert_difference("JoinedTeamUser.count") do
|
|
41
|
+ post api_v1_joined_team_users_url,
|
|
42
|
+ params: { joinedTeamUser: { team_id: @team.id, user_id: @user.id, can_edit: false } },
|
|
43
|
+ headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
|
|
44
|
+ as: :json
|
|
45
|
+ end
|
|
46
|
+ assert_response :created
|
|
47
|
+ end
|
|
48
|
+
|
|
49
|
+ test "should forbid create joinedTeamUser" do
|
|
50
|
+ assert_no_difference("JoinedTeamUser.count") do
|
|
51
|
+ post api_v1_joined_team_users_url,
|
|
52
|
+ params: { joinedTeamUser: { team_id: @team.id, user_id: @user.id, can_edit: false } },
|
|
53
|
+ as: :json
|
|
54
|
+ end
|
|
55
|
+ assert_response :forbidden
|
|
56
|
+ end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+end
|