-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from toptier/refactor/single-resource
Use user single resources instead of /users/me
- Loading branch information
Showing
15 changed files
with
142 additions
and
58 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
json.user do | ||
json.partial! 'info', user: current_user | ||
json.partial! 'info', user: user | ||
end |
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
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
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
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
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
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,17 @@ | ||
require 'rails_helper' | ||
|
||
describe 'GET api/v1/user/profile', type: :request do | ||
let(:user) { create(:user) } | ||
|
||
it 'returns success' do | ||
get profile_api_v1_user_path, headers: auth_headers, as: :json | ||
expect(response).to have_http_status(:success) | ||
end | ||
|
||
it 'returns user\'s data' do | ||
get profile_api_v1_user_path, headers: auth_headers, as: :json | ||
|
||
expect(json[:user][:id]).to eq user.id | ||
expect(json[:user][:first_name]).to eq user.first_name | ||
end | ||
end |
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 |
---|---|---|
@@ -1,17 +1,18 @@ | ||
require 'rails_helper' | ||
|
||
describe 'GET api/v1/users/me', type: :request do | ||
describe 'GET api/v1/users/:id', type: :request do | ||
let(:user) { create(:user) } | ||
let(:another_user) { create :user } | ||
|
||
it 'returns success' do | ||
get api_v1_user_path(id: 'me'), headers: auth_headers, as: :json | ||
get api_v1_user_path(id: another_user.id), headers: auth_headers, as: :json | ||
expect(response).to have_http_status(:success) | ||
end | ||
|
||
it 'returns user\'s data' do | ||
get api_v1_user_path(id: 'me'), headers: auth_headers, as: :json | ||
get api_v1_user_path(id: another_user.id), headers: auth_headers, as: :json | ||
|
||
expect(json[:user][:id]).to eq user.id | ||
expect(json[:user][:first_name]).to eq user.first_name | ||
expect(json[:user][:id]).to eq another_user.id | ||
expect(json[:user][:first_name]).to eq another_user.first_name | ||
end | ||
end |
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
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
Oops, something went wrong.