|
@@ -52,4 +52,28 @@ class Api::V1::ActivitiesControllerTest < ActionDispatch::IntegrationTest
|
52
|
52
|
end
|
53
|
53
|
assert_response :forbidden
|
54
|
54
|
end
|
55
|
|
-end
|
|
55
|
+
|
|
56
|
+ #UPDATE
|
|
57
|
+ test "should update activity" do
|
|
58
|
+ patch api_v1_activity_url(@activity),
|
|
59
|
+ params: { activity: { name: "Updated name" } },
|
|
60
|
+ headers: { Authorization: JsonWebToken.encode(user_id: @activity.author_id) },
|
|
61
|
+ as: :json
|
|
62
|
+ assert_response :success
|
|
63
|
+ end
|
|
64
|
+
|
|
65
|
+ test "should forbid update activity - not connected" do
|
|
66
|
+ patch api_v1_activity_url(@activity),
|
|
67
|
+ params: { activity: { name: "Updated name" } },
|
|
68
|
+ as: :json
|
|
69
|
+ assert_response :forbidden
|
|
70
|
+ end
|
|
71
|
+
|
|
72
|
+ test "should forbid update activity - not owner" do
|
|
73
|
+ patch api_v1_activity_url(@activity),
|
|
74
|
+ params: { activity: { name: "Updated name" } },
|
|
75
|
+ headers: { Authorization: JsonWebToken.encode(user_id: users(:two).id) },
|
|
76
|
+ as: :json
|
|
77
|
+ assert_response :forbidden
|
|
78
|
+ end
|
|
79
|
+end
|