Skip to content

Commit

Permalink
Merge pull request jeremytregunna#38 from benzimmer/only-put-changed-…
Browse files Browse the repository at this point in the history
…attributes

Only 'put' changed attributes
  • Loading branch information
jeremytregunna committed Jan 10, 2013
2 parents fbaf8ec + 1d245db commit 5c8bf2c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
13 changes: 3 additions & 10 deletions lib/trello/card.rb
Expand Up @@ -87,18 +87,11 @@ def save
# this object before making your changes, and before updating the record.
def update!
@previously_changed = changes
# extract only new values to build payload
payload = Hash[changes.map { |key, values| [key.to_sym, values[1]] }]
@changed_attributes.clear

Client.put("/cards/#{id}", {
:name => name,
:desc => description,
:due => due && due.utc.iso8601,
:closed => closed,
:idList => list_id,
:idBoard => board_id,
:idMembers => member_ids,
:pos => pos
})
Client.put("/cards/#{id}", payload)
end

# Check if the card is not active anymore.
Expand Down
14 changes: 0 additions & 14 deletions spec/card_spec.rb
Expand Up @@ -51,13 +51,6 @@ module Trello

payload = {
:name => expected_new_name,
:desc => "Awesome things are awesome.",
:due => nil,
:closed => false,
:idList => "abcdef123456789123456789",
:idBoard => "abcdef123456789123456789",
:idMembers => ["abcdef123456789123456789"],
:pos => 12
}

Client.should_receive(:put).once.with("/cards/abcdef123456789123456789", payload)
Expand Down Expand Up @@ -286,14 +279,7 @@ module Trello
describe "#close!" do
it "updates the close attribute to true and saves the list" do
payload = {
:name => @card.name,
:desc => "Awesome things are awesome.",
:due => nil,
:closed => true,
:idList => "abcdef123456789123456789",
:idBoard => "abcdef123456789123456789",
:idMembers => ["abcdef123456789123456789"],
:pos => 12
}

Client.should_receive(:put).once.with("/cards/abcdef123456789123456789", payload)
Expand Down

0 comments on commit 5c8bf2c

Please sign in to comment.