Index: app/controllers/previews_controller.rb =================================================================== --- app/controllers/previews_controller.rb (revision 17016) +++ app/controllers/previews_controller.rb (working copy) @@ -41,6 +41,11 @@ render :partial => 'common/preview' end + def comment + @text = params[:comment][:comments] + render partial: 'common/preview' + end + private def find_project Index: app/views/news/show.html.erb =================================================================== --- app/views/news/show.html.erb (revision 17016) +++ app/views/news/show.html.erb (working copy) @@ -58,8 +58,12 @@ <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> <%= wikitoolbar_for 'comment_comments' %> -

<%= submit_tag l(:button_add) %>

+

+ <%= submit_tag l(:button_add) %> + <%= preview_link preview_comment_path(project_id: @project), 'add_comment_form', 'comment-preview' %> +

<% end %> +
<% end %> <% html_title @news.title -%> Index: config/routes.rb =================================================================== --- config/routes.rb (revision 17016) +++ config/routes.rb (working copy) @@ -29,6 +29,7 @@ match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put, :patch] match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put, :patch] match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put, :patch] + match '/comments/preview', to: 'previews#comment', as: 'preview_comment', via: [:post] match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post] Index: test/functional/previews_controller_test.rb =================================================================== --- test/functional/previews_controller_test.rb (revision 17016) +++ test/functional/previews_controller_test.rb (working copy) @@ -141,4 +141,15 @@ assert_response :success assert_select 'fieldset.preview', :text => /News description/ end + + def test_preview_comment + post :comment, params: { + project_id: 1, + comment: { + comments: 'Comment content :)' + } + } + assert_response :success + assert_select 'fieldset.preview', text: /Comment content :\)/ + end end Index: test/integration/routing/previews_test.rb =================================================================== --- test/integration/routing/previews_test.rb (revision 17016) +++ test/integration/routing/previews_test.rb (working copy) @@ -28,5 +28,7 @@ should_route 'POST /issues/preview/edit/321' => 'previews#issue', :id => '321' should_route 'GET /news/preview' => 'previews#news' + + should_route 'POST /comments/preview' => 'previews#comment' end end