Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
don't allow updating a closed case, fixed #10
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Stachl committed Sep 6, 2013
1 parent 805ad26 commit 03e5c7d
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/desk_api/action/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ module DeskApi
module Action
module Update
def update(params = {})
if kind_of?(resource('case')) and status == 'closed'
raise DeskApi::Error::NotUpdateable
end

params.each_pair do |key, value|
send("#{key}=", value) if respond_to?("#{key}=")
end

setup(client.patch(@_links.self.href, @_changed).body)
end
end
Expand Down
10 changes: 10 additions & 0 deletions lib/desk_api/error/not_updateable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'desk_api/error'

module DeskApi
class Error
# Raised when an updateable resources becomes non-updateable
# and you try to update it
class NotUpdateable < DeskApi::Error
end
end
end
Loading

0 comments on commit 03e5c7d

Please sign in to comment.