diff --git a/app/models/concerns/justifiable.rb b/app/models/concerns/justifiable.rb index a6f4e8df49f..bd4af895427 100644 --- a/app/models/concerns/justifiable.rb +++ b/app/models/concerns/justifiable.rb @@ -18,7 +18,9 @@ module Justifiable private def strip_octothorpe - self.ticket_number = self.ticket_number.delete_prefix("#") unless self.ticket_number.nil? + unless ticket_number.is_a?(Integer) + self.ticket_number = self.ticket_number.delete_prefix("#") unless self.ticket_number.nil? + end end def enabled? diff --git a/spec/models/concerns/justifiable_spec.rb b/spec/models/concerns/justifiable_spec.rb index b023e56a6f0..2e68cd2bd48 100644 --- a/spec/models/concerns/justifiable_spec.rb +++ b/spec/models/concerns/justifiable_spec.rb @@ -26,7 +26,7 @@ record.assign_attributes(attributes) expect(record).not_to be_valid - expect(record.errors[:ticket_number]).to contain_exactly("can't be blank", "is not a number") + expect(record.errors[:ticket_number]).to contain_exactly("can't be blank", "may begin with an # and otherwise contain only numbers.") expect(record.ticket_url).to be_nil end