OSDN Git Service

Refactor: rename UsersController#add to #new
authorEric Davis <edavis@littlestreamsoftware.com>
Wed, 29 Sep 2010 16:00:45 +0000 (16:00 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Wed, 29 Sep 2010 16:00:45 +0000 (16:00 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4229 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/users_controller.rb
app/views/users/index.rhtml
app/views/users/new.html.erb [moved from app/views/users/add.rhtml with 100% similarity]
config/routes.rb
test/functional/users_controller_test.rb
test/integration/admin_test.rb
test/integration/routing_test.rb

index 3fb1110..1fd8347 100644 (file)
@@ -71,7 +71,7 @@ class UsersController < ApplicationController
     render_404
   end
 
-  def add
+  def new
     @notification_options = User::MAIL_NOTIFICATION_OPTIONS
     @notification_option = Setting.default_notification_option
 
@@ -100,14 +100,14 @@ class UsersController < ApplicationController
 
       Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
       flash[:notice] = l(:notice_successful_create)
-      redirect_to(params[:continue] ? {:controller => 'users', :action => 'add'} : 
+      redirect_to(params[:continue] ? {:controller => 'users', :action => 'new'} : 
                                       {:controller => 'users', :action => 'edit', :id => @user})
       return
     else
       @auth_sources = AuthSource.find(:all)
       @notification_option = @user.mail_notification
 
-      render :action => 'add'
+      render :action => 'new'
     end
   end
 
index 1b47028..8046789 100644 (file)
@@ -1,5 +1,5 @@
 <div class="contextual">
-<%= link_to l(:label_user_new), {:action => 'add'}, :class => 'icon icon-add' %>
+<%= link_to l(:label_user_new), {:action => 'new'}, :class => 'icon icon-add' %>
 </div>
 
 <h2><%=l(:label_user_plural)%></h2>
index 0e60c55..d9c22d6 100644 (file)
@@ -143,11 +143,10 @@ ActionController::Routing::Routes.draw do |map|
     users.with_options :conditions => {:method => :get} do |user_views|
       user_views.connect 'users', :action => 'index'
       user_views.connect 'users/:id', :action => 'show', :id => /\d+/
-      user_views.connect 'users/new', :action => 'add'
+      user_views.connect 'users/new', :action => 'new'
       user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil
     end
     users.with_options :conditions => {:method => :post} do |user_actions|
-      user_actions.connect 'users', :action => 'add'
       user_actions.connect 'users/new', :action => 'create'
       user_actions.connect 'users/:id/edit', :action => 'edit'
       user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
index 6131c7e..577f54b 100644 (file)
@@ -107,14 +107,14 @@ class UsersControllerTest < ActionController::TestCase
     assert project_ids.include?(2) #private project admin can see
   end
 
-  context "GET :add" do
+  context "GET :new" do
     setup do
-      get :add
+      get :new
     end
 
     should_assign_to :user
     should_respond_with :success
-    should_render_template :add
+    should_render_template :new
   end
 
   context "POST :create" do
@@ -148,7 +148,7 @@ class UsersControllerTest < ActionController::TestCase
 
       should_assign_to :user
       should_respond_with :success
-      should_render_template :add
+      should_render_template :new
     end
 
   end
index 62ddc53..dd52859 100644 (file)
@@ -22,9 +22,9 @@ class AdminTest < ActionController::IntegrationTest
 
   def test_add_user
     log_user("admin", "admin")
-    get "/users/add"
+    get "/users/new"
     assert_response :success
-    assert_template "users/add"
+    assert_template "users/new"
     post "/users/create", :user => { :login => "psmith", :firstname => "Paul", :lastname => "Smith", :mail => "psmith@somenet.foo", :language => "en" }, :password => "psmith09", :password_confirmation => "psmith09"
     
     user = User.find_by_login("psmith")
index 74b7d99..341efe3 100644 (file)
@@ -246,7 +246,7 @@ class RoutingTest < ActionController::IntegrationTest
   context "users" do
     should_route :get, "/users", :controller => 'users', :action => 'index'
     should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
-    should_route :get, "/users/new", :controller => 'users', :action => 'add'
+    should_route :get, "/users/new", :controller => 'users', :action => 'new'
     should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
     should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'