]> source.dussan.org Git - redmine.git/commitdiff
Fixed that some error messages were not displayed (#2866).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 1 Mar 2009 10:15:38 +0000 (10:15 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 1 Mar 2009 10:15:38 +0000 (10:15 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2542 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
test/functional/issues_controller_test.rb

index d4d1bb611ddca1f8cab26f474b52307877b666a6..0af5f192a497b268099368f44d9ea556dcf60ff5 100644 (file)
@@ -120,8 +120,7 @@ class IssuesController < ApplicationController
     # Tracker must be set before custom field values
     @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
     if @issue.tracker.nil?
-      flash.now[:error] = 'No tracker is associated to this project. Please check the Project settings.'
-      render :nothing => true, :layout => true
+      render_error 'No tracker is associated to this project. Please check the Project settings.'
       return
     end
     if params[:issue].is_a?(Hash)
@@ -132,8 +131,7 @@ class IssuesController < ApplicationController
     
     default_status = IssueStatus.default
     unless default_status
-      flash.now[:error] = 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
-      render :nothing => true, :layout => true
+      render_error 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
       return
     end    
     @issue.status = default_status
index ebc2aa8b81dd321187fae4fb376a5ead1e055968..6748f078f2cf4aa4350925777f9d6bab44da7310 100644 (file)
@@ -379,6 +379,28 @@ class IssuesControllerTest < Test::Unit::TestCase
     assert_equal Project.find(1).trackers.first, issue.tracker
   end
   
+  def test_get_new_with_no_default_status_should_display_an_error
+    @request.session[:user_id] = 2
+    IssueStatus.delete_all
+    
+    get :new, :project_id => 1
+    assert_response 500
+    assert_not_nil flash[:error]
+    assert_tag :tag => 'div', :attributes => { :class => /error/ },
+                              :content => /No default issue/
+  end
+  
+  def test_get_new_with_no_tracker_should_display_an_error
+    @request.session[:user_id] = 2
+    Tracker.delete_all
+    
+    get :new, :project_id => 1
+    assert_response 500
+    assert_not_nil flash[:error]
+    assert_tag :tag => 'div', :attributes => { :class => /error/ },
+                              :content => /No tracker/
+  end
+  
   def test_update_new_form
     @request.session[:user_id] = 2
     xhr :post, :new, :project_id => 1,