Skip to content

Commit

Permalink
Fixes sprint XML download
Browse files Browse the repository at this point in the history
- Add API auth for downloading sprint XML.
- Fixes sprint xml download controller code.
- Add test of downloading sprint XML.
  • Loading branch information
bohansen committed Apr 9, 2014
1 parent 3efab94 commit 20a126a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/controllers/rb_sprints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
class RbSprintsController < RbApplicationController
unloadable

# Accept download as API request as Redmine redirects XML format to this type
accept_api_auth :download

def create
attribs = params.select{|k,v| k != 'id' and RbSprint.column_names.include? k }
attribs = Hash[*attribs.flatten]
Expand Down Expand Up @@ -59,10 +62,10 @@ def download
bold = {:font => {:bold => true}}
dump = BacklogsSpreadsheet::WorkBook.new
ws = dump[@sprint.name]
ws << [nil, @sprint.id, nil, nil, {:value => @sprint.name, :style => bold}, {:value => 'Start', :style => bold}] + @sprint.days(:all).collect{|d| {:value => d, :style => bold} }
ws << [nil, @sprint.id, nil, nil, {:value => @sprint.name, :style => bold}, {:value => 'Start', :style => bold}] + @sprint.days.collect{|d| {:value => d, :style => bold} }
bd = @sprint.burndown
bd.series(false).sort{|a, b| l("label_#{a}") <=> l("label_#{b}")}.each{ |k|
ws << [ nil, nil, nil, nil, l("label_#{k}") ] + bd[k]
ws << [ nil, nil, nil, nil, l("label_#{k}") ] + bd.data[k.to_sym]
}

@sprint.stories.each{|s|
Expand All @@ -75,7 +78,7 @@ def download
ws << [nil, nil, nil, nil, label ] + bd[k]
}
s.tasks.each {|t|
ws << [nil, nil, t.tracker.name, t.id, {:value => t.subject, :style => bold}] + t.burndown
ws << [nil, nil, t.tracker.name, t.id, {:value => t.subject, :style => bold}] + t.becomes(RbTask).burndown
}
}

Expand Down
9 changes: 9 additions & 0 deletions features/scrum_master.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Feature: Scrum Master
And I have defined the following impediments:
| subject | sprint | blocks |
| Impediment 1 | Sprint 001 | Story A |
And I have defined the following tasks:
| subject | story | assigned_to |
| Task 1 | Story A | |

Scenario: Create an impediment
Given I am viewing the taskboard for Sprint 001
Expand Down Expand Up @@ -196,3 +199,9 @@ Feature: Scrum Master
When I update the sprint
Then the server should return an update error
And the error message should say "Sprint cannot end before it starts"

Scenario: Download sprint as XML spreadsheet
Given I am viewing the master backlog
And I have set my API access key
When I try to download the XML sheet for Sprint 001
Then the request should complete successfully
6 changes: 6 additions & 0 deletions features/step_definitions/_when_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@
visit url_for({ :key => @api_key, :controller => 'rb_calendars', :action => 'ical', :project_id => @project, :format => 'xml', :only_path => true})
end

When /^I try to download the XML sheet for (.+)$/ do |sprint_name|
sprint = RbSprint.find(:first, :conditions => ["name=?", sprint_name])
visit url_for({:key => @api_key, :controller => :rb_sprints, :action => :download,
:sprint_id => sprint, :format => :xml, :only_path => true})
end

When /^I view the master backlog$/ do
visit url_for(:controller => :projects, :action => :show, :id => @project, :only_path => true)
click_link("Backlogs")
Expand Down

0 comments on commit 20a126a

Please sign in to comment.