From: Jean-Philippe Lang Date: Thu, 13 Apr 2017 12:15:21 +0000 (+0000) Subject: Preview when editing journal notes broken by r15621. X-Git-Tag: 3.4.0~134 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=35bb707b918d58e23d9a784a9226cade5304a08d;p=redmine.git Preview when editing journal notes broken by r15621. git-svn-id: http://svn.redmine.org/redmine/trunk@16542 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/previews_controller.rb b/app/controllers/previews_controller.rb index 698816e44..d81560c13 100644 --- a/app/controllers/previews_controller.rb +++ b/app/controllers/previews_controller.rb @@ -25,8 +25,8 @@ class PreviewsController < ApplicationController if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n") @description = nil end - # params[:notes] is useful for preview of notes in issue history - @notes = params[:notes] || (params[:issue] ? params[:issue][:notes] : nil) + @notes = params[:journal] ? params[:journal][:notes] : nil + @notes ||= params[:issue] ? params[:issue][:notes] : nil else @description = (params[:issue] ? params[:issue][:description] : nil) end diff --git a/app/views/journals/_notes_form.html.erb b/app/views/journals/_notes_form.html.erb index 3bd6a31fd..2ab978769 100644 --- a/app/views/journals/_notes_form.html.erb +++ b/app/views/journals/_notes_form.html.erb @@ -2,7 +2,7 @@ :remote => true, :method => 'put', :id => "journal-#{@journal.id}-form") do %> - <%= label_tag "notes", l(:description_notes), :class => "hidden-for-sighted" %> + <%= label_tag "notes", l(:description_notes), :class => "hidden-for-sighted", :for => "journal_#{@journal.id}_notes" %> <%= text_area_tag 'journal[notes]', @journal.notes, :id => "journal_#{@journal.id}_notes", :class => 'wiki-edit', diff --git a/test/functional/previews_controller_test.rb b/test/functional/previews_controller_test.rb index ac9090de9..e75a670fe 100644 --- a/test/functional/previews_controller_test.rb +++ b/test/functional/previews_controller_test.rb @@ -47,7 +47,7 @@ class PreviewsControllerTest < Redmine::ControllerTest assert_select 'legend', :text => 'Notes' end - def test_preview_issue_notes_with_no_change_to_description + def test_preview_issue_notes_with_change_to_description @request.session[:user_id] = 2 post :issue, :project_id => '1', :id => 1, :issue => {:description => 'Changed description', :notes => 'Foo'} @@ -58,7 +58,7 @@ class PreviewsControllerTest < Redmine::ControllerTest def test_preview_journal_notes_for_update @request.session[:user_id] = 2 - post :issue, :project_id => '1', :id => 1, :notes => 'Foo' + post :issue, :project_id => '1', :id => 1, :journal => {:notes => 'Foo'} assert_response :success assert_select 'legend', :text => 'Notes' assert_select 'p', :text => 'Foo' @@ -67,7 +67,7 @@ class PreviewsControllerTest < Redmine::ControllerTest def test_preview_issue_notes_should_support_links_to_existing_attachments Attachment.generate!(:container => Issue.find(1), :filename => 'foo.bar') @request.session[:user_id] = 2 - post :issue, :project_id => '1', :id => 1, :notes => 'attachment:foo.bar' + post :issue, :project_id => '1', :id => 1, :issue => {:notes => 'attachment:foo.bar'} assert_response :success assert_select 'a.attachment', :text => 'foo.bar' end diff --git a/test/ui/issues_test_ui.rb b/test/ui/issues_test_ui.rb index e19497edc..c0739175d 100644 --- a/test/ui/issues_test_ui.rb +++ b/test/ui/issues_test_ui.rb @@ -310,4 +310,26 @@ class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base assert !page.has_css?('span.total-for-estimated-hours') end end + + def test_update_journal_notes_with_preview + log_user('admin', 'admin') + + visit '/issues/1' + # Click on the edit button + page.first('#change-2 a.icon-edit').click + # Check that the textarea is displayed + assert page.has_css?('#change-2 textarea') + assert page.first('#change-2 textarea').has_content?('Some notes with Redmine links') + # Update the notes + fill_in 'Notes', :with => 'Updated notes' + # Preview the change + click_on 'Preview' + assert page.has_css?('#journal_2_preview') + assert page.first('#journal_2_preview').has_content?('Updated notes') + # Save + click_on 'Save' + + sleep 1 + assert_equal 'Updated notes', Journal.find(2).notes + end end