From 597725d77ce07c1e297e83f2a3594bbe1902ab2e Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Mon, 8 Feb 2010 17:53:58 +0000 Subject: [PATCH] Separated ReportsController#issue_report into two separate actions. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3396 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/reports_controller.rb | 42 ++++++++++++---------- config/routes.rb | 6 ++-- lib/redmine.rb | 2 +- test/functional/reports_controller_test.rb | 30 +++++++++++++--- test/integration/routing_test.rb | 2 +- 5 files changed, 54 insertions(+), 28 deletions(-) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index e057c6c0a..ef2ffd339 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -22,6 +22,27 @@ class ReportsController < ApplicationController def issue_report @statuses = IssueStatus.find(:all, :order => 'position') + @trackers = @project.trackers + @versions = @project.shared_versions.sort + @priorities = IssuePriority.all + @categories = @project.issue_categories + @assignees = @project.members.collect { |m| m.user }.sort + @authors = @project.members.collect { |m| m.user }.sort + @subprojects = @project.descendants.active + issues_by_tracker + issues_by_version + issues_by_priority + issues_by_category + issues_by_assigned_to + issues_by_author + issues_by_subproject + + render :template => "reports/issue_report" + end + + def issue_report_details + @statuses = IssueStatus.find(:all, :order => 'position') + case params[:detail] when "tracker" @field = "tracker_id" @@ -66,25 +87,10 @@ class ReportsController < ApplicationController @report_title = l(:field_subproject) render :template => "reports/issue_report_details" else - @trackers = @project.trackers - @versions = @project.shared_versions.sort - @priorities = IssuePriority.all - @categories = @project.issue_categories - @assignees = @project.members.collect { |m| m.user }.sort - @authors = @project.members.collect { |m| m.user }.sort - @subprojects = @project.descendants.active - issues_by_tracker - issues_by_version - issues_by_priority - issues_by_category - issues_by_assigned_to - issues_by_author - issues_by_subproject - - render :template => "reports/issue_report" + redirect_to :action => 'issue_report', :id => @project end - end - + + end private def issues_by_tracker @issues_by_tracker ||= Issue.by_tracker(@project) diff --git a/config/routes.rb b/config/routes.rb index 8956e3c94..54a5ddf17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -139,9 +139,9 @@ ActionController::Routing::Routes.draw do |map| relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy' end - map.with_options :controller => 'reports', :action => 'issue_report', :conditions => {:method => :get} do |reports| - reports.connect 'projects/:id/issues/report' - reports.connect 'projects/:id/issues/report/:detail' + map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| + reports.connect 'projects/:id/issues/report', :action => 'issue_report' + reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' end map.with_options :controller => 'news' do |news_routes| diff --git a/lib/redmine.rb b/lib/redmine.rb index 9d9de9cf9..573692ff1 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -42,7 +42,7 @@ Redmine::AccessControl.map do |map| :issues => [:index, :changes, :show, :context_menu], :versions => [:show, :status_by], :queries => :index, - :reports => :issue_report} + :reports => [:issue_report, :issue_report_details]} map.permission :add_issues, {:issues => [:new, :update_form]} map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit, :update_form]} map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} diff --git a/test/functional/reports_controller_test.rb b/test/functional/reports_controller_test.rb index d9ef4942a..db9d9cda7 100644 --- a/test/functional/reports_controller_test.rb +++ b/test/functional/reports_controller_test.rb @@ -48,12 +48,32 @@ class ReportsControllerTest < ActionController::TestCase end end end - - def test_issue_report_details + + context "GET :issue_report_details" do %w(tracker version priority category assigned_to author subproject).each do |detail| - get :issue_report, :id => 1, :detail => detail - assert_response :success - assert_template 'issue_report_details' + context "for #{detail}" do + setup do + get :issue_report_details, :id => 1, :detail => detail + end + + should_respond_with :success + should_render_template :issue_report_details + should_assign_to :field + should_assign_to :rows + should_assign_to :data + should_assign_to :report_title + end end + + context "with an invalid detail" do + setup do + get :issue_report_details, :id => 1, :detail => 'invalid' + end + + should_respond_with :redirect + should_redirect_to('the issue report') {{:controller => 'reports', :action => 'issue_report', :id => 'ecookbook'}} + end + end + end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index dc3e32e8c..5f9b8c192 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -20,7 +20,7 @@ require "test_helper" class RoutingTest < ActionController::IntegrationTest context "issue reports" do should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567' - should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report', :id => '567', :detail => 'assigned_to' + should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to' end end