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
: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',
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'}
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'
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
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