-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
global_business/business/controllers/api/v1/users_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Api::V1::UsersController, type: :controller do | ||
describe 'GET #show' do | ||
it 'returns the current user' do | ||
user = FactoryBot.create(:user) | ||
sign_in user | ||
get :show, format: :json | ||
expect(response).to be_success | ||
expect(JSON.parse(response.body)).to eq(user.as_json) | ||
end | ||
end | ||
|
||
describe 'PUT #update' do | ||
it 'updates the current user' do | ||
user = FactoryBot.create(:user) | ||
sign_in user | ||
put :update, params: { user: { email: '[email protected]' } }, format: :json | ||
expect(response).to be_success | ||
expect(user.reload.email).to eq('[email protected]') | ||
end | ||
end | ||
|
||
describe 'DELETE #destroy' do | ||
it 'destroys the current user' do | ||
user = FactoryBot.create(:user) | ||
sign_in user | ||
delete :destroy, format: :json | ||
expect(response).to be_success | ||
expect(User.find_by(id: user.id)).to be_nil | ||
end | ||
end | ||
end |