From 3bc29e29e091b56bcffeb07ffb9c37c328525f99 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Mon, 20 Sep 2010 15:13:48 +0000 Subject: [PATCH] Refactor: split NewsController#new into #new and #create methods. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4163 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/news_controller.rb | 12 +++++++++--- app/views/news/index.rhtml | 2 +- app/views/news/new.rhtml | 2 +- config/routes.rb | 2 +- lib/redmine.rb | 2 +- test/functional/news_controller_test.rb | 8 ++++---- test/integration/routing_test.rb | 2 +- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 4d44158a4..f4e4b6559 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -18,9 +18,9 @@ class NewsController < ApplicationController default_search_scope :news model_object News - before_filter :find_model_object, :except => [:new, :index, :preview] - before_filter :find_project_from_association, :except => [:new, :index, :preview] - before_filter :find_project, :only => [:new, :preview] + before_filter :find_model_object, :except => [:new, :create, :index, :preview] + before_filter :find_project_from_association, :except => [:new, :create, :index, :preview] + before_filter :find_project, :only => [:new, :create, :preview] before_filter :authorize, :except => [:index, :preview] before_filter :find_optional_project, :only => :index accept_key_auth :index @@ -46,11 +46,17 @@ class NewsController < ApplicationController def new @news = News.new(:project => @project, :author => User.current) + end + + def create + @news = News.new(:project => @project, :author => User.current) if request.post? @news.attributes = params[:news] if @news.save flash[:notice] = l(:notice_successful_create) redirect_to :controller => 'news', :action => 'index', :project_id => @project + else + render :action => 'new' end end end diff --git a/app/views/news/index.rhtml b/app/views/news/index.rhtml index 41e8bb355..2b53b7f72 100644 --- a/app/views/news/index.rhtml +++ b/app/views/news/index.rhtml @@ -7,7 +7,7 @@