Bladeren bron

added tests and method update and destroy

Lou 2 jaren geleden
bovenliggende
commit
90d329eff8
1 gewijzigde bestanden met toevoegingen van 36 en 36 verwijderingen
  1. 36
    36
      test/controllers/api/v1/memberships_controller_test.rb

+ 36
- 36
test/controllers/api/v1/memberships_controller_test.rb Bestand weergeven

@@ -67,44 +67,44 @@ class Api::V1::MembershipsControllerTest < ActionDispatch::IntegrationTest
67 67
     assert_response :forbidden
68 68
   end
69 69
 
70
-  # # UPDATE
71
-  # test "should update membership" do
72
-  #   patch api_v1_membership_url(@membership),
73
-  #   headers: { Authorization: JsonWebToken.encode(user_id: @user.id) }, 
74
-  #   params: { membership: { can_edit: true } },
75
-  #   as: :json
76
-  #   assert_response :success
77
-  # end
70
+  # UPDATE
71
+  test "should update membership" do
72
+    patch api_v1_team_membership_url(@team, @membership),
73
+    headers: { Authorization: JsonWebToken.encode(user_id: @user.id) }, 
74
+    params: { membership: { can_edit: true } },
75
+    as: :json
76
+    assert_response :success
77
+  end
78 78
 
79
-  # test "should forbid update membership" do
80
-  #   patch api_v1_membership_url(@membership),
81
-  #   params: { membership: { can_edit: true } },
82
-  #   as: :json
83
-  #   assert_response :forbidden
84
-  # end
79
+  test "should forbid update membership" do
80
+    patch api_v1_team_membership_url(@team, @membership),
81
+    params: { membership: { can_edit: true } },
82
+    as: :json
83
+    assert_response :forbidden
84
+  end
85 85
 
86
-  # test "should forbid update read_only attributes - team_id" do
87
-  #   patch api_v1_membership_url(@membership),
88
-  #   headers: { Authorization: JsonWebToken.encode(user_id: @user.id) }, 
89
-  #   params: { membership: { team_id: @team2.id, member_id: @user2.id } },
90
-  #   as: :json
91
-  #   assert_response :unprocessable_entity
92
-  # end
86
+  test "should forbid update read_only attributes - team_id" do
87
+    patch api_v1_team_membership_url(@team, @membership),
88
+    headers: { Authorization: JsonWebToken.encode(user_id: @user.id) }, 
89
+    params: { membership: { team_id: @team2.id, member_id: @user2.id } },
90
+    as: :json
91
+    assert_response :unprocessable_entity
92
+  end
93 93
 
94
-  # # DESTROY
95
-  # test "should destroy membership" do
96
-  #   assert_difference('Membership.count', -1) do
97
-  #     delete api_v1_membership_url(@membership), 
98
-  #     headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
99
-  #     as: :json
100
-  #   end
101
-  #   assert_response :no_content
102
-  # end
94
+  # DESTROY
95
+  test "should destroy membership" do
96
+    assert_difference('Membership.count', -1) do
97
+      delete api_v1_team_membership_url(@team, @membership), 
98
+      headers: { Authorization: JsonWebToken.encode(user_id: @user.id) },
99
+      as: :json
100
+    end
101
+    assert_response :no_content
102
+  end
103 103
 
104
-  # test "should forbid destroy membership" do
105
-  #   assert_no_difference('Membership.count') do
106
-  #     delete api_v1_membership_url(@membership), as: :json
107
-  #   end
108
-  #   assert_response :forbidden
109
-  # end
104
+  test "should forbid destroy membership" do
105
+    assert_no_difference('Membership.count') do
106
+      delete api_v1_team_membership_url(@team, @membership), as: :json
107
+    end
108
+    assert_response :forbidden
109
+  end
110 110
 end

Loading…
Annuleren
Opslaan