|
@@ -3,6 +3,7 @@ require "test_helper"
|
3
|
3
|
class Api::V1::ActivitiesControllerTest < ActionDispatch::IntegrationTest
|
4
|
4
|
setup do
|
5
|
5
|
@activity = activities(:one)
|
|
6
|
+ @user = users(:one)
|
6
|
7
|
end
|
7
|
8
|
|
8
|
9
|
#INDEX
|
|
@@ -31,4 +32,24 @@ class Api::V1::ActivitiesControllerTest < ActionDispatch::IntegrationTest
|
31
|
32
|
as: :json
|
32
|
33
|
assert_response :forbidden
|
33
|
34
|
end
|
|
35
|
+
|
|
36
|
+ #CREATE
|
|
37
|
+ test "should create activity" do
|
|
38
|
+ assert_difference("Activity.count") do
|
|
39
|
+ post api_v1_activities_url,
|
|
40
|
+ params: { activity: { name: @activity.name, client: @activity.client, description: @activity.description, author_id: @user }},
|
|
41
|
+ headers: { Authorization: JsonWebToken.encode(user_id: @activity.author_id) },
|
|
42
|
+ as: :json
|
|
43
|
+ end
|
|
44
|
+ assert_response :created
|
|
45
|
+ end
|
|
46
|
+
|
|
47
|
+ test "should forbid create activity" do
|
|
48
|
+ assert_no_difference "Activity.count" do
|
|
49
|
+ post api_v1_activities_url,
|
|
50
|
+ params: { activity: { name: @activity.name, client: @activity.client, description: @activity.description, author_id: @user } },
|
|
51
|
+ as: :json
|
|
52
|
+ end
|
|
53
|
+ assert_response :forbidden
|
|
54
|
+ end
|
34
|
55
|
end
|