1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-06 09:03:25 +00:00

Preview when editing journal notes broken by r15621.

git-svn-id: http://svn.redmine.org/redmine/trunk@16542 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2017-04-13 12:15:21 +00:00
parent 4d5ddb0072
commit 35bb707b91
4 changed files with 28 additions and 6 deletions

View File

@ -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

View File

@ -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',

View File

@ -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

View File

@ -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