lib/roart/ticket.rb in roart-0.1.6 vs lib/roart/ticket.rb in roart-0.1.7

- old
+ new

@@ -63,20 +63,16 @@ uri = "#{self.class.connection.server}/REST/1.0/ticket/#{self.id}/edit" payload = @attributes.clone payload.delete("text") payload.delete("id") # Can't have text in an update, only create, use comment for updateing payload = payload.to_content_format - puts payload resp = self.class.connection.post(uri, :content => payload) - puts resp resp = resp.split("\n") - raise "Ticket Update Failed" unless resp.first.include?("200") + raise TicketSystemError, "Ticket Update Failed" unless resp.first.include?("200") resp.each do |line| - puts "line" if line.match(/^# Ticket (\d+) updated./) self.after_update - puts "FOUND" return true else #TODO: Add warnign to ticket end end @@ -93,18 +89,18 @@ uri = "#{self.class.connection.server}/REST/1.0/ticket/#{self.id}/comment" payload = comment.to_content_format resp = self.class.connection.post(uri, :content => payload) resp = resp.split("\n") - raise "Ticket Comment Failed" unless resp.first.include?("200") + raise TicketSystemError, "Ticket Comment Failed" unless resp.first.include?("200") !!resp[2].match(/^# Message recorded/) end # works just like save, but if the save fails, it raises an exception instead of silently returning false # def save! - raise "Ticket Create Failed" unless self.save + raise TicketSystemError, "Ticket Create Failed" unless self.save true end def new_record? return @new_record @@ -116,11 +112,11 @@ self.before_create uri = "#{self.class.connection.server}/REST/1.0/ticket/new" payload = @attributes.to_content_format resp = self.class.connection.post(uri, :content => payload) resp = resp.split("\n") - raise "Ticket Create Failed" unless resp.first.include?("200") + raise TicketSystemError, "Ticket Create Failed" unless resp.first.include?("200") resp.each do |line| if tid = line.match(/^# Ticket (\d+) created./) @attributes[:id] = tid[1].to_i self.after_create @new_record = false @@ -131,11 +127,11 @@ end return false end def create! #:nodoc: - raise "Ticket Create Failed" unless self.create + raise TicketSystemError, "Ticket Create Failed" unless self.create true end class << self #class methods @@ -271,11 +267,11 @@ uri = construct_search_uri(options) tickets = get_tickets_from_search_uri(uri) end def find_by_ids(args, options) #:nodoc: - raise "First argument must be :all or :first, or an ID with no hash options" unless args.first.is_a?(Fixnum) || args.first.is_a?(String) + raise ArgumentError, "First argument must be :all or :first, or an ID with no hash options" unless args.first.is_a?(Fixnum) || args.first.is_a?(String) get_ticket_by_id(args.first) end def page_array(uri) #:nodoc: page = self.connection.get(uri) @@ -290,10 +286,10 @@ end end def page_list_array(uri) #:nodoc: page = self.connection.get(uri) - raise TicketSystemError, "Can't get ticket." unless page + raise TicketSystemInterfaceError, "Can't get ticket." unless page page = page.split("\n") status = page.delete_at(0) if status.include?("200") page = page.join("\n") chunks = page.split(/^--$/)