<p><%= link_to_project(news.project) + ': ' unless @project %>
-<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
+<%= link_to h(news.title), news_path(news) %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<br />
<% unless news.summary.blank? %><span class="summary"><%=h news.summary %></span><br /><% end %>
<h2><%=l(:label_news)%></h2>
-<% labelled_tabular_form_for :news, @news, :url => { :action => "update" },
+<% labelled_tabular_form_for :news, @news, :url => news_path(@news),
:html => { :id => 'news-form', :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
- { :url => { :controller => 'previews', :action => 'news', :project_id => @project },
+ { :url => preview_news_path(:project_id => @project),
:method => 'get',
:update => 'preview',
:with => "Form.serialize('news-form')"
<div class="contextual">
<%= link_to_if_authorized(l(:label_news_new),
- {:controller => 'news', :action => 'new', :project_id => @project},
+ new_project_news_path(@project),
:class => 'icon icon-add',
:onclick => 'Element.show("add-news"); Form.Element.focus("news_title"); return false;') if @project %>
</div>
<div id="add-news" style="display:none;">
<h2><%=l(:label_news_new)%></h2>
-<% labelled_tabular_form_for :news, @news, :url => { :controller => 'news', :action => 'create', :project_id => @project },
+<% labelled_tabular_form_for :news, @news, :url => project_news_index_path(@project),
:html => { :id => 'news-form' } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<%= link_to_remote l(:label_preview),
- { :url => { :controller => 'previews', :action => 'news', :project_id => @project },
+ { :url => preview_news_path(:project_id => @project),
:method => 'get',
:update => 'preview',
:with => "Form.serialize('news-form')"
<% else %>
<% @newss.each do |news| %>
<h3><%= link_to_project(news.project) + ': ' unless news.project == @project %>
- <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
+ <%= link_to h(news.title), news_path(news) %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %></h3>
<p class="author"><%= authoring news.created_on, news.author %></p>
<div class="wiki">
<h2><%=l(:label_news_new)%></h2>
-<% labelled_tabular_form_for :news, @news, :url => { :controller => 'news', :action => 'create', :project_id => @project },
+<% labelled_tabular_form_for :news, @news, :url => project_news_index_path(@project),
:html => { :id => 'news-form' } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<%= link_to_remote l(:label_preview),
- { :url => { :controller => 'previews', :action => 'news', :project_id => @project },
+ { :url => preview_news_path(:project_id => @project),
:method => 'get',
:update => 'preview',
:with => "Form.serialize('news-form')"
<div class="contextual">
<%= link_to_if_authorized l(:button_edit),
- {:controller => 'news', :action => 'edit', :id => @news},
+ edit_news_path(@news),
:class => 'icon icon-edit',
:accesskey => accesskey(:edit),
:onclick => 'Element.show("edit-news"); return false;' %>
-<%= link_to_if_authorized l(:button_delete), {:controller => 'news', :action => 'destroy', :id => @news}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
+<%= link_to_if_authorized l(:button_delete), news_path(@news), :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %>
</div>
<h2><%= avatar(@news.author, :size => "24") %><%=h @news.title %></h2>
<% if authorize_for('news', 'edit') %>
<div id="edit-news" style="display:none;">
-<% labelled_tabular_form_for :news, @news, :url => { :action => "update", :id => @news },
+<% labelled_tabular_form_for :news, @news, :url => news_path(@news),
:html => { :id => 'news-form', :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
- { :url => { :controller => 'previews', :action => 'news', :project_id => @project },
+ { :url => preview_news_path(:project_id => @project),
:method => 'get',
:update => 'preview',
:with => "Form.serialize('news-form')"
relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
end
-
- map.with_options :controller => 'news' do |news_routes|
- news_routes.connect 'news/:id/preview', :controller => 'previews', :action => 'news'
- news_routes.connect 'news/preview', :controller => 'previews', :action => 'news'
-
- news_routes.with_options :conditions => {:method => :get} do |news_views|
- news_views.connect 'news', :action => 'index'
- news_views.connect 'projects/:project_id/news', :action => 'index'
- news_views.connect 'projects/:project_id/news.:format', :action => 'index'
- news_views.connect 'news.:format', :action => 'index'
- news_views.connect 'projects/:project_id/news/new', :action => 'new'
- news_views.connect 'news/:id', :action => 'show'
- news_views.connect 'news/:id/edit', :action => 'edit'
- end
- news_routes.with_options do |news_actions|
- news_actions.connect 'projects/:project_id/news', :action => 'create', :conditions => {:method => :post}
- news_actions.connect 'news/:id/destroy', :action => 'destroy'
- end
- news_routes.connect 'news/:id/edit', :action => 'update', :conditions => {:method => :put}
- news_routes.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
- news_routes.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
- end
-
map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
map.with_options :controller => 'users' do |users|
# For nice "roadmap" in the url for the index action
map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
+ map.all_news 'news', :controller => 'news', :action => 'index'
+ map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
+ map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
+ map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
+ map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
+
map.resources :projects, :member => {
:copy => [:get, :post],
:settings => :get,
project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy]
project.resources :files, :only => [:index, :new, :create]
project.resources :versions, :collection => {:close_completed => :put}, :member => {:status_by => :post}
+ project.resources :news, :shallow => true
end
# Destroy uses a get request to prompt the user before the actual DELETE request
def test_destroy
@request.session[:user_id] = 2
- post :destroy, :id => 1
+ delete :destroy, :id => 1
assert_redirected_to 'projects/ecookbook/news'
assert_nil News.find_by_id(1)
end
should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
- should_route :get, "/news/123/preview", :controller => 'previews', :action => 'news', :id => '123'
should_route :get, "/news/preview", :controller => 'previews', :action => 'news'
should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567'
- should_route :post, "/news/567/destroy", :controller => 'news', :action => 'destroy', :id => '567'
should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567'
- should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
-
- should_route :put, "/news/567/edit", :controller => 'news', :action => 'update', :id => '567'
+ should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567'
+ should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567'
should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15'
end