Preview description if it was edited while updating an issue (#741).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3623 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-03-28 15:17:46 +00:00
parent c499d2d150
commit 2bbc948e06
3 changed files with 38 additions and 3 deletions

View File

@ -453,9 +453,17 @@ class IssuesController < ApplicationController
def preview def preview
@issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank? @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
@attachements = @issue.attachments if @issue if @issue
@text = params[:notes] || (params[:issue] ? params[:issue][:description] : nil) @attachements = @issue.attachments
render :partial => 'common/preview' @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")
@description = nil
end
@notes = params[:notes]
else
@description = (params[:issue] ? params[:issue][:description] : nil)
end
render :layout => false
end end
def auto_complete def auto_complete

View File

@ -0,0 +1,11 @@
<% if @notes %>
<fieldset class="preview"><legend><%= l(:field_notes) %></legend>
<%= textilizable @notes, :attachments => @attachements, :object => @issue %>
</fieldset>
<% end %>
<% if @description %>
<fieldset class="preview"><legend><%= l(:field_description) %></legend>
<%= textilizable @description, :attachments => @attachements, :object => @issue %>
</fieldset>
<% end %>

View File

@ -1272,6 +1272,22 @@ class IssuesControllerTest < ActionController::TestCase
:class => 'icon-del disabled' } :class => 'icon-del disabled' }
end end
def test_preview_new_issue
@request.session[:user_id] = 2
post :preview, :project_id => '1', :issue => {:description => 'Foo'}
assert_response :success
assert_template 'preview'
assert_not_nil assigns(:description)
end
def test_preview_notes
@request.session[:user_id] = 2
post :preview, :project_id => '1', :id => 1, :issue => {:description => Issue.find(1).description}, :notes => 'Foo'
assert_response :success
assert_template 'preview'
assert_not_nil assigns(:notes)
end
def test_auto_complete_routing def test_auto_complete_routing
assert_routing( assert_routing(
{:method => :get, :path => '/issues/auto_complete'}, {:method => :get, :path => '/issues/auto_complete'},