Skip to content

Commit

Permalink
Refactor: rename method ProjectsController#add to ProjectsController#new
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4069 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Sep 7, 2010
1 parent 06878e5 commit 2295b61
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 19 deletions.
11 changes: 5 additions & 6 deletions app/controllers/projects_controller.rb
Expand Up @@ -20,9 +20,9 @@ class ProjectsController < ApplicationController
menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings

before_filter :find_project, :except => [ :index, :list, :add, :create, :copy ]
before_filter :authorize, :except => [ :index, :list, :add, :create, :copy, :archive, :unarchive, :destroy]
before_filter :authorize_global, :only => [:add, :create]
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
before_filter :authorize_global, :only => [:new, :create]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
accept_key_auth :index

Expand Down Expand Up @@ -60,8 +60,7 @@ def index
end
end

# Add a new project
def add
def new
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@trackers = Tracker.all
@project = Project.new(params[:project])
Expand Down Expand Up @@ -95,7 +94,7 @@ def create
end
else
respond_to do |format|
format.html { render :action => 'add' }
format.html { render :action => 'new' }
format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/projects.rhtml
@@ -1,5 +1,5 @@
<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>

<h2><%=l(:label_project_plural)%></h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/index.rhtml
Expand Up @@ -3,7 +3,7 @@
<% end %>

<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_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' }%>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -177,7 +177,7 @@
projects.with_options :conditions => {:method => :get} do |project_views|
project_views.connect 'projects', :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.:format', :action => 'show'
project_views.connect 'projects/:id/:action', :action => /destroy|settings/
Expand Down
4 changes: 2 additions & 2 deletions lib/redmine.rb
Expand Up @@ -46,12 +46,12 @@
Redmine::AccessControl.map do |map|
map.permission :view_project, {:projects => [:show], :activities => [: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 :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_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|
# Issue categories
Expand Down
14 changes: 7 additions & 7 deletions test/functional/projects_controller_test.rb
Expand Up @@ -87,16 +87,16 @@ def test_index_atom
end
end

context "#add" do
context "#new" do
context "by admin user" do
setup do
@request.session[:user_id] = 1
end

should "accept get" do
get :add
get :new
assert_response :success
assert_template 'add'
assert_template 'new'
end

end
Expand All @@ -108,9 +108,9 @@ def test_index_atom
end

should "accept get" do
get :add
get :new
assert_response :success
assert_template 'add'
assert_template 'new'
assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}
end
end
Expand All @@ -123,9 +123,9 @@ def test_index_atom
end

should "accept get" do
get :add, :parent_id => 'ecookbook'
get :new, :parent_id => 'ecookbook'
assert_response :success
assert_template 'add'
assert_template 'new'
# parent project selected
assert_tag :select, :attributes => {:name => 'project[parent_id]'},
:child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routing_test.rb
Expand Up @@ -166,7 +166,7 @@ class RoutingTest < ActionController::IntegrationTest
should_route :get, "/projects", :controller => 'projects', :action => 'index'
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/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/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
Expand Down

0 comments on commit 2295b61

Please sign in to comment.