-
Notifications
You must be signed in to change notification settings - Fork 34
Conversation
The goal will be to migrate view-only methods from Presenter::Auction into here, but just making all tests pass first with delegation.
Since ViewModel::Auction is used in views and has the current_user as an attribute, this replaces the need to pass a user into various Presenter::Auction methods
Presenter::Auction is just a basic wrapper around the AR model
@@ -1,12 +1,12 @@ | |||
<% if auction.over? %> | |||
<% if auction.bids? %> | |||
<% if current_user %> | |||
<% if auction.user_is_winning_bidder?(current_user) %> | |||
<% if auction.user_is_winning_bidder? %> |
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.
Definitely an improvement, not having to pass along the current user.
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.
Yeah, I really wanted to get rid of those parameters
looks good to me! |
@@ -27,7 +27,7 @@ | |||
</div> | |||
</div> | |||
<% end %> | |||
<% elsif auction.available? && auction.bids? && current_user && auction.user_is_bidder?(current_user) %> | |||
<% elsif auction.available? && auction.bids? && current_user && auction.user_is_bidder? %> |
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 would use this oppty to wrap this into one method on the view model. Also, probabyl the current_user check isn't necessary. Would hope it is inside the #user_is_bidder? method
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 think I want to look at cleaning up the logic in this partial in a future revision because this is kinda ugly, right?
Seems like an improvement to me. Got things in the view a little cleaner. I am just a little worried that when all the |
So, I do have a few questions I was wondering if you all could help me with:
|
@harrisj about your questions:
|
Thanks! With regards to point #2, ViewModel::Auction is not really tied to a specific view (like I should add tests for the BidsUser classes, but that might be a future PR. |
I decided to make a
ViewModel::Auction
class to extract some common functionality from theViewModel::AuctionIndex
andViewModel::AuctionShow
methods as well as wrapping user-specific methods fromPresenter::Auction