From 79e30e7087d714ad81de83d389c37ae7d46d4dad Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Mon, 27 Sep 2010 16:51:12 +0000 Subject: [PATCH] Refactor: convert News to a REST resource git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4214 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/news/_news.rhtml | 2 +- app/views/news/edit.rhtml | 4 ++-- app/views/news/index.rhtml | 8 +++---- app/views/news/new.rhtml | 4 ++-- app/views/news/show.rhtml | 8 +++---- config/routes.rb | 30 ++++++------------------- test/functional/news_controller_test.rb | 2 +- test/integration/routing_test.rb | 7 ++---- 8 files changed, 23 insertions(+), 42 deletions(-) diff --git a/app/views/news/_news.rhtml b/app/views/news/_news.rhtml index 8f481f09..ddbaecab 100644 --- a/app/views/news/_news.rhtml +++ b/app/views/news/_news.rhtml @@ -1,5 +1,5 @@

<%= 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 %>
<% unless news.summary.blank? %><%=h news.summary %>
<% end %> diff --git a/app/views/news/edit.rhtml b/app/views/news/edit.rhtml index 70482008..0d44bfbb 100644 --- a/app/views/news/edit.rhtml +++ b/app/views/news/edit.rhtml @@ -1,11 +1,11 @@

<%=l(:label_news)%>

-<% 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')" diff --git a/app/views/news/index.rhtml b/app/views/news/index.rhtml index d65bdf2f..c2a227fe 100644 --- a/app/views/news/index.rhtml +++ b/app/views/news/index.rhtml @@ -1,18 +1,18 @@
<%= 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 %>