-
Notifications
You must be signed in to change notification settings - Fork 28
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
India & Jing #11
base: master
Are you sure you want to change the base?
India & Jing #11
Conversation
Passenger merging with master
Passenger - Jing set up model relationships and seeded database
Passenger
Passenger
Passenger
if params[:passenger_id] | ||
@trip = Trip.request_trip(params[:passenger_id]) | ||
@trip.save | ||
@passenger = Passenger.find(@trip.passenger_id) | ||
@driver = Driver.find(@trip.driver_id) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to name a couple things here:
- Because this code is creating a new trip, it would be more appropriate for this code to live in
create
thannew
. The link in the passenger show page would need to be updated accordingly (and the nested route would need to be updated.) - This code is not tested because there's no unit test for the
new
action the passes thepassenger_id
param.
I'm happy to talk in more detail about either or both of these things if they're unclear!
validates :cost, numericality: { only_integer: true, greater_than: 0 } | ||
|
||
|
||
def self.request_trip(passenger_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love that you made a controller method for this!
Rideshare RailsMajor Learning Goals/Code Review
Functional Requirements
Overall FeedbackGreat work! Y'all made a whole interactive Rails application with so many ways for the user to interact! And it's fairly well tested! See my inline comment above for a little more depth on one specific area for improvement. But I hope y'all are proud! This is so amazing and it looks so good!
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
|
||
it "will delete a passenger" do | ||
expect{ | ||
delete passenger_path(Passenger.find_by(id: 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is failing because the id isn't necessarily 1
. In tests the id is randomly assigned. The code below solves the problem.
delete passenger_path(Passenger.find_by(id: 1)) | |
delete passenger_path(Passenger.first) |
it "will delete a passenger" do | ||
expect{ | ||
delete passenger_path(Passenger.find_by(id: 1)) | ||
}.must_change 'Passenger.count', 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be -1 because the count is expected to go down by one, rather than up.
}.must_change 'Passenger.count', 1 | |
}.must_change 'Passenger.count', -1 |
Assignment Submission: Rideshare Rails
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions. These questions should be answered by all team members together, not by a single teammate.
Reflection