@@ -1,5 +1,5 | |||
|
1 | 1 | <p><%= link_to_project(news.project) + ': ' unless @project %> |
|
2 |
<%= link_to h(news.title), |
|
|
2 | <%= link_to h(news.title), news_path(news) %> | |
|
3 | 3 | <%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %> |
|
4 | 4 | <br /> |
|
5 | 5 | <% unless news.summary.blank? %><span class="summary"><%=h news.summary %></span><br /><% end %> |
@@ -1,11 +1,11 | |||
|
1 | 1 | <h2><%=l(:label_news)%></h2> |
|
2 | 2 | |
|
3 |
<% labelled_tabular_form_for :news, @news, :url => |
|
|
3 | <% labelled_tabular_form_for :news, @news, :url => news_path(@news), | |
|
4 | 4 | :html => { :id => 'news-form', :method => :put } do |f| %> |
|
5 | 5 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
6 | 6 | <%= submit_tag l(:button_save) %> |
|
7 | 7 | <%= link_to_remote l(:label_preview), |
|
8 |
{ :url => |
|
|
8 | { :url => preview_news_path(:project_id => @project), | |
|
9 | 9 | :method => 'get', |
|
10 | 10 | :update => 'preview', |
|
11 | 11 | :with => "Form.serialize('news-form')" |
@@ -1,18 +1,18 | |||
|
1 | 1 | <div class="contextual"> |
|
2 | 2 | <%= link_to_if_authorized(l(:label_news_new), |
|
3 |
|
|
|
3 | new_project_news_path(@project), | |
|
4 | 4 | :class => 'icon icon-add', |
|
5 | 5 | :onclick => 'Element.show("add-news"); Form.Element.focus("news_title"); return false;') if @project %> |
|
6 | 6 | </div> |
|
7 | 7 | |
|
8 | 8 | <div id="add-news" style="display:none;"> |
|
9 | 9 | <h2><%=l(:label_news_new)%></h2> |
|
10 |
<% labelled_tabular_form_for :news, @news, :url => |
|
|
10 | <% labelled_tabular_form_for :news, @news, :url => project_news_index_path(@project), | |
|
11 | 11 | :html => { :id => 'news-form' } do |f| %> |
|
12 | 12 | <%= render :partial => 'news/form', :locals => { :f => f } %> |
|
13 | 13 | <%= submit_tag l(:button_create) %> |
|
14 | 14 | <%= link_to_remote l(:label_preview), |
|
15 |
{ :url => |
|
|
15 | { :url => preview_news_path(:project_id => @project), | |
|
16 | 16 | :method => 'get', |
|
17 | 17 | :update => 'preview', |
|
18 | 18 | :with => "Form.serialize('news-form')" |
@@ -29,7 +29,7 | |||
|
29 | 29 | <% else %> |
|
30 | 30 | <% @newss.each do |news| %> |
|
31 | 31 | <h3><%= link_to_project(news.project) + ': ' unless news.project == @project %> |
|
32 |
<%= link_to h(news.title), |
|
|
32 | <%= link_to h(news.title), news_path(news) %> | |
|
33 | 33 | <%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %></h3> |
|
34 | 34 | <p class="author"><%= authoring news.created_on, news.author %></p> |
|
35 | 35 | <div class="wiki"> |
@@ -1,11 +1,11 | |||
|
1 | 1 | <h2><%=l(:label_news_new)%></h2> |
|
2 | 2 | |
|
3 |
<% labelled_tabular_form_for :news, @news, :url => |
|
|
3 | <% labelled_tabular_form_for :news, @news, :url => project_news_index_path(@project), | |
|
4 | 4 | :html => { :id => 'news-form' } do |f| %> |
|
5 | 5 | <%= render :partial => 'news/form', :locals => { :f => f } %> |
|
6 | 6 | <%= submit_tag l(:button_create) %> |
|
7 | 7 | <%= link_to_remote l(:label_preview), |
|
8 |
{ :url => |
|
|
8 | { :url => preview_news_path(:project_id => @project), | |
|
9 | 9 | :method => 'get', |
|
10 | 10 | :update => 'preview', |
|
11 | 11 | :with => "Form.serialize('news-form')" |
@@ -1,22 +1,22 | |||
|
1 | 1 | <div class="contextual"> |
|
2 | 2 | <%= link_to_if_authorized l(:button_edit), |
|
3 | {:controller => 'news', :action => 'edit', :id => @news}, | |
|
3 | edit_news_path(@news), | |
|
4 | 4 | :class => 'icon icon-edit', |
|
5 | 5 | :accesskey => accesskey(:edit), |
|
6 | 6 | :onclick => 'Element.show("edit-news"); return false;' %> |
|
7 |
<%= link_to_if_authorized l(:button_delete), |
|
|
7 | <%= link_to_if_authorized l(:button_delete), news_path(@news), :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> | |
|
8 | 8 | </div> |
|
9 | 9 | |
|
10 | 10 | <h2><%= avatar(@news.author, :size => "24") %><%=h @news.title %></h2> |
|
11 | 11 | |
|
12 | 12 | <% if authorize_for('news', 'edit') %> |
|
13 | 13 | <div id="edit-news" style="display:none;"> |
|
14 |
<% labelled_tabular_form_for :news, @news, :url => |
|
|
14 | <% labelled_tabular_form_for :news, @news, :url => news_path(@news), | |
|
15 | 15 | :html => { :id => 'news-form', :method => :put } do |f| %> |
|
16 | 16 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
17 | 17 | <%= submit_tag l(:button_save) %> |
|
18 | 18 | <%= link_to_remote l(:label_preview), |
|
19 |
{ :url => |
|
|
19 | { :url => preview_news_path(:project_id => @project), | |
|
20 | 20 | :method => 'get', |
|
21 | 21 | :update => 'preview', |
|
22 | 22 | :with => "Form.serialize('news-form')" |
@@ -136,30 +136,7 ActionController::Routing::Routes.draw do |map| | |||
|
136 | 136 | relations.connect 'issues/:issue_id/relations/:id', :action => 'new' |
|
137 | 137 | relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy' |
|
138 | 138 | end |
|
139 | ||
|
140 | map.with_options :controller => 'news' do |news_routes| | |
|
141 | news_routes.connect 'news/:id/preview', :controller => 'previews', :action => 'news' | |
|
142 | news_routes.connect 'news/preview', :controller => 'previews', :action => 'news' | |
|
143 | ||
|
144 | news_routes.with_options :conditions => {:method => :get} do |news_views| | |
|
145 | news_views.connect 'news', :action => 'index' | |
|
146 | news_views.connect 'projects/:project_id/news', :action => 'index' | |
|
147 | news_views.connect 'projects/:project_id/news.:format', :action => 'index' | |
|
148 | news_views.connect 'news.:format', :action => 'index' | |
|
149 | news_views.connect 'projects/:project_id/news/new', :action => 'new' | |
|
150 | news_views.connect 'news/:id', :action => 'show' | |
|
151 | news_views.connect 'news/:id/edit', :action => 'edit' | |
|
152 | end | |
|
153 | news_routes.with_options do |news_actions| | |
|
154 | news_actions.connect 'projects/:project_id/news', :action => 'create', :conditions => {:method => :post} | |
|
155 | news_actions.connect 'news/:id/destroy', :action => 'destroy' | |
|
156 | end | |
|
157 | news_routes.connect 'news/:id/edit', :action => 'update', :conditions => {:method => :put} | |
|
158 | 139 | |
|
159 | news_routes.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post} | |
|
160 | news_routes.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete} | |
|
161 | end | |
|
162 | ||
|
163 | 140 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' |
|
164 | 141 | |
|
165 | 142 | map.with_options :controller => 'users' do |users| |
@@ -182,6 +159,12 ActionController::Routing::Routes.draw do |map| | |||
|
182 | 159 | # For nice "roadmap" in the url for the index action |
|
183 | 160 | map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' |
|
184 | 161 | |
|
162 | map.all_news 'news', :controller => 'news', :action => 'index' | |
|
163 | map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index' | |
|
164 | map.preview_news '/news/preview', :controller => 'previews', :action => 'news' | |
|
165 | map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post} | |
|
166 | map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete} | |
|
167 | ||
|
185 | 168 | map.resources :projects, :member => { |
|
186 | 169 | :copy => [:get, :post], |
|
187 | 170 | :settings => :get, |
@@ -192,6 +175,7 ActionController::Routing::Routes.draw do |map| | |||
|
192 | 175 | project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] |
|
193 | 176 | project.resources :files, :only => [:index, :new, :create] |
|
194 | 177 | project.resources :versions, :collection => {:close_completed => :put}, :member => {:status_by => :post} |
|
178 | project.resources :news, :shallow => true | |
|
195 | 179 | end |
|
196 | 180 | |
|
197 | 181 | # Destroy uses a get request to prompt the user before the actual DELETE request |
@@ -113,7 +113,7 class NewsControllerTest < ActionController::TestCase | |||
|
113 | 113 | |
|
114 | 114 | def test_destroy |
|
115 | 115 | @request.session[:user_id] = 2 |
|
116 |
|
|
|
116 | delete :destroy, :id => 1 | |
|
117 | 117 | assert_redirected_to 'projects/ecookbook/news' |
|
118 | 118 | assert_nil News.find_by_id(1) |
|
119 | 119 | end |
@@ -157,17 +157,14 class RoutingTest < ActionController::IntegrationTest | |||
|
157 | 157 | should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567' |
|
158 | 158 | should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234' |
|
159 | 159 | should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567' |
|
160 | should_route :get, "/news/123/preview", :controller => 'previews', :action => 'news', :id => '123' | |
|
161 | 160 | should_route :get, "/news/preview", :controller => 'previews', :action => 'news' |
|
162 | 161 | |
|
163 | 162 | should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567' |
|
164 | should_route :post, "/news/567/destroy", :controller => 'news', :action => 'destroy', :id => '567' | |
|
165 | 163 | should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567' |
|
166 | 164 | |
|
167 |
should_route :p |
|
|
168 | ||
|
169 | should_route :put, "/news/567/edit", :controller => 'news', :action => 'update', :id => '567' | |
|
165 | should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567' | |
|
170 | 166 | |
|
167 | should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567' | |
|
171 | 168 | should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15' |
|
172 | 169 | end |
|
173 | 170 |
General Comments 0
You need to be logged in to leave comments.
Login now