Class: JIRA::Resource::Issue
- Inherits:
-
Object
- Object
- JIRA::Resource::Issue
- Defined in:
- lib/yajp/issue.rb
Overview
This class extends (aka monkey patch) the ‘JIRA::Resource::Issue` class with straightforward methods to easily transition and update issues.
Instance Method Summary collapse
-
#get_transition_id(name) ⇒ Integer
Retrieve the ID of the transition matching the given name.
-
#link ⇒ String
Get the browse URL of the issue.
-
#transition(transition_id, **fields) ⇒ Boolean
Transition the issue using the ID or name of the transition.
-
#update(**fields) ⇒ Boolean
Update the issue.
Instance Method Details
#get_transition_id(name) ⇒ Integer
Retrieve the ID of the transition matching the given name.
62 63 64 65 66 67 68 |
# File 'lib/yajp/issue.rb', line 62 def get_transition_id(name) transitions.all.each do |transition| return transition.id if transition.name.casecmp?(name) end return -1 end |
#link ⇒ String
Get the browse URL of the issue.
13 14 15 |
# File 'lib/yajp/issue.rb', line 13 def link "#{ENV['DANGER_JIRA_URL']}/browse/#{key}" end |
#transition(transition_id, **fields) ⇒ Boolean
Transition the issue using the ID or name of the transition. Transition IDs can be found in Jira under Project Workflow > Edit Workflow in Text Mode. The transition name is the text that appears on the issue screen to transition it. The fields that can be updated with this method are only the fields available in the transition screen of the transition. Otherwise use ‘transition_and_update`.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/yajp/issue.rb', line 44 def transition(transition_id, **fields) if transition_id.kind_of?(String) transition_id = get_transition_id(transition_id) return false if transition_id == -1 end data = { transition: { id: transition_id.to_s } } data[:fields] = fields unless fields.empty? transitions.build.save(data) end |
#update(**fields) ⇒ Boolean
Update the issue.
26 27 28 29 30 |
# File 'lib/yajp/issue.rb', line 26 def update(**fields) return if fields.empty? save({ fields: fields }) end |