Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'fixed_for_2_custom_fields'

Conflicts:
	lib/issue_patch.rb
  • Loading branch information...
commit 07f551d401702237b76e28cf2f084bc84d4c90b6 2 parents eed777e + 14331aa
@pbrudny pbrudny authored
Showing with 13 additions and 20 deletions.
  1. +13 −20 lib/issue_patch.rb
View
33 lib/issue_patch.rb
@@ -11,17 +11,13 @@ def self.included(klass) # :nodoc:
# Finishes story when Issue status changed to 'closed' or 'rejected'
before_update do |issue|
if issue.status_id_changed? && issue.status.is_closed?
- begin
- if issue.pivotal_story_id != 0 && issue.pivotal_project_id != 0
+ if (issue.pivotal_story_id != 0) || (issue.pivotal_project_id != 0)
+ begin
Trackmine.finish_story( issue.pivotal_project_id, issue.pivotal_story_id )
- elsif issue.pivotal_story_id == 0 && issue.pivotal_project_id == 0
- #Do nothing when both are empty
- else
- throw Exception.new("You should fill both fields (Pivotal Story ID, Pivotal Project ID) in issue: '#{issue.subject}' or none")
- end
- rescue => e
- TrackmineMailer.deliver_error_mail("Error while closing story: " + e)
- end
+ rescue => e
+ TrackmineMailer.deliver_error_mail("Error while closing story. Pivotal Project ID:'#{issue.pivotal_project_id}', Story ID:'#{issue.pivotal_story_id}',: " + e)
+ end
+ end
end
end
@@ -33,14 +29,11 @@ def self.find_by_story_id(story_id)
end
def pivotal_custom_value(name)
- cv = CustomValue.first :joins => :custom_field,
- :readonly => false,
- :conditions => { :custom_values => { :customized_id => self.id,
- :customized_type => 'Issue' },
- :custom_fields => { :name => name } }
-
- logger.error("Can't find #{name} custom field for issue: '#{self.subject}'") if cv.nil?
- return cv
+ CustomValue.first :joins => :custom_field,
+ :readonly => false,
+ :conditions => { :custom_values => { :customized_id => self.id,
+ :customized_type => 'Issue' },
+ :custom_fields => { :name => name } }
end
# Pivotal Project ID setter
@@ -50,7 +43,7 @@ def pivotal_project_id=(project_id)
# Pivotal Project ID getter
def pivotal_project_id
- pivotal_custom_value('Pivotal Project ID').value.to_i
+ pivotal_custom_value('Pivotal Project ID').try(:value).to_i
end
# Pivotal Story ID setter
@@ -60,7 +53,7 @@ def pivotal_story_id=(story_id)
# Pivotal Story ID getter
def pivotal_story_id
- pivotal_custom_value('Pivotal Story ID').value.to_i
+ pivotal_custom_value('Pivotal Story ID').try(:value).to_i
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.