@@ -34,6 +34,10 class PreviewsController < ApplicationController | |||
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | def news |
|
37 | if params[:id].present? && news = News.visible.find_by_id(params[:id]) | |
|
38 | @previewed = news | |
|
39 | @attachments = news.attachments | |
|
40 | end | |
|
37 | 41 | @text = (params[:news] ? params[:news][:description] : nil) |
|
38 | 42 | render :partial => 'common/preview' |
|
39 | 43 | end |
@@ -3,7 +3,7 | |||
|
3 | 3 | <%= labelled_form_for @news, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> |
|
4 | 4 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
5 | 5 | <%= submit_tag l(:button_save) %> |
|
6 | <%= preview_link preview_news_path(:project_id => @project), 'news-form' %> | |
|
6 | <%= preview_link preview_news_path(:project_id => @project, :id => @news), 'news-form' %> | |
|
7 | 7 | <% end %> |
|
8 | 8 | <div id="preview" class="wiki"></div> |
|
9 | 9 |
@@ -16,7 +16,7 | |||
|
16 | 16 | :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> |
|
17 | 17 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
18 | 18 | <%= submit_tag l(:button_save) %> |
|
19 | <%= preview_link preview_news_path(:project_id => @project), 'news-form' %> | | |
|
19 | <%= preview_link preview_news_path(:project_id => @project, :id => @news), 'news-form' %> | | |
|
20 | 20 | <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %> |
|
21 | 21 | <% end %> |
|
22 | 22 | <div id="preview" class="wiki"></div> |
@@ -26,7 +26,8 class PreviewsControllerTest < ActionController::TestCase | |||
|
26 | 26 | :members, |
|
27 | 27 | :enabled_modules, |
|
28 | 28 | :workflows, |
|
29 | :journals, :journal_details | |
|
29 | :journals, :journal_details, | |
|
30 | :news | |
|
30 | 31 | |
|
31 | 32 | def test_preview_new_issue |
|
32 | 33 | @request.session[:user_id] = 2 |
@@ -55,7 +56,7 class PreviewsControllerTest < ActionController::TestCase | |||
|
55 | 56 | assert_tag :p, :content => 'Foo' |
|
56 | 57 | end |
|
57 | 58 | |
|
58 | def test_news | |
|
59 | def test_preview_new_news | |
|
59 | 60 | get :news, :project_id => 1, |
|
60 | 61 | :news => {:title => '', |
|
61 | 62 | :description => 'News description', |
@@ -65,4 +66,18 class PreviewsControllerTest < ActionController::TestCase | |||
|
65 | 66 | assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' }, |
|
66 | 67 | :content => /News description/ |
|
67 | 68 | end |
|
69 | ||
|
70 | def test_existing_new_news | |
|
71 | get :news, :project_id => 1, :id => 2, | |
|
72 | :news => {:title => '', | |
|
73 | :description => 'News description', | |
|
74 | :summary => ''} | |
|
75 | assert_response :success | |
|
76 | assert_template 'common/_preview' | |
|
77 | assert_equal News.find(2), assigns(:previewed) | |
|
78 | assert_not_nil assigns(:attachments) | |
|
79 | ||
|
80 | assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' }, | |
|
81 | :content => /News description/ | |
|
82 | end | |
|
68 | 83 | end |
General Comments 0
You need to be logged in to leave comments.
Login now