]> source.dussan.org Git - redmine.git/commitdiff
Test cleanup.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 1 Jan 2012 19:57:30 +0000 (19:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 1 Jan 2012 19:57:30 +0000 (19:57 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8462 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/functional/reports_controller_test.rb

index 88df190f2eb9ed422b31189a9ae87f0c3736558b..40a1a498c2e1762ed8f7e8a8fabbf4eb047b78f1 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require File.expand_path('../../test_helper', __FILE__)
-require 'reports_controller'
-
-# Re-raise errors caught by the controller.
-class ReportsController; def rescue_action(e) raise e end; end
-
 
 class ReportsControllerTest < ActionController::TestCase
   fixtures :projects, :trackers, :issue_statuses, :issues,
@@ -34,54 +29,36 @@ class ReportsControllerTest < ActionController::TestCase
            :versions
 
   def setup
-    @controller = ReportsController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
-    User.current = nil
   end
 
-  context "GET :issue_report without details" do
-    setup do
-      get :issue_report, :id => 1
-    end
+  def test_get_issue_report
+    get :issue_report, :id => 1
 
-    should_respond_with :success
-    should_render_template :issue_report
+    assert_response :success
+    assert_template 'issue_report'
 
     [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to,
      :issues_by_author, :issues_by_subproject].each do |ivar|
-      should_assign_to ivar
-      should "set a value for #{ivar}" do
-        assert assigns[ivar.to_s].present?
-      end
+      assert_not_nil assigns(ivar)
     end
   end
 
-  context "GET :issue_report_details" do
+  def test_get_issue_report_details
     %w(tracker version priority category assigned_to author subproject).each do |detail|
-      context "for #{detail}" do
-        setup do
-          get :issue_report_details, :id => 1, :detail => detail
-        end
+      get :issue_report_details, :id => 1, :detail => detail
 
-        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
+      assert_response :success
+      assert_template 'issue_report_details'
+      assert_not_nil assigns(:field)
+      assert_not_nil assigns(:rows)
+      assert_not_nil assigns(:data)
+      assert_not_nil assigns(: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
+  def test_get_issue_report_details_with_an_invalid_detail
+    get :issue_report_details, :id => 1, :detail => 'invalid'
 
+    assert_redirected_to '/projects/ecookbook/issues/report'
   end
-
 end