Feature #27368 » comment-preview.patch
| app/controllers/previews_controller.rb (working copy) | ||
|---|---|---|
| 41 | 41 |
render :partial => 'common/preview' |
| 42 | 42 |
end |
| 43 | 43 | |
| 44 |
def comment |
|
| 45 |
@text = params[:comment][:comments] |
|
| 46 |
render partial: 'common/preview' |
|
| 47 |
end |
|
| 48 | ||
| 44 | 49 |
private |
| 45 | 50 | |
| 46 | 51 |
def find_project |
| app/views/news/show.html.erb (working copy) | ||
|---|---|---|
| 58 | 58 |
<%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> |
| 59 | 59 |
<%= wikitoolbar_for 'comment_comments' %> |
| 60 | 60 |
</div> |
| 61 |
<p><%= submit_tag l(:button_add) %></p> |
|
| 61 |
<p> |
|
| 62 |
<%= submit_tag l(:button_add) %> |
|
| 63 |
<%= preview_link preview_comment_path(project_id: @project), 'add_comment_form', 'comment-preview' %> |
|
| 64 |
</p> |
|
| 62 | 65 |
<% end %> |
| 66 |
<div id="comment-preview" class="wiki"></div> |
|
| 63 | 67 |
<% end %> |
| 64 | 68 | |
| 65 | 69 |
<% html_title @news.title -%> |
| config/routes.rb (working copy) | ||
|---|---|---|
| 29 | 29 |
match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put, :patch] |
| 30 | 30 |
match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put, :patch] |
| 31 | 31 |
match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put, :patch] |
| 32 |
match '/comments/preview', to: 'previews#comment', as: 'preview_comment', via: [:post] |
|
| 32 | 33 | |
| 33 | 34 |
match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post |
| 34 | 35 |
match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post] |
| test/functional/previews_controller_test.rb (working copy) | ||
|---|---|---|
| 141 | 141 |
assert_response :success |
| 142 | 142 |
assert_select 'fieldset.preview', :text => /News description/ |
| 143 | 143 |
end |
| 144 | ||
| 145 |
def test_preview_comment |
|
| 146 |
post :comment, params: {
|
|
| 147 |
project_id: 1, |
|
| 148 |
comment: {
|
|
| 149 |
comments: 'Comment content :)' |
|
| 150 |
} |
|
| 151 |
} |
|
| 152 |
assert_response :success |
|
| 153 |
assert_select 'fieldset.preview', text: /Comment content :\)/ |
|
| 154 |
end |
|
| 144 | 155 |
end |
| test/integration/routing/previews_test.rb (working copy) | ||
|---|---|---|
| 28 | 28 |
should_route 'POST /issues/preview/edit/321' => 'previews#issue', :id => '321' |
| 29 | 29 | |
| 30 | 30 |
should_route 'GET /news/preview' => 'previews#news' |
| 31 | ||
| 32 |
should_route 'POST /comments/preview' => 'previews#comment' |
|
| 31 | 33 |
end |
| 32 | 34 |
end |