]> source.dussan.org Git - redmine.git/commitdiff
Fixed that preview doesn't show notes when issue project is changed (#17959).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 5 Oct 2014 13:18:55 +0000 (13:18 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 5 Oct 2014 13:18:55 +0000 (13:18 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13428 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/previews_controller.rb
test/functional/previews_controller_test.rb

index 38245b94b982a421ee290854ee089fa7c50c4946..e74d1fe553e3743d7ccc3c7ff5837dd520d8a63c 100644 (file)
@@ -19,7 +19,7 @@ class PreviewsController < ApplicationController
   before_filter :find_project, :find_attachments
 
   def issue
-    @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
+    @issue = Issue.visible.find_by_id(params[:id]) unless params[:id].blank?
     if @issue
       @description = params[:issue] && params[:issue][:description]
       if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
@@ -45,7 +45,7 @@ class PreviewsController < ApplicationController
 
   def find_project
     project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
-    @project = Project.find(project_id)
+    @project = Project.visible.find(project_id)
   rescue ActiveRecord::RecordNotFound
     render_404
   end
index 976af94e321d370eee9e697a47367fcd80165f1b..abbbd7afa70ad935c8a115b59f037d29d78dbc3f 100644 (file)
@@ -62,6 +62,14 @@ class PreviewsControllerTest < ActionController::TestCase
     assert_select 'a.attachment', :text => 'foo.bar'
   end
 
+  def test_preview_issue_with_project_changed
+    @request.session[:user_id] = 2
+    post :issue, :project_id => '1', :id => 1, :issue => {:notes => 'notes', :project_id => 2}
+    assert_response :success
+    assert_not_nil assigns(:issue)
+    assert_not_nil assigns(:notes)
+  end
+
   def test_preview_new_news
     get :news, :project_id => 1,
                   :news => {:title => '',