Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transition issue #358

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
#
# # Transition an issue
# # -------------------
# issue_transition = issue.transitions.build
# issue_transition.save!('transition' => {'id' => transition_id})
# issue_transition = underlying_jira.transitions.all.find { |t| t.name == "Transition" }
# issue_transition.save('transition' => { 'id' => transition.id })
#
# # Change assignee
# # -------------------
Expand Down
20 changes: 4 additions & 16 deletions lib/jira/resource/sprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,20 @@ def get_sprint_details_attribute(attribute_name)

def get_sprint_details
search_url =
"#{client.options[:site]}#{client.options[:client_path]}/rest/greenhopper/1.0/rapid/charts/sprintreport?rapidViewId=#{rapidview_id}&sprintId=#{id}"
"#{client.options[:site]}#{client.options[:client_path]}/rest/agile/1.0/sprint/#{id}"
begin
response = client.get(search_url)
rescue StandardError
return nil
end
json = self.class.parse_json(response.body)

@start_date = Date.parse(json['sprint']['startDate']) unless json['sprint']['startDate'] == 'None'
@end_date = Date.parse(json['sprint']['endDate']) unless json['sprint']['endDate'] == 'None'
@completed_date = Date.parse(json['sprint']['completeDate']) unless json['sprint']['completeDate'] == 'None'
@start_date = json['sprint']['startDate'] && Date.parse(json['sprint']['startDate'])
@end_date = json['sprint']['endDate'] && Date.parse(json['sprint']['endDate'])
@completed_date = json['sprint']['completeDate'] && Date.parse(json['sprint']['completeDate'])
@sprint_report = client.SprintReport.build(json['contents'])
end

def rapidview_id
return @attrs['rapidview_id'] if @attrs['rapidview_id']
search_url = client.options[:site] + '/secure/GHGoToBoard.jspa?sprintId=' + id.to_s
begin
response = client.get(search_url)
rescue JIRA::HTTPError => error
return unless error.response.instance_of? Net::HTTPFound
rapid_view_match = /rapidView=(\d+)&/.match(error.response['location'])
@attrs['rapidview_id'] = rapid_view_match[1] unless rapid_view_match.nil?
end
end

def save(attrs = {}, _path = nil)
attrs = @attrs if attrs.empty?
super(attrs, agile_path)
Expand Down
13 changes: 13 additions & 0 deletions lib/jira/resource/transition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ def self.all(client, options = {})
issue.transitions.build(transition)
end
end

# Saves the specified resource attributes by sending either a POST or PUT
# request to JIRA, depending on resource.new_record?
#
# Accepts an attributes hash of the values to be saved. Will throw a
# JIRA::HTTPError if the request fails (response is not HTTP 2xx).
def save!(attrs, path = nil)
path = "#{client.options[:site]}#{client.options[:context]}/rest/api/2/issue/#{self.issue_id}/transitions"
response = client.send(:post, path, attrs.to_json)
set_attrs_from_response(response)
@expanded = false
true
end
end
end
end