-
Notifications
You must be signed in to change notification settings - Fork 238
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
Allow authenticated user to vote/remove vote on card, add idMembersVoted to card #208
Conversation
private def get_authenticated_user_id | ||
mem = Member.from_response client.get('/members/me') | ||
mem && mem.id | ||
end |
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.
IMHO, this is the wrong place to put this. Would adding a Member.me
class method be a good idea? The concept of "me" exists in the API and is documented here: https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username
# | ||
# @return [Array<Trello::Member>] | ||
def voters | ||
Member.from_response client.get("/cards/#{id}/membersVoted") |
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.
can we also please have a spec for this method?
@joneslee85 this is ready for your review. One defect I've noticed, and tried to solve, is that when the state of the object changes (like when an upvote occurs) the whole object is not refreshed. EX: @card # => badges: {votes: 0}
@card.upvote # => badges: {votes: 1}
@card # => badges: {votes: 0}, should be votes: 1 I attempted to solve this in a number of ways but realized that this behavior is consistent with other attributes (like labels). I'd expect consumers of this gem have established patterns of handling this. It felt like a defect to me though. CI is failing at the moment because I'm using the |
card.remove_upvote | ||
end | ||
|
||
it 'returns members that have voted for the card' 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.
spec for Card#voters
is here. Want it in its own context?
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.
Yes, please
@brycemcd regarding the defect, It'd be ideal that we return a refreshed / updated clone of the card object. However this seems to be too out of scope. For the time being, can you please write a spec noting this defect? We could discuss in further how to rectify that issue. |
@brycemcd let me know when it is good for another review round |
@joneslee85 It should be ready to go now (was waiting for CI to confirm tests pass). I'll get a new issue/PR opened for the defect I found in doing this work in the next day or so. |
What
See #202 for more details. This PR adds support for adding/removing votes to a card. It also adds idMembersVoted to card attributes (though this last part is WIP)
How to test
Authenticate and execute the following code:
Note
I'll be able to add
idMembersVoted
to the PR tomorrow (2016-08-04)