-
Notifications
You must be signed in to change notification settings - Fork 45
Ampers: Angela Poland #21
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
base: master
Are you sure you want to change the base?
Conversation
…hen I put puts statments in the if/else loop its in...both are printing out and I don't know why. (even though the test technically passes in specs test
…ere/ran out of time to figure it out.
…ethod test. did not finish.
…able to get csv file to get imported.
…t updated the first wave 1 test for it though.
…supposed to work.
… did in order specs that are easier to adjust for online-orders.
Grocery StoreWhat We're Looking For
|
|
|
||
| class OnlineOrder < Order | ||
|
|
||
| attr_reader :id, :products, :customer_id, :fulfillment_status |
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.
You can inherit the helper methods for id and products and just have:
attr_reader :customer_id, :fulfillment_status| attr_reader :id, :products, :customer_id, :fulfillment_status | ||
|
|
||
| def initialize(id, products, customer_id, fulfillment_status) | ||
| @id = 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.
You should have:
super(id, products)here to initialize @id and @products
| # tip from Katie: 16 and 22 are the customer id's that exsit but do not have orders | ||
| end | ||
|
|
||
| def self.all |
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.
Nicely done!
| def self.find_by_customer(customer_id) | ||
|
|
||
| OnlineOrder.all.each do |single_order| | ||
| order_list = [] |
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.
You should probably have order_list = [] outside the loop.
| end | ||
| end | ||
|
|
||
| def total |
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.
Great!
| # TODO: Your test code here! | ||
| end | ||
| xdescribe "OnlineOrder.find_by_customer" do | ||
| xit "Returns an array of online orders for a specific customer ID" do |
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 return an array, so:
Grocery::OnlineOrder.find(1).must_be_instance_of Array
Grocery::OnlineOrder.find(1).each do |element|
element.must_be_instance_of Grocery::OnlineOrder
end| # Act | ||
| order.add_product("salad", 4.25) | ||
|
|
||
| # Assert |
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.
Smart to put these comments in to see the steps.
| all_orders.class.must_equal Array | ||
|
|
||
| all_orders.each do |order| | ||
| order.must_be_instance_of Grocery::Order |
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.
Good!
| describe "Order.find" do | ||
|
|
||
| before do | ||
| @order_class = Grocery::Order |
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.
Not sure what the point of this is, just to save typing?
| it "Can find the first order from the CSV" do | ||
| # TODO: Your test code here! | ||
|
|
||
| @order_class.find(1).must_be_instance_of Grocery::Order |
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.
You should also check to ensure the values of the found Order have the right values, check the id, products etc.
Grocery Store
Congratulations! You're submitting your assignment.
Comprehension Questions
raise ArgumentError?.all&.findmethods class methods? Why not instance methods?