Skip to content
Snippets Groups Projects
Commit 702ff358 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

adding more tests for user controller

parent 7e9ca8f8
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,12 @@ module FollowableController
# DELETE /v1/users/1/unfollow
# DELETE /v1/users/1/unfollow.json
def unfollow
current_user.unfollow(@followable) if current_user.following? @followable
if current_user.following?(@followable)
current_user.unfollow(@followable)
render nothing: true, status: :ok
else
render nothing: true, status: :forbidden
end
end
end
\ No newline at end of file
......@@ -36,7 +36,6 @@ class V1::UsersControllerTest < ActionController::TestCase
test 'should put invalid user to update and return :unprocessable_entity code' do
user = users(:john)
put :update, user: {name: 'mauricio', email: '', password: 'test123455', password_confirmation: 'test123455',
terms_of_service: false}, id: user.id
assert_response :unprocessable_entity
......@@ -49,10 +48,28 @@ class V1::UsersControllerTest < ActionController::TestCase
end
test 'should user follow an user jack' do
user = users(:john)
auth_request user
auth_request users(:john)
post :follow, id: users(:jack).id
assert_response :created
end
test 'should user follow an already followed user and return :forbidden code' do
auth_request users(:john)
post :follow, id: users(:jack).id
assert_response :created
post :follow, id: users(:jack).id
assert_response :forbidden
end
test 'should user unfollow an user jack' do
auth_request users(:john)
post :follow, id: users(:jack).id
assert_response :created
delete :unfollow, id: users(:jack).id
assert_response :ok
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment