]> source.dussan.org Git - redmine.git/commitdiff
Separated ReportsController#issue_report into two separate actions.
authorEric Davis <edavis@littlestreamsoftware.com>
Mon, 8 Feb 2010 17:53:58 +0000 (17:53 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Mon, 8 Feb 2010 17:53:58 +0000 (17:53 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3396 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/reports_controller.rb
config/routes.rb
lib/redmine.rb
test/functional/reports_controller_test.rb
test/integration/routing_test.rb

index e057c6c0a77dd03840f1d853c71fb6eb483489f7..ef2ffd339fdb080d437d69164bd92e787ecf64d9 100644 (file)
@@ -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)
index 8956e3c946f59b3c089142cab722141182cdf888..54a5ddf1724b06660233054c7558c0546b0da199 100644 (file)
@@ -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|
index 9d9de9cf9cc9d2653309bf03de63dac27ac6f22d..573692ff1ea9ea07970b4d1a766e888244924b36 100644 (file)
@@ -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]}
index d9ef4942add982e11a8108b1832310758f229c12..db9d9cda7558f2a9297e93c0692cf2db231b02b7 100644 (file)
@@ -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
index dc3e32e8c983de8887fb4bcb5a6759f40e93e5a5..5f9b8c1928964db9402dbfb4719d76969f789e02 100644 (file)
@@ -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