Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Request for User Resource only #75

Merged
merged 9 commits into from
Oct 1, 2019
Merged

Pull Request for User Resource only #75

merged 9 commits into from
Oct 1, 2019

Conversation

sibsmc
Copy link
Collaborator

@sibsmc sibsmc commented Jun 18, 2019

Add User resource and browser version Create, Edit, Read and Delete function.
Also contains user database migration and database seed.

Also contains user database migration and database seed.
…with command 'rspec spec/requests/api/v1/users_spec.rb' in the server directory.
@sibsmc sibsmc requested a review from a team June 21, 2019 15:31
@sibsmc sibsmc added the backend Issue for backend team label Jun 21, 2019
Copy link
Contributor

@diwanow diwanow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can revisit the api controller logic in light of the agreement that the rails app should publish a REST API for consumption by the front-end team. I am by far not an expert in Ruby and Rails, but to me this article looks good (I might be wrong) regarding details how to make an API controller in Rails. It might be worth a read ;)

As for designing REST APIs, this article might be of interest as a starting point. A point that often is missed is that responses different than 2xx are quite important and need to be considered for every endpoint.

server/app/controllers/api/v1/users_controller.rb Outdated Show resolved Hide resolved
server/app/controllers/users_controller.rb Outdated Show resolved Hide resolved
server/app/models/user.rb Outdated Show resolved Hide resolved
server/app/controllers/api/v1/users_controller.rb Outdated Show resolved Hide resolved
server/spec/requests/api/v1/users_spec.rb Outdated Show resolved Hide resolved
server/spec/requests/api/v1/users_spec.rb Outdated Show resolved Hide resolved
server/spec/requests/api/v1/users_spec.rb Outdated Show resolved Hide resolved
server/spec/requests/api/v1/users_spec.rb Outdated Show resolved Hide resolved
server/spec/requests/api/v1/users_spec.rb Outdated Show resolved Hide resolved
server/spec/requests/api/v1/users_spec.rb Outdated Show resolved Hide resolved
@sibsmc sibsmc closed this Jun 30, 2019
@sibsmc
Copy link
Collaborator Author

sibsmc commented Jun 30, 2019

Will resubmit with a different pull request

CRUD APIs have been created
A series of tests in Spec have been created for the CRUD APIs
@diwanow
Copy link
Contributor

diwanow commented Jun 30, 2019

@sibsmc I think it would be great to continue on this pull request, if you haven't started re-implementing this completely from scratch.

A pull request in my opinion is a place for discussion, to share opinions, suggestions for improvement and to reach to a stage where both reviewer and author have maybe learnt something and have agreed that the state is good, whatever that means. In that sense, keeping the history of this discussion and progression is something valuable - the journey is as important as the destination.

Having this point of view in mind, consider whether to open a new PR or re-open this one.

@sibsmc
Copy link
Collaborator Author

sibsmc commented Jul 1, 2019

Hi
I agree it is good to keep same pull request, I just reopened a new branch on my local machine so thought I couldn't submit to this branch, I'll reopen and try to push to this branch.

@sibsmc sibsmc reopened this Jul 1, 2019
This was referenced Jul 1, 2019
@sibsmc
Copy link
Collaborator Author

sibsmc commented Jul 1, 2019

Creates a user database called 'ApiUser'
CRUD APIs have been created
A series of tests in Spec have been created for the CRUD APIs

I started to look into authentication, hence these three files:
server/spec/auth/authorize_api_request_spec.rb
server/app/lib/json_web_token.rb
server/app/auth/authenticate_user.rb
however these don't serve any purpose at the moment, no authentication required.

Test can be run by running command 'bundle exec rspec spec'

server/db/seeds.rb Outdated Show resolved Hide resolved
@diwanow
Copy link
Contributor

diwanow commented Jul 5, 2019

I started to look into authentication, hence these three files:
server/spec/auth/authorize_api_request_spec.rb
server/app/lib/json_web_token.rb
server/app/auth/authenticate_user.rb
however these don't serve any purpose at the moment, no authentication required.

In general, I usually say that if something doesn't serve a purpose, it shouldn't be in the code base in the first place. This applies also to the worse case when something doesn't work and the worst case when something works wrong/partially. The reason for this is that anything that is in the codebase calls for maintenance and when working in a team anyone can decide it is what they need (unfortunately not everyone reads docs, even if they exist) and this can either cause them headaches or even completely throw them off and slow down overall progress. On higher product level it is like releasing a partially done feature with the docs in code playing the role of explicit marking that the feature is experimental. When this is done, any user can start using it and depending on it so it becomes something that there might be market pressure to keep there, maybe even working in the broken way it was working in the first place.

What I stated above pictures some of the grimmest scenarios that something like that can lead to. The risk with your change is low, I just wanted to illustrate the idea.

Enough with general talk, on the practical side, I would recommend to remove the files that are not used in this review. You can stash them or add them to another branch locally (or remotely) so that you don't lose them - you've done some work after all in a direction that is needed.

FYI, there are several authentication-related stories: #8 #13 #32 #33 #34 (I grouped them under a label). So you can consider continue working on auth as part of one of them (what you have here is probably more in scope of #8 #13 as the rest are integrations of libraries/products)

server/app/assets/javascripts/api_users.coffee Outdated Show resolved Hide resolved
server/app/helpers/api_users_helper.rb Show resolved Hide resolved
server/app/lib/message.rb Show resolved Hide resolved
server/app/lib/message.rb Show resolved Hide resolved
server/spec/auth/authorize_api_request_spec.rb Outdated Show resolved Hide resolved
server/app/models/user.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@diwanow diwanow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, the changes I proposed are rather cleanup

@LoneKP LoneKP requested a review from diwanow October 1, 2019 16:21
Copy link
Contributor

@diwanow diwanow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unblocking the PR. Further active comments are still in the Conversation tab.

@LoneKP LoneKP merged commit e4ed1fc into master Oct 1, 2019
@LoneKP LoneKP deleted the user_resource branch October 1, 2019 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Issue for backend team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants