Refactor: rename method ProjectsController#add to ProjectsController#new
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4069 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
06878e5004
commit
2295b61cb6
|
@ -20,9 +20,9 @@ class ProjectsController < ApplicationController
|
||||||
menu_item :roadmap, :only => :roadmap
|
menu_item :roadmap, :only => :roadmap
|
||||||
menu_item :settings, :only => :settings
|
menu_item :settings, :only => :settings
|
||||||
|
|
||||||
before_filter :find_project, :except => [ :index, :list, :add, :create, :copy ]
|
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
|
||||||
before_filter :authorize, :except => [ :index, :list, :add, :create, :copy, :archive, :unarchive, :destroy]
|
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
||||||
before_filter :authorize_global, :only => [:add, :create]
|
before_filter :authorize_global, :only => [:new, :create]
|
||||||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
||||||
accept_key_auth :index
|
accept_key_auth :index
|
||||||
|
|
||||||
|
@ -60,8 +60,7 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new project
|
def new
|
||||||
def add
|
|
||||||
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||||||
@trackers = Tracker.all
|
@trackers = Tracker.all
|
||||||
@project = Project.new(params[:project])
|
@project = Project.new(params[:project])
|
||||||
|
@ -95,7 +94,7 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'add' }
|
format.html { render :action => 'new' }
|
||||||
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
|
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'add'}, :class => 'icon icon-add' %>
|
<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2><%=l(:label_project_plural)%></h2>
|
<h2><%=l(:label_project_plural)%></h2>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'add'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %>
|
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %>
|
||||||
<%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %>
|
<%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %>
|
||||||
<%= link_to(l(:label_overall_spent_time), { :controller => 'time_entries' }) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %>
|
<%= link_to(l(:label_overall_spent_time), { :controller => 'time_entries' }) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %>
|
||||||
<%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%>
|
<%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%>
|
||||||
|
|
|
@ -177,7 +177,7 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
projects.with_options :conditions => {:method => :get} do |project_views|
|
projects.with_options :conditions => {:method => :get} do |project_views|
|
||||||
project_views.connect 'projects', :action => 'index'
|
project_views.connect 'projects', :action => 'index'
|
||||||
project_views.connect 'projects.:format', :action => 'index'
|
project_views.connect 'projects.:format', :action => 'index'
|
||||||
project_views.connect 'projects/new', :action => 'add'
|
project_views.connect 'projects/new', :action => 'new'
|
||||||
project_views.connect 'projects/:id', :action => 'show'
|
project_views.connect 'projects/:id', :action => 'show'
|
||||||
project_views.connect 'projects/:id.:format', :action => 'show'
|
project_views.connect 'projects/:id.:format', :action => 'show'
|
||||||
project_views.connect 'projects/:id/:action', :action => /destroy|settings/
|
project_views.connect 'projects/:id/:action', :action => /destroy|settings/
|
||||||
|
|
|
@ -46,12 +46,12 @@ end
|
||||||
Redmine::AccessControl.map do |map|
|
Redmine::AccessControl.map do |map|
|
||||||
map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true
|
map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true
|
||||||
map.permission :search_project, {:search => :index}, :public => true
|
map.permission :search_project, {:search => :index}, :public => true
|
||||||
map.permission :add_project, {:projects => [:add, :create]}, :require => :loggedin
|
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
|
||||||
map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
|
map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
|
||||||
map.permission :select_project_modules, {:projects => :modules}, :require => :member
|
map.permission :select_project_modules, {:projects => :modules}, :require => :member
|
||||||
map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
|
map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
|
||||||
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member
|
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member
|
||||||
map.permission :add_subprojects, {:projects => [:add, :create]}, :require => :member
|
map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
|
||||||
|
|
||||||
map.project_module :issue_tracking do |map|
|
map.project_module :issue_tracking do |map|
|
||||||
# Issue categories
|
# Issue categories
|
||||||
|
|
|
@ -87,16 +87,16 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#add" do
|
context "#new" do
|
||||||
context "by admin user" do
|
context "by admin user" do
|
||||||
setup do
|
setup do
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
should "accept get" do
|
should "accept get" do
|
||||||
get :add
|
get :new
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'add'
|
assert_template 'new'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -108,9 +108,9 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "accept get" do
|
should "accept get" do
|
||||||
get :add
|
get :new
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'add'
|
assert_template 'new'
|
||||||
assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}
|
assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -123,9 +123,9 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "accept get" do
|
should "accept get" do
|
||||||
get :add, :parent_id => 'ecookbook'
|
get :new, :parent_id => 'ecookbook'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'add'
|
assert_template 'new'
|
||||||
# parent project selected
|
# parent project selected
|
||||||
assert_tag :select, :attributes => {:name => 'project[parent_id]'},
|
assert_tag :select, :attributes => {:name => 'project[parent_id]'},
|
||||||
:child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
|
:child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
|
||||||
|
|
|
@ -166,7 +166,7 @@ class RoutingTest < ActionController::IntegrationTest
|
||||||
should_route :get, "/projects", :controller => 'projects', :action => 'index'
|
should_route :get, "/projects", :controller => 'projects', :action => 'index'
|
||||||
should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
|
should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
|
||||||
should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
|
should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
|
||||||
should_route :get, "/projects/new", :controller => 'projects', :action => 'add'
|
should_route :get, "/projects/new", :controller => 'projects', :action => 'new'
|
||||||
should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
|
should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
|
||||||
should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
|
should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
|
||||||
should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
|
should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
|
||||||
|
|
Loading…
Reference in New Issue