|
@@ -34,5 +34,31 @@ class Api::V1::UsersControllerTest < ActionDispatch::IntegrationTest
|
34
|
34
|
post api_v1_users_url, params: { user: { email: "test@email.com", username: @user.username, password: '123456' } }, as: :json
|
35
|
35
|
end
|
36
|
36
|
assert_response :unprocessable_entity
|
37
|
|
- end
|
|
37
|
+ end
|
|
38
|
+
|
|
39
|
+ #UPDATE
|
|
40
|
+ test "should update user" do
|
|
41
|
+ patch api_v1_user_url(@user), params: { user: { email: @user.email, username: @user.username, password: '123456' } }, as: :json
|
|
42
|
+ assert_response :success
|
|
43
|
+ end
|
|
44
|
+
|
|
45
|
+ # test "should not update user when invalid params are sent" do
|
|
46
|
+ # patch api_v1_user_url(@user), params: { user: { email: 'bad_email', username: @user.username, password: '123456' } }, as: :json
|
|
47
|
+ # assert_response :unprocessable_entity
|
|
48
|
+ # end
|
|
49
|
+
|
|
50
|
+ #DESTROY
|
|
51
|
+ test "should destroy user" do
|
|
52
|
+ assert_difference('User.count', -1) do
|
|
53
|
+ delete api_v1_user_url(@user), as: :json
|
|
54
|
+ end
|
|
55
|
+ assert_response :no_content
|
|
56
|
+ end
|
|
57
|
+
|
|
58
|
+ # test "should forbid destroy user" do
|
|
59
|
+ # assert_no_difference('User.count') do
|
|
60
|
+ # delete api_v1_user_url(@user), as: :json
|
|
61
|
+ # end
|
|
62
|
+ # assert_response :forbidden
|
|
63
|
+ # end
|
38
|
64
|
end
|