@@ -1,97 +1,97 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class IssueRelationsController < ApplicationController |
|
18 | class IssueRelationsController < ApplicationController | |
19 | before_filter :find_issue, :find_project_from_association, :authorize, :only => [:index, :create] |
|
19 | before_filter :find_issue, :find_project_from_association, :authorize, :only => [:index, :create] | |
20 | before_filter :find_relation, :except => [:index, :create] |
|
20 | before_filter :find_relation, :except => [:index, :create] | |
21 |
|
21 | |||
22 | accept_api_auth :index, :show, :create, :destroy |
|
22 | accept_api_auth :index, :show, :create, :destroy | |
23 |
|
23 | |||
24 | def index |
|
24 | def index | |
25 | @relations = @issue.relations |
|
25 | @relations = @issue.relations | |
26 |
|
26 | |||
27 | respond_to do |format| |
|
27 | respond_to do |format| | |
28 | format.html { render :nothing => true } |
|
28 | format.html { render :nothing => true } | |
29 | format.api |
|
29 | format.api | |
30 | end |
|
30 | end | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def show |
|
33 | def show | |
34 | raise Unauthorized unless @relation.visible? |
|
34 | raise Unauthorized unless @relation.visible? | |
35 |
|
35 | |||
36 | respond_to do |format| |
|
36 | respond_to do |format| | |
37 | format.html { render :nothing => true } |
|
37 | format.html { render :nothing => true } | |
38 | format.api |
|
38 | format.api | |
39 | end |
|
39 | end | |
40 | end |
|
40 | end | |
41 |
|
41 | |||
42 | verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } |
|
42 | verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } | |
43 | def create |
|
43 | def create | |
44 | @relation = IssueRelation.new(params[:relation]) |
|
44 | @relation = IssueRelation.new(params[:relation]) | |
45 | @relation.issue_from = @issue |
|
45 | @relation.issue_from = @issue | |
46 | if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/) |
|
46 | if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/) | |
47 | @relation.issue_to = Issue.visible.find_by_id(m[1].to_i) |
|
47 | @relation.issue_to = Issue.visible.find_by_id(m[1].to_i) | |
48 | end |
|
48 | end | |
49 | saved = @relation.save |
|
49 | saved = @relation.save | |
50 |
|
50 | |||
51 | respond_to do |format| |
|
51 | respond_to do |format| | |
52 | format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } |
|
52 | format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } | |
53 | format.js do |
|
53 | format.js do | |
54 | @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } |
|
54 | @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } | |
55 | render :update do |page| |
|
55 | render :update do |page| | |
56 | page.replace_html "relations", :partial => 'issues/relations' |
|
56 | page.replace_html "relations", :partial => 'issues/relations' | |
57 | if @relation.errors.empty? |
|
57 | if @relation.errors.empty? | |
58 | page << "$('relation_delay').value = ''" |
|
58 | page << "$('relation_delay').value = ''" | |
59 | page << "$('relation_issue_to_id').value = ''" |
|
59 | page << "$('relation_issue_to_id').value = ''" | |
60 | end |
|
60 | end | |
61 | end |
|
61 | end | |
62 | end |
|
62 | end | |
63 | format.api { |
|
63 | format.api { | |
64 | if saved |
|
64 | if saved | |
65 | render :action => 'show', :status => :created, :location => relation_url(@relation) |
|
65 | render :action => 'show', :status => :created, :location => relation_url(@relation) | |
66 | else |
|
66 | else | |
67 | render_validation_errors(@relation) |
|
67 | render_validation_errors(@relation) | |
68 | end |
|
68 | end | |
69 | } |
|
69 | } | |
70 | end |
|
70 | end | |
71 | end |
|
71 | end | |
72 |
|
72 | |||
73 | verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed } |
|
73 | verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed } | |
74 | def destroy |
|
74 | def destroy | |
75 | raise Unauthorized unless @relation.deletable? |
|
75 | raise Unauthorized unless @relation.deletable? | |
76 | @relation.destroy |
|
76 | @relation.destroy | |
77 |
|
77 | |||
78 | respond_to do |format| |
|
78 | respond_to do |format| | |
79 | format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } |
|
79 | format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to? | |
80 | format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} } |
|
80 | format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} } | |
81 | format.api { head :ok } |
|
81 | format.api { head :ok } | |
82 | end |
|
82 | end | |
83 | end |
|
83 | end | |
84 |
|
84 | |||
85 | private |
|
85 | private | |
86 | def find_issue |
|
86 | def find_issue | |
87 | @issue = @object = Issue.find(params[:issue_id]) |
|
87 | @issue = @object = Issue.find(params[:issue_id]) | |
88 | rescue ActiveRecord::RecordNotFound |
|
88 | rescue ActiveRecord::RecordNotFound | |
89 | render_404 |
|
89 | render_404 | |
90 | end |
|
90 | end | |
91 |
|
91 | |||
92 | def find_relation |
|
92 | def find_relation | |
93 | @relation = IssueRelation.find(params[:id]) |
|
93 | @relation = IssueRelation.find(params[:id]) | |
94 | rescue ActiveRecord::RecordNotFound |
|
94 | rescue ActiveRecord::RecordNotFound | |
95 | render_404 |
|
95 | render_404 | |
96 | end |
|
96 | end | |
97 | end |
|
97 | end |
@@ -1,36 +1,36 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to l(:label_personalize_page), :action => 'page_layout' %> |
|
2 | <%= link_to l(:label_personalize_page), :action => 'page_layout' %> | |
3 | </div> |
|
3 | </div> | |
4 |
|
4 | |||
5 | <h2><%=l(:label_my_page)%></h2> |
|
5 | <h2><%=l(:label_my_page)%></h2> | |
6 |
|
6 | |||
7 | <div id="list-top"> |
|
7 | <div id="list-top"> | |
8 | <% @blocks['top'].each do |b| |
|
8 | <% @blocks['top'].each do |b| | |
9 | next unless MyController::BLOCKS.keys.include? b %> |
|
9 | next unless MyController::BLOCKS.keys.include? b %> | |
10 | <div class="mypage-box"> |
|
10 | <div class="mypage-box"> | |
11 | <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> |
|
11 | <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> | |
12 | </div> |
|
12 | </div> | |
13 | <% end if @blocks['top'] %> |
|
13 | <% end if @blocks['top'] %> | |
14 | </div> |
|
14 | </div> | |
15 |
|
15 | |||
16 | <div id="list-left" class="splitcontentleft"> |
|
16 | <div id="list-left" class="splitcontentleft"> | |
17 | <% @blocks['left'].each do |b| |
|
17 | <% @blocks['left'].each do |b| | |
18 | next unless MyController::BLOCKS.keys.include? b %> |
|
18 | next unless MyController::BLOCKS.keys.include? b %> | |
19 | <div class="mypage-box"> |
|
19 | <div class="mypage-box"> | |
20 | <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> |
|
20 | <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> | |
21 | </div> |
|
21 | </div> | |
22 | <% end if @blocks['left'] %> |
|
22 | <% end if @blocks['left'] %> | |
23 | </div> |
|
23 | </div> | |
24 |
|
24 | |||
25 | <div id="list-right" class="splitcontentright"> |
|
25 | <div id="list-right" class="splitcontentright"> | |
26 | <% @blocks['right'].each do |b| |
|
26 | <% @blocks['right'].each do |b| | |
27 | next unless MyController::BLOCKS.keys.include? b %> |
|
27 | next unless MyController::BLOCKS.keys.include? b %> | |
28 | <div class="mypage-box"> |
|
28 | <div class="mypage-box"> | |
29 | <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> |
|
29 | <%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %> | |
30 | </div> |
|
30 | </div> | |
31 | <% end if @blocks['right'] %> |
|
31 | <% end if @blocks['right'] %> | |
32 | </div> |
|
32 | </div> | |
33 |
|
33 | |||
34 |
<%= context_menu |
|
34 | <%= context_menu issues_context_menu_path %> | |
35 |
|
35 | |||
36 | <% html_title(l(:label_my_page)) -%> |
|
36 | <% html_title(l(:label_my_page)) -%> |
@@ -1,26 +1,26 | |||||
1 | <% content_for :header_tags do %> |
|
1 | <% content_for :header_tags do %> | |
2 | <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> |
|
2 | <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> | |
3 | <% end %> |
|
3 | <% end %> | |
4 |
|
4 | |||
5 | <div class="contextual"> |
|
5 | <div class="contextual"> | |
6 | <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %> |
|
6 | <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %> | |
7 | <%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> |
|
7 | <%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> | |
8 |
<%= link_to(l(:label_overall_spent_time), |
|
8 | <%= link_to(l(:label_overall_spent_time), time_entries_path) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %> | |
9 | <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%> |
|
9 | <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%> | |
10 | </div> |
|
10 | </div> | |
11 |
|
11 | |||
12 | <h2><%=l(:label_project_plural)%></h2> |
|
12 | <h2><%=l(:label_project_plural)%></h2> | |
13 |
|
13 | |||
14 | <%= render_project_hierarchy(@projects)%> |
|
14 | <%= render_project_hierarchy(@projects)%> | |
15 |
|
15 | |||
16 | <% if User.current.logged? %> |
|
16 | <% if User.current.logged? %> | |
17 | <p style="text-align:right;"> |
|
17 | <p style="text-align:right;"> | |
18 | <span class="my-project"><%= l(:label_my_projects) %></span> |
|
18 | <span class="my-project"><%= l(:label_my_projects) %></span> | |
19 | </p> |
|
19 | </p> | |
20 | <% end %> |
|
20 | <% end %> | |
21 |
|
21 | |||
22 | <% other_formats_links do |f| %> |
|
22 | <% other_formats_links do |f| %> | |
23 | <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> |
|
23 | <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> | |
24 | <% end %> |
|
24 | <% end %> | |
25 |
|
25 | |||
26 | <% html_title(l(:label_project_plural)) -%> |
|
26 | <% html_title(l(:label_project_plural)) -%> |
@@ -1,191 +1,282 | |||||
1 | ActionController::Routing::Routes.draw do |map| |
|
1 | ActionController::Routing::Routes.draw do |map| | |
2 | # Add your own custom routes here. |
|
2 | # Add your own custom routes here. | |
3 | # The priority is based upon order of creation: first created -> highest priority. |
|
3 | # The priority is based upon order of creation: first created -> highest priority. | |
4 |
|
4 | |||
5 | # Here's a sample route: |
|
5 | # Here's a sample route: | |
6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
|
6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' | |
7 | # Keep in mind you can assign values other than :controller and :action |
|
7 | # Keep in mind you can assign values other than :controller and :action | |
8 |
|
8 | |||
9 | map.home '', :controller => 'welcome' |
|
9 | map.home '', :controller => 'welcome', :conditions => {:method => :get} | |
10 |
|
10 | |||
11 | map.signin 'login', :controller => 'account', :action => 'login' |
|
11 | map.signin 'login', :controller => 'account', :action => 'login', :conditions => {:method => [:get, :post]} | |
12 | map.signout 'logout', :controller => 'account', :action => 'logout' |
|
12 | map.signout 'logout', :controller => 'account', :action => 'logout', :conditions => {:method => :get} | |
|
13 | map.connect 'account/register', :controller => 'account', :action => 'register', :conditions => {:method => [:get, :post]} | |||
|
14 | map.connect 'account/lost_password', :controller => 'account', :action => 'lost_password', :conditions => {:method => [:get, :post]} | |||
|
15 | map.connect 'account/login', :controller => 'account', :action => 'login', :conditions => {:method => [:get, :post]} | |||
|
16 | map.connect 'account/logout', :controller => 'account', :action => 'logout', :conditions => {:method => :get} | |||
|
17 | map.connect 'account/activate', :controller => 'account', :action => 'activate', :conditions => {:method => :get} | |||
13 |
|
18 | |||
14 | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' |
|
19 | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' | |
15 | map.connect 'help/:ctrl/:page', :controller => 'help' |
|
|||
16 |
|
20 | |||
|
21 | map.connect 'help/:ctrl/:page', :controller => 'help', :conditions => {:method => :get} | |||
|
22 | ||||
|
23 | map.connect '/time_entries/destroy', | |||
|
24 | :controller => 'timelog', :action => 'destroy', :conditions => { :method => :delete } | |||
17 | map.time_entries_context_menu '/time_entries/context_menu', |
|
25 | map.time_entries_context_menu '/time_entries/context_menu', | |
18 | :controller => 'context_menus', :action => 'time_entries' |
|
26 | :controller => 'context_menus', :action => 'time_entries' | |
19 |
|
27 | |||
20 | map.resources :time_entries, :controller => 'timelog', :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post} |
|
28 | map.resources :time_entries, :controller => 'timelog', :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post} | |
21 |
|
29 | |||
22 | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} |
|
30 | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} | |
23 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} |
|
31 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => [:get, :post]} | |
24 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} |
|
|||
25 |
|
32 | |||
26 | map.with_options :controller => 'messages' do |messages_routes| |
|
33 | map.with_options :controller => 'messages' do |messages_routes| | |
27 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| |
|
34 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| | |
28 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' |
|
35 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' | |
29 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' |
|
36 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' | |
|
37 | messages_views.connect 'boards/:board_id/topics/quote/:id', :action => 'quote' | |||
30 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' |
|
38 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' | |
31 | end |
|
39 | end | |
32 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| |
|
40 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| | |
33 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' |
|
41 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' | |
|
42 | messages_actions.connect 'boards/:board_id/topics/preview', :action => 'preview' | |||
34 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' |
|
43 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' | |
35 | messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/ |
|
44 | messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/ | |
36 | end |
|
45 | end | |
37 | end |
|
46 | end | |
38 |
|
47 | |||
39 | map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move' |
|
48 | map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move' | |
40 | map.resources :queries, :except => [:show] |
|
49 | map.resources :queries, :except => [:show] | |
41 |
|
50 | |||
42 | # Misc issue routes. TODO: move into resources |
|
51 | # Misc issue routes. TODO: move into resources | |
43 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues', :conditions => { :method => :get } |
|
52 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues', :conditions => { :method => :get } | |
44 | map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview |
|
53 | map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview | |
45 | map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' |
|
54 | map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' | |
46 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' |
|
55 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' | |
47 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } |
|
56 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } | |
|
57 | map.connect '/journals/diff', :controller => 'journals', :action => 'diff' | |||
|
58 | map.connect '/journals/edit/:id', :controller => 'journals', :action => 'edit', :id => /\d+/, :conditions => { :method => [:get, :post] } | |||
48 |
|
59 | |||
49 | map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes| |
|
60 | map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes| | |
50 | gantts_routes.connect '/projects/:project_id/issues/gantt' |
|
61 | gantts_routes.connect '/projects/:project_id/issues/gantt' | |
51 | gantts_routes.connect '/projects/:project_id/issues/gantt.:format' |
|
62 | gantts_routes.connect '/projects/:project_id/issues/gantt.:format' | |
52 | gantts_routes.connect '/issues/gantt.:format' |
|
63 | gantts_routes.connect '/issues/gantt.:format' | |
53 | end |
|
64 | end | |
54 |
|
65 | |||
55 | map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes| |
|
66 | map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes| | |
56 | calendars_routes.connect '/projects/:project_id/issues/calendar' |
|
67 | calendars_routes.connect '/projects/:project_id/issues/calendar' | |
57 | calendars_routes.connect '/issues/calendar' |
|
68 | calendars_routes.connect '/issues/calendar' | |
58 | end |
|
69 | end | |
59 |
|
70 | |||
60 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| |
|
71 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| | |
61 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' |
|
72 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' | |
62 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' |
|
73 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' | |
63 | end |
|
74 | end | |
64 |
|
75 | |||
|
76 | map.connect 'my/account', :controller => 'my', :action => 'account', :conditions => {:method => [:get, :post]} | |||
|
77 | map.connect 'my/page', :controller => 'my', :action => 'page', :conditions => {:method => :get} | |||
|
78 | map.connect 'my', :controller => 'my', :action => 'index', :conditions => {:method => :get} # Redirects to my/page | |||
|
79 | map.connect 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :conditions => {:method => :post} | |||
|
80 | map.connect 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :conditions => {:method => :post} | |||
|
81 | map.connect 'my/password', :controller => 'my', :action => 'password', :conditions => {:method => [:get, :post]} | |||
|
82 | map.connect 'my/page_layout', :controller => 'my', :action => 'page_layout', :conditions => {:method => :get} | |||
|
83 | map.connect 'my/add_block', :controller => 'my', :action => 'add_block', :conditions => {:method => :post} | |||
|
84 | map.connect 'my/remove_block', :controller => 'my', :action => 'remove_block', :conditions => {:method => :post} | |||
|
85 | map.connect 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :conditions => {:method => :post} | |||
|
86 | ||||
65 | map.resources :issues, :collection => {:bulk_edit => :get, :bulk_update => :post} do |issues| |
|
87 | map.resources :issues, :collection => {:bulk_edit => :get, :bulk_update => :post} do |issues| | |
66 | issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get} |
|
88 | issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get} | |
67 | issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy] |
|
89 | issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy] | |
68 | end |
|
90 | end | |
69 | # Bulk deletion |
|
91 | # Bulk deletion | |
70 | map.connect '/issues', :controller => 'issues', :action => 'destroy', :conditions => {:method => :delete} |
|
92 | map.connect '/issues', :controller => 'issues', :action => 'destroy', :conditions => {:method => :delete} | |
71 |
|
93 | |||
72 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' |
|
94 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new', :conditions => { :method => :post } | |
|
95 | map.connect 'members/edit/:id', :controller => 'members', :action => 'edit', :id => /\d+/, :conditions => { :method => :post } | |||
|
96 | map.connect 'members/destroy/:id', :controller => 'members', :action => 'destroy', :id => /\d+/, :conditions => { :method => :post } | |||
|
97 | map.connect 'members/autocomplete_for_member/:id', :controller => 'members', :action => 'autocomplete_for_member', :conditions => { :method => :post } | |||
73 |
|
98 | |||
74 | map.resources :users |
|
99 | map.resources :users | |
75 | map.with_options :controller => 'users' do |users| |
|
100 | map.with_options :controller => 'users' do |users| | |
76 | users.user_memberships 'users/:id/memberships', :action => 'edit_membership', :conditions => {:method => :post} |
|
101 | users.user_memberships 'users/:id/memberships', :action => 'edit_membership', :conditions => {:method => :post} | |
77 | users.user_membership 'users/:id/memberships/:membership_id', :action => 'edit_membership', :conditions => {:method => :put} |
|
102 | users.user_membership 'users/:id/memberships/:membership_id', :action => 'edit_membership', :conditions => {:method => :put} | |
78 | users.connect 'users/:id/memberships/:membership_id', :action => 'destroy_membership', :conditions => {:method => :delete} |
|
103 | users.connect 'users/:id/memberships/:membership_id', :action => 'destroy_membership', :conditions => {:method => :delete} | |
79 | end |
|
104 | end | |
80 |
|
105 | |||
81 | # For nice "roadmap" in the url for the index action |
|
106 | # For nice "roadmap" in the url for the index action | |
82 | map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' |
|
107 | map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' | |
83 |
|
108 | |||
84 | map.all_news 'news', :controller => 'news', :action => 'index' |
|
109 | map.all_news 'news', :controller => 'news', :action => 'index' | |
85 | map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index' |
|
110 | map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index' | |
86 | map.preview_news '/news/preview', :controller => 'previews', :action => 'news' |
|
111 | map.preview_news '/news/preview', :controller => 'previews', :action => 'news' | |
87 | map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post} |
|
112 | map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post} | |
88 | map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete} |
|
113 | map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete} | |
89 |
|
114 | |||
|
115 | map.connect 'watchers/new', :controller=> 'watchers', :action => 'new', :conditions => {:method => [:get, :post]} | |||
|
116 | map.connect 'watchers/destroy', :controller=> 'watchers', :action => 'destroy', :conditions => {:method => :post} | |||
|
117 | map.connect 'watchers/watch', :controller=> 'watchers', :action => 'watch', :conditions => {:method => :post} | |||
|
118 | map.connect 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch', :conditions => {:method => :post} | |||
|
119 | ||||
90 | map.resources :projects, :member => { |
|
120 | map.resources :projects, :member => { | |
91 | :copy => [:get, :post], |
|
121 | :copy => [:get, :post], | |
92 | :settings => :get, |
|
122 | :settings => :get, | |
93 | :modules => :post, |
|
123 | :modules => :post, | |
94 | :archive => :post, |
|
124 | :archive => :post, | |
95 | :unarchive => :post |
|
125 | :unarchive => :post | |
96 | } do |project| |
|
126 | } do |project| | |
97 | project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] |
|
127 | project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] | |
98 | project.resources :issues, :only => [:index, :new, :create] do |issues| |
|
128 | project.resources :issues, :only => [:index, :new, :create] do |issues| | |
99 | issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get} |
|
129 | issues.resources :time_entries, :controller => 'timelog', :collection => {:report => :get} | |
100 | end |
|
130 | end | |
101 | project.resources :files, :only => [:index, :new, :create] |
|
131 | project.resources :files, :only => [:index, :new, :create] | |
102 | project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post} |
|
132 | project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post} | |
103 | project.resources :news, :shallow => true |
|
133 | project.resources :news, :shallow => true | |
104 | project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id', :collection => {:report => :get} |
|
134 | project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id', :collection => {:report => :get} | |
105 | project.resources :queries, :only => [:new, :create] |
|
135 | project.resources :queries, :only => [:new, :create] | |
106 | project.resources :issue_categories, :shallow => true |
|
136 | project.resources :issue_categories, :shallow => true | |
107 | project.resources :documents, :shallow => true, :member => {:add_attachment => :post} |
|
137 | project.resources :documents, :shallow => true, :member => {:add_attachment => :post} | |
108 | project.resources :boards |
|
138 | project.resources :boards | |
109 |
|
139 | |||
110 | project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get} |
|
140 | project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get} | |
111 | project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get} |
|
141 | project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get} | |
112 | project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil |
|
142 | project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil | |
113 | project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff' |
|
143 | project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff' | |
114 | project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate' |
|
144 | project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate' | |
115 | project.resources :wiki, :except => [:new, :create], :member => { |
|
145 | project.resources :wiki, :except => [:new, :create], :member => { | |
116 | :rename => [:get, :post], |
|
146 | :rename => [:get, :post], | |
117 | :history => :get, |
|
147 | :history => :get, | |
118 | :preview => :any, |
|
148 | :preview => :any, | |
119 | :protect => :post, |
|
149 | :protect => :post, | |
120 | :add_attachment => :post |
|
150 | :add_attachment => :post | |
121 | }, :collection => { |
|
151 | }, :collection => { | |
122 | :export => :get, |
|
152 | :export => :get, | |
123 | :date_index => :get |
|
153 | :date_index => :get | |
124 | } |
|
154 | } | |
125 |
|
155 | |||
126 | end |
|
156 | end | |
127 |
|
157 | |||
128 | # TODO: port to be part of the resources route(s) |
|
158 | # TODO: port to be part of the resources route(s) | |
129 | map.with_options :controller => 'projects' do |project_mapper| |
|
159 | map.with_options :controller => 'projects' do |project_mapper| | |
130 | project_mapper.with_options :conditions => {:method => :get} do |project_views| |
|
160 | project_mapper.with_options :conditions => {:method => :get} do |project_views| | |
131 | project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings' |
|
161 | project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings' | |
132 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' |
|
162 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' | |
133 | end |
|
163 | end | |
134 | end |
|
164 | end | |
135 |
|
165 | |||
136 | map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| |
|
166 | map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| | |
137 | activity.connect 'projects/:id/activity' |
|
167 | activity.connect 'projects/:id/activity' | |
138 | activity.connect 'projects/:id/activity.:format' |
|
168 | activity.connect 'projects/:id/activity.:format' | |
139 | activity.connect 'activity', :id => nil |
|
169 | activity.connect 'activity', :id => nil | |
140 | activity.connect 'activity.:format', :id => nil |
|
170 | activity.connect 'activity.:format', :id => nil | |
141 | end |
|
171 | end | |
142 |
|
172 | |||
143 | map.with_options :controller => 'repositories' do |repositories| |
|
173 | map.with_options :controller => 'repositories' do |repositories| | |
144 | repositories.with_options :conditions => {:method => :get} do |repository_views| |
|
174 | repositories.with_options :conditions => {:method => :get} do |repository_views| | |
145 | repository_views.connect 'projects/:id/repository', :action => 'show' |
|
175 | repository_views.connect 'projects/:id/repository', :action => 'show' | |
146 | repository_views.connect 'projects/:id/repository/edit', :action => 'edit' |
|
176 | repository_views.connect 'projects/:id/repository/edit', :action => 'edit' | |
147 | repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' |
|
177 | repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' | |
148 | repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' |
|
178 | repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' | |
149 | repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' |
|
179 | repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' | |
150 | repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' |
|
180 | repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' | |
151 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' |
|
181 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' | |
152 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' |
|
182 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' | |
153 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
183 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } | |
154 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
184 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } | |
155 | repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' |
|
185 | repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' | |
156 | # TODO: why the following route is required? |
|
186 | repository_views.connect 'projects/:id/repository/browse/*path', :action => 'browse' | |
157 | repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' |
|
187 | repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' | |
158 |
repository_views.connect 'projects/:id/repository/ |
|
188 | repository_views.connect 'projects/:id/repository/changes/*path', :action => 'changes' | |
|
189 | repository_views.connect 'projects/:id/repository/annotate/*path', :action => 'annotate' | |||
|
190 | repository_views.connect 'projects/:id/repository/diff/*path', :action => 'diff' | |||
|
191 | repository_views.connect 'projects/:id/repository/graph', :action => 'graph' | |||
|
192 | # repository_views.connect 'projects/:id/repository/:action/*path' | |||
159 | end |
|
193 | end | |
160 |
|
194 | |||
161 | repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} |
|
195 | repositories.connect 'projects/:id/repository/revision', :action => 'revision', :conditions => {:method => [:get, :post]} | |
|
196 | repositories.connect 'projects/:id/repository/committers', :action => 'committers', :conditions => {:method => [:get, :post]} | |||
|
197 | repositories.connect 'projects/:id/repository/edit', :action => 'edit', :conditions => {:method => :post} | |||
|
198 | repositories.connect 'projects/:id/repository/destroy', :action => 'destroy', :conditions => {:method => :post} | |||
|
199 | # repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} | |||
162 | end |
|
200 | end | |
163 |
|
201 | |||
164 | map.resources :attachments, :only => [:show, :destroy] |
|
202 | map.resources :attachments, :only => [:show, :destroy] | |
165 | # additional routes for having the file name at the end of url |
|
203 | # additional routes for having the file name at the end of url | |
166 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ |
|
204 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ | |
167 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
205 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ | |
|
206 | map.connect 'attachments/download/:id', :controller => 'attachments', :action => 'download', :id => /\d+/ | |||
168 |
|
207 | |||
169 | map.resources :groups, :member => {:autocomplete_for_user => :get} |
|
208 | map.resources :groups, :member => {:autocomplete_for_user => :get} | |
170 | map.group_users 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :conditions => {:method => :post} |
|
209 | map.group_users 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :conditions => {:method => :post} | |
171 | map.group_user 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :conditions => {:method => :delete} |
|
210 | map.group_user 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :conditions => {:method => :delete} | |
|
211 | map.connect 'groups/add_users/:id', :controller => 'groups', :action => 'add_users', :id => /\d+/, :conditions => {:method => :post} | |||
|
212 | map.connect 'groups/remove_user/:id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :conditions => {:method => :post} | |||
|
213 | map.connect 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :conditions => {:method => :post} | |||
|
214 | map.connect 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :conditions => {:method => :post} | |||
172 |
|
215 | |||
173 | map.resources :trackers, :except => :show |
|
216 | map.resources :trackers, :except => :show | |
174 | map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post} |
|
217 | map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post} | |
175 | map.resources :custom_fields, :except => :show |
|
218 | map.resources :custom_fields, :except => :show | |
176 | map.resources :roles, :except => :show, :collection => {:permissions => [:get, :post]} |
|
219 | map.resources :roles, :except => :show, :collection => {:permissions => [:get, :post]} | |
177 |
|
220 | |||
178 | #left old routes at the bottom for backwards compat |
|
221 | map.connect 'custom_fields', :controller => 'custom_fields', :action => 'index', :conditions => {:method => :get} | |
179 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' |
|
222 | map.connect 'custom_fields/new', :controller => 'custom_fields', :action => 'new', :conditions => {:method => [:get, :post]} | |
|
223 | map.connect 'custom_fields/edit/:id', :controller => 'custom_fields', :action => 'edit', :id => /\d+/, :conditions => {:method => [:get, :post]} | |||
|
224 | map.connect 'custom_fields/destroy/:id', :controller => 'custom_fields', :action => 'destroy', :id => /\d+/, :conditions => {:method => :post} | |||
|
225 | ||||
|
226 | map.connect 'search', :controller => 'search', :action => 'index', :conditions => {:method => :get} | |||
|
227 | ||||
|
228 | map.connect 'mail_handler', :controller => 'mail_handler', :action => 'index', :conditions => {:method => :post} | |||
|
229 | ||||
|
230 | map.connect 'admin', :controller => 'admin', :action => 'index', :conditions => {:method => :get} | |||
|
231 | map.connect 'admin/projects', :controller => 'admin', :action => 'projects', :conditions => {:method => :get} | |||
|
232 | map.connect 'admin/plugins', :controller => 'admin', :action => 'plugins', :conditions => {:method => :get} | |||
|
233 | map.connect 'admin/info', :controller => 'admin', :action => 'info', :conditions => {:method => :get} | |||
|
234 | map.connect 'admin/test_email', :controller => 'admin', :action => 'test_email', :conditions => {:method => :get} | |||
|
235 | map.connect 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :conditions => {:method => :post} | |||
|
236 | ||||
|
237 | # Used by AuthSourcesControllerTest | |||
|
238 | # TODO : refactor *AuthSourcesController to remove these routes | |||
|
239 | map.connect 'auth_sources', :controller => 'auth_sources', :action => 'index', :conditions => {:method => :get} | |||
|
240 | map.connect 'auth_sources/new', :controller => 'auth_sources', :action => 'new', :conditions => {:method => :get} | |||
|
241 | map.connect 'auth_sources/create', :controller => 'auth_sources', :action => 'create', :conditions => {:method => :post} | |||
|
242 | map.connect 'auth_sources/destroy/:id', :controller => 'auth_sources', :action => 'destroy', :id => /\d+/, :conditions => {:method => :post} | |||
|
243 | map.connect 'auth_sources/test_connection/:id', :controller => 'auth_sources', :action => 'test_connection', :conditions => {:method => :get} | |||
|
244 | map.connect 'auth_sources/edit/:id', :controller => 'auth_sources', :action => 'edit', :id => /\d+/, :conditions => {:method => :get} | |||
|
245 | map.connect 'auth_sources/update/:id', :controller => 'auth_sources', :action => 'update', :id => /\d+/, :conditions => {:method => :post} | |||
|
246 | ||||
|
247 | map.connect 'ldap_auth_sources', :controller => 'ldap_auth_sources', :action => 'index', :conditions => {:method => :get} | |||
|
248 | map.connect 'ldap_auth_sources/new', :controller => 'ldap_auth_sources', :action => 'new', :conditions => {:method => :get} | |||
|
249 | map.connect 'ldap_auth_sources/create', :controller => 'ldap_auth_sources', :action => 'create', :conditions => {:method => :post} | |||
|
250 | map.connect 'ldap_auth_sources/destroy/:id', :controller => 'ldap_auth_sources', :action => 'destroy', :id => /\d+/, :conditions => {:method => :post} | |||
|
251 | map.connect 'ldap_auth_sources/test_connection/:id', :controller => 'ldap_auth_sources', :action => 'test_connection', :conditions => {:method => :get} | |||
|
252 | map.connect 'ldap_auth_sources/edit/:id', :controller => 'ldap_auth_sources', :action => 'edit', :id => /\d+/, :conditions => {:method => :get} | |||
|
253 | map.connect 'ldap_auth_sources/update/:id', :controller => 'ldap_auth_sources', :action => 'update', :id => /\d+/, :conditions => {:method => :post} | |||
|
254 | map.connect 'workflows', :controller => 'workflows', :action => 'index', :conditions => {:method => :get} | |||
|
255 | map.connect 'workflows/edit', :controller => 'workflows', :action => 'edit', :conditions => {:method => [:get, :post]} | |||
|
256 | map.connect 'workflows/copy', :controller => 'workflows', :action => 'copy', :conditions => {:method => [:get, :post]} | |||
|
257 | map.connect 'enumerations', :controller => 'enumerations', :action => 'index', :conditions => {:method => :get} | |||
|
258 | map.connect 'enumerations/new', :controller => 'enumerations', :action => 'new', :conditions => {:method => :get} | |||
|
259 | map.connect 'enumerations/create', :controller => 'enumerations', :action => 'create', :conditions => {:method => :post} | |||
|
260 | map.connect 'enumerations/edit/:id', :controller => 'enumerations', :action => 'edit', :id => /\d+/, :conditions => {:method => :get} | |||
|
261 | map.connect 'enumerations/update/:id', :controller => 'enumerations', :action => 'update', :id => /\d+/, :conditions => {:method => :post} | |||
|
262 | map.connect 'enumerations/destroy/:id', :controller => 'enumerations', :action => 'destroy', :id => /\d+/, :conditions => {:method => :post} | |||
|
263 | map.connect 'settings', :controller => 'settings', :action => 'index', :conditions => {:method => :get} | |||
|
264 | map.connect 'settings/edit', :controller => 'settings', :action => 'edit', :conditions => {:method => [:get, :post]} | |||
|
265 | map.connect 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :conditions => {:method => [:get, :post]} | |||
180 |
|
266 | |||
181 | map.with_options :controller => 'sys' do |sys| |
|
267 | map.with_options :controller => 'sys' do |sys| | |
182 | sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} |
|
268 | sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} | |
183 | sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} |
|
269 | sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} | |
|
270 | sys.connect 'sys/fetch_changesets', :action => 'fetch_changesets', :conditions => {:method => :get} | |||
184 | end |
|
271 | end | |
185 |
|
272 | |||
|
273 | #left old routes at the bottom for backwards compat | |||
|
274 | # map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' | |||
|
275 | ||||
186 | # Install the default route as the lowest priority. |
|
276 | # Install the default route as the lowest priority. | |
187 | map.connect ':controller/:action/:id' |
|
277 | # map.connect ':controller/:action/:id' | |
188 | map.connect 'robots.txt', :controller => 'welcome', :action => 'robots' |
|
278 | map.connect 'robots.txt', :controller => 'welcome', :action => 'robots', :conditions => {:method => :get} | |
|
279 | ||||
189 | # Used for OpenID |
|
280 | # Used for OpenID | |
190 | map.root :controller => 'account', :action => 'login' |
|
281 | map.root :controller => 'account', :action => 'login' | |
191 | end |
|
282 | end |
@@ -1,545 +1,538 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 | require 'projects_controller' |
|
19 | require 'projects_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class ProjectsController; def rescue_action(e) raise e end; end |
|
22 | class ProjectsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class ProjectsControllerTest < ActionController::TestCase |
|
24 | class ProjectsControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, |
|
25 | fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, | |
26 | :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, |
|
26 | :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, | |
27 | :attachments, :custom_fields, :custom_values, :time_entries |
|
27 | :attachments, :custom_fields, :custom_values, :time_entries | |
28 |
|
28 | |||
29 | def setup |
|
29 | def setup | |
30 | @controller = ProjectsController.new |
|
30 | @controller = ProjectsController.new | |
31 | @request = ActionController::TestRequest.new |
|
31 | @request = ActionController::TestRequest.new | |
32 | @response = ActionController::TestResponse.new |
|
32 | @response = ActionController::TestResponse.new | |
33 | @request.session[:user_id] = nil |
|
33 | @request.session[:user_id] = nil | |
34 | Setting.default_language = 'en' |
|
34 | Setting.default_language = 'en' | |
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | def test_index |
|
37 | def test_index | |
38 | get :index |
|
38 | get :index | |
39 | assert_response :success |
|
39 | assert_response :success | |
40 | assert_template 'index' |
|
40 | assert_template 'index' | |
41 | assert_not_nil assigns(:projects) |
|
41 | assert_not_nil assigns(:projects) | |
42 |
|
42 | |||
43 | assert_tag :ul, :child => {:tag => 'li', |
|
43 | assert_tag :ul, :child => {:tag => 'li', | |
44 | :descendant => {:tag => 'a', :content => 'eCookbook'}, |
|
44 | :descendant => {:tag => 'a', :content => 'eCookbook'}, | |
45 | :child => { :tag => 'ul', |
|
45 | :child => { :tag => 'ul', | |
46 | :descendant => { :tag => 'a', |
|
46 | :descendant => { :tag => 'a', | |
47 | :content => 'Child of private child' |
|
47 | :content => 'Child of private child' | |
48 | } |
|
48 | } | |
49 | } |
|
49 | } | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | assert_no_tag :a, :content => /Private child of eCookbook/ |
|
52 | assert_no_tag :a, :content => /Private child of eCookbook/ | |
53 | end |
|
53 | end | |
54 |
|
54 | |||
55 | def test_index_atom |
|
55 | def test_index_atom | |
56 | get :index, :format => 'atom' |
|
56 | get :index, :format => 'atom' | |
57 | assert_response :success |
|
57 | assert_response :success | |
58 | assert_template 'common/feed.atom' |
|
58 | assert_template 'common/feed.atom' | |
59 | assert_select 'feed>title', :text => 'Redmine: Latest projects' |
|
59 | assert_select 'feed>title', :text => 'Redmine: Latest projects' | |
60 | assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_condition(User.current)) |
|
60 | assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_condition(User.current)) | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
63 | context "#index" do |
|
63 | context "#index" do | |
64 | context "by non-admin user with view_time_entries permission" do |
|
64 | context "by non-admin user with view_time_entries permission" do | |
65 | setup do |
|
65 | setup do | |
66 | @request.session[:user_id] = 3 |
|
66 | @request.session[:user_id] = 3 | |
67 | end |
|
67 | end | |
68 | should "show overall spent time link" do |
|
68 | should "show overall spent time link" do | |
69 | get :index |
|
69 | get :index | |
70 | assert_template 'index' |
|
70 | assert_template 'index' | |
71 | assert_tag :a, :attributes => {:href => '/time_entries'} |
|
71 | assert_tag :a, :attributes => {:href => '/time_entries'} | |
72 | end |
|
72 | end | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | context "by non-admin user without view_time_entries permission" do |
|
75 | context "by non-admin user without view_time_entries permission" do | |
76 | setup do |
|
76 | setup do | |
77 | Role.find(2).remove_permission! :view_time_entries |
|
77 | Role.find(2).remove_permission! :view_time_entries | |
78 | Role.non_member.remove_permission! :view_time_entries |
|
78 | Role.non_member.remove_permission! :view_time_entries | |
79 | Role.anonymous.remove_permission! :view_time_entries |
|
79 | Role.anonymous.remove_permission! :view_time_entries | |
80 | @request.session[:user_id] = 3 |
|
80 | @request.session[:user_id] = 3 | |
81 | end |
|
81 | end | |
82 | should "not show overall spent time link" do |
|
82 | should "not show overall spent time link" do | |
83 | get :index |
|
83 | get :index | |
84 | assert_template 'index' |
|
84 | assert_template 'index' | |
85 | assert_no_tag :a, :attributes => {:href => '/time_entries'} |
|
85 | assert_no_tag :a, :attributes => {:href => '/time_entries'} | |
86 | end |
|
86 | end | |
87 | end |
|
87 | end | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
90 | context "#new" do |
|
90 | context "#new" do | |
91 | context "by admin user" do |
|
91 | context "by admin user" do | |
92 | setup do |
|
92 | setup do | |
93 | @request.session[:user_id] = 1 |
|
93 | @request.session[:user_id] = 1 | |
94 | end |
|
94 | end | |
95 |
|
95 | |||
96 | should "accept get" do |
|
96 | should "accept get" do | |
97 | get :new |
|
97 | get :new | |
98 | assert_response :success |
|
98 | assert_response :success | |
99 | assert_template 'new' |
|
99 | assert_template 'new' | |
100 | end |
|
100 | end | |
101 |
|
101 | |||
102 | end |
|
102 | end | |
103 |
|
103 | |||
104 | context "by non-admin user with add_project permission" do |
|
104 | context "by non-admin user with add_project permission" do | |
105 | setup do |
|
105 | setup do | |
106 | Role.non_member.add_permission! :add_project |
|
106 | Role.non_member.add_permission! :add_project | |
107 | @request.session[:user_id] = 9 |
|
107 | @request.session[:user_id] = 9 | |
108 | end |
|
108 | end | |
109 |
|
109 | |||
110 | should "accept get" do |
|
110 | should "accept get" do | |
111 | get :new |
|
111 | get :new | |
112 | assert_response :success |
|
112 | assert_response :success | |
113 | assert_template 'new' |
|
113 | assert_template 'new' | |
114 | assert_no_tag :select, :attributes => {:name => 'project[parent_id]'} |
|
114 | assert_no_tag :select, :attributes => {:name => 'project[parent_id]'} | |
115 | end |
|
115 | end | |
116 | end |
|
116 | end | |
117 |
|
117 | |||
118 | context "by non-admin user with add_subprojects permission" do |
|
118 | context "by non-admin user with add_subprojects permission" do | |
119 | setup do |
|
119 | setup do | |
120 | Role.find(1).remove_permission! :add_project |
|
120 | Role.find(1).remove_permission! :add_project | |
121 | Role.find(1).add_permission! :add_subprojects |
|
121 | Role.find(1).add_permission! :add_subprojects | |
122 | @request.session[:user_id] = 2 |
|
122 | @request.session[:user_id] = 2 | |
123 | end |
|
123 | end | |
124 |
|
124 | |||
125 | should "accept get" do |
|
125 | should "accept get" do | |
126 | get :new, :parent_id => 'ecookbook' |
|
126 | get :new, :parent_id => 'ecookbook' | |
127 | assert_response :success |
|
127 | assert_response :success | |
128 | assert_template 'new' |
|
128 | assert_template 'new' | |
129 | # parent project selected |
|
129 | # parent project selected | |
130 | assert_tag :select, :attributes => {:name => 'project[parent_id]'}, |
|
130 | assert_tag :select, :attributes => {:name => 'project[parent_id]'}, | |
131 | :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}} |
|
131 | :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}} | |
132 | # no empty value |
|
132 | # no empty value | |
133 | assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}, |
|
133 | assert_no_tag :select, :attributes => {:name => 'project[parent_id]'}, | |
134 | :child => {:tag => 'option', :attributes => {:value => ''}} |
|
134 | :child => {:tag => 'option', :attributes => {:value => ''}} | |
135 | end |
|
135 | end | |
136 | end |
|
136 | end | |
137 |
|
137 | |||
138 | end |
|
138 | end | |
139 |
|
139 | |||
140 | context "POST :create" do |
|
140 | context "POST :create" do | |
141 | context "by admin user" do |
|
141 | context "by admin user" do | |
142 | setup do |
|
142 | setup do | |
143 | @request.session[:user_id] = 1 |
|
143 | @request.session[:user_id] = 1 | |
144 | end |
|
144 | end | |
145 |
|
145 | |||
146 | should "create a new project" do |
|
146 | should "create a new project" do | |
147 | post :create, |
|
147 | post :create, | |
148 | :project => { |
|
148 | :project => { | |
149 | :name => "blog", |
|
149 | :name => "blog", | |
150 | :description => "weblog", |
|
150 | :description => "weblog", | |
151 | :homepage => 'http://weblog', |
|
151 | :homepage => 'http://weblog', | |
152 | :identifier => "blog", |
|
152 | :identifier => "blog", | |
153 | :is_public => 1, |
|
153 | :is_public => 1, | |
154 | :custom_field_values => { '3' => 'Beta' }, |
|
154 | :custom_field_values => { '3' => 'Beta' }, | |
155 | :tracker_ids => ['1', '3'], |
|
155 | :tracker_ids => ['1', '3'], | |
156 | # an issue custom field that is not for all project |
|
156 | # an issue custom field that is not for all project | |
157 | :issue_custom_field_ids => ['9'], |
|
157 | :issue_custom_field_ids => ['9'], | |
158 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] |
|
158 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] | |
159 | } |
|
159 | } | |
160 | assert_redirected_to '/projects/blog/settings' |
|
160 | assert_redirected_to '/projects/blog/settings' | |
161 |
|
161 | |||
162 | project = Project.find_by_name('blog') |
|
162 | project = Project.find_by_name('blog') | |
163 | assert_kind_of Project, project |
|
163 | assert_kind_of Project, project | |
164 | assert project.active? |
|
164 | assert project.active? | |
165 | assert_equal 'weblog', project.description |
|
165 | assert_equal 'weblog', project.description | |
166 | assert_equal 'http://weblog', project.homepage |
|
166 | assert_equal 'http://weblog', project.homepage | |
167 | assert_equal true, project.is_public? |
|
167 | assert_equal true, project.is_public? | |
168 | assert_nil project.parent |
|
168 | assert_nil project.parent | |
169 | assert_equal 'Beta', project.custom_value_for(3).value |
|
169 | assert_equal 'Beta', project.custom_value_for(3).value | |
170 | assert_equal [1, 3], project.trackers.map(&:id).sort |
|
170 | assert_equal [1, 3], project.trackers.map(&:id).sort | |
171 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort |
|
171 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort | |
172 | assert project.issue_custom_fields.include?(IssueCustomField.find(9)) |
|
172 | assert project.issue_custom_fields.include?(IssueCustomField.find(9)) | |
173 | end |
|
173 | end | |
174 |
|
174 | |||
175 | should "create a new subproject" do |
|
175 | should "create a new subproject" do | |
176 | post :create, :project => { :name => "blog", |
|
176 | post :create, :project => { :name => "blog", | |
177 | :description => "weblog", |
|
177 | :description => "weblog", | |
178 | :identifier => "blog", |
|
178 | :identifier => "blog", | |
179 | :is_public => 1, |
|
179 | :is_public => 1, | |
180 | :custom_field_values => { '3' => 'Beta' }, |
|
180 | :custom_field_values => { '3' => 'Beta' }, | |
181 | :parent_id => 1 |
|
181 | :parent_id => 1 | |
182 | } |
|
182 | } | |
183 | assert_redirected_to '/projects/blog/settings' |
|
183 | assert_redirected_to '/projects/blog/settings' | |
184 |
|
184 | |||
185 | project = Project.find_by_name('blog') |
|
185 | project = Project.find_by_name('blog') | |
186 | assert_kind_of Project, project |
|
186 | assert_kind_of Project, project | |
187 | assert_equal Project.find(1), project.parent |
|
187 | assert_equal Project.find(1), project.parent | |
188 | end |
|
188 | end | |
189 |
|
189 | |||
190 | should "continue" do |
|
190 | should "continue" do | |
191 | assert_difference 'Project.count' do |
|
191 | assert_difference 'Project.count' do | |
192 | post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue' |
|
192 | post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue' | |
193 | end |
|
193 | end | |
194 | assert_redirected_to '/projects/new?' |
|
194 | assert_redirected_to '/projects/new?' | |
195 | end |
|
195 | end | |
196 | end |
|
196 | end | |
197 |
|
197 | |||
198 | context "by non-admin user with add_project permission" do |
|
198 | context "by non-admin user with add_project permission" do | |
199 | setup do |
|
199 | setup do | |
200 | Role.non_member.add_permission! :add_project |
|
200 | Role.non_member.add_permission! :add_project | |
201 | @request.session[:user_id] = 9 |
|
201 | @request.session[:user_id] = 9 | |
202 | end |
|
202 | end | |
203 |
|
203 | |||
204 | should "accept create a Project" do |
|
204 | should "accept create a Project" do | |
205 | post :create, :project => { :name => "blog", |
|
205 | post :create, :project => { :name => "blog", | |
206 | :description => "weblog", |
|
206 | :description => "weblog", | |
207 | :identifier => "blog", |
|
207 | :identifier => "blog", | |
208 | :is_public => 1, |
|
208 | :is_public => 1, | |
209 | :custom_field_values => { '3' => 'Beta' }, |
|
209 | :custom_field_values => { '3' => 'Beta' }, | |
210 | :tracker_ids => ['1', '3'], |
|
210 | :tracker_ids => ['1', '3'], | |
211 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] |
|
211 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | assert_redirected_to '/projects/blog/settings' |
|
214 | assert_redirected_to '/projects/blog/settings' | |
215 |
|
215 | |||
216 | project = Project.find_by_name('blog') |
|
216 | project = Project.find_by_name('blog') | |
217 | assert_kind_of Project, project |
|
217 | assert_kind_of Project, project | |
218 | assert_equal 'weblog', project.description |
|
218 | assert_equal 'weblog', project.description | |
219 | assert_equal true, project.is_public? |
|
219 | assert_equal true, project.is_public? | |
220 | assert_equal [1, 3], project.trackers.map(&:id).sort |
|
220 | assert_equal [1, 3], project.trackers.map(&:id).sort | |
221 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort |
|
221 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort | |
222 |
|
222 | |||
223 | # User should be added as a project member |
|
223 | # User should be added as a project member | |
224 | assert User.find(9).member_of?(project) |
|
224 | assert User.find(9).member_of?(project) | |
225 | assert_equal 1, project.members.size |
|
225 | assert_equal 1, project.members.size | |
226 | end |
|
226 | end | |
227 |
|
227 | |||
228 | should "fail with parent_id" do |
|
228 | should "fail with parent_id" do | |
229 | assert_no_difference 'Project.count' do |
|
229 | assert_no_difference 'Project.count' do | |
230 | post :create, :project => { :name => "blog", |
|
230 | post :create, :project => { :name => "blog", | |
231 | :description => "weblog", |
|
231 | :description => "weblog", | |
232 | :identifier => "blog", |
|
232 | :identifier => "blog", | |
233 | :is_public => 1, |
|
233 | :is_public => 1, | |
234 | :custom_field_values => { '3' => 'Beta' }, |
|
234 | :custom_field_values => { '3' => 'Beta' }, | |
235 | :parent_id => 1 |
|
235 | :parent_id => 1 | |
236 | } |
|
236 | } | |
237 | end |
|
237 | end | |
238 | assert_response :success |
|
238 | assert_response :success | |
239 | project = assigns(:project) |
|
239 | project = assigns(:project) | |
240 | assert_kind_of Project, project |
|
240 | assert_kind_of Project, project | |
241 | assert_not_nil project.errors[:parent_id] |
|
241 | assert_not_nil project.errors[:parent_id] | |
242 | end |
|
242 | end | |
243 | end |
|
243 | end | |
244 |
|
244 | |||
245 | context "by non-admin user with add_subprojects permission" do |
|
245 | context "by non-admin user with add_subprojects permission" do | |
246 | setup do |
|
246 | setup do | |
247 | Role.find(1).remove_permission! :add_project |
|
247 | Role.find(1).remove_permission! :add_project | |
248 | Role.find(1).add_permission! :add_subprojects |
|
248 | Role.find(1).add_permission! :add_subprojects | |
249 | @request.session[:user_id] = 2 |
|
249 | @request.session[:user_id] = 2 | |
250 | end |
|
250 | end | |
251 |
|
251 | |||
252 | should "create a project with a parent_id" do |
|
252 | should "create a project with a parent_id" do | |
253 | post :create, :project => { :name => "blog", |
|
253 | post :create, :project => { :name => "blog", | |
254 | :description => "weblog", |
|
254 | :description => "weblog", | |
255 | :identifier => "blog", |
|
255 | :identifier => "blog", | |
256 | :is_public => 1, |
|
256 | :is_public => 1, | |
257 | :custom_field_values => { '3' => 'Beta' }, |
|
257 | :custom_field_values => { '3' => 'Beta' }, | |
258 | :parent_id => 1 |
|
258 | :parent_id => 1 | |
259 | } |
|
259 | } | |
260 | assert_redirected_to '/projects/blog/settings' |
|
260 | assert_redirected_to '/projects/blog/settings' | |
261 | project = Project.find_by_name('blog') |
|
261 | project = Project.find_by_name('blog') | |
262 | end |
|
262 | end | |
263 |
|
263 | |||
264 | should "fail without parent_id" do |
|
264 | should "fail without parent_id" do | |
265 | assert_no_difference 'Project.count' do |
|
265 | assert_no_difference 'Project.count' do | |
266 | post :create, :project => { :name => "blog", |
|
266 | post :create, :project => { :name => "blog", | |
267 | :description => "weblog", |
|
267 | :description => "weblog", | |
268 | :identifier => "blog", |
|
268 | :identifier => "blog", | |
269 | :is_public => 1, |
|
269 | :is_public => 1, | |
270 | :custom_field_values => { '3' => 'Beta' } |
|
270 | :custom_field_values => { '3' => 'Beta' } | |
271 | } |
|
271 | } | |
272 | end |
|
272 | end | |
273 | assert_response :success |
|
273 | assert_response :success | |
274 | project = assigns(:project) |
|
274 | project = assigns(:project) | |
275 | assert_kind_of Project, project |
|
275 | assert_kind_of Project, project | |
276 | assert_not_nil project.errors[:parent_id] |
|
276 | assert_not_nil project.errors[:parent_id] | |
277 | end |
|
277 | end | |
278 |
|
278 | |||
279 | should "fail with unauthorized parent_id" do |
|
279 | should "fail with unauthorized parent_id" do | |
280 | assert !User.find(2).member_of?(Project.find(6)) |
|
280 | assert !User.find(2).member_of?(Project.find(6)) | |
281 | assert_no_difference 'Project.count' do |
|
281 | assert_no_difference 'Project.count' do | |
282 | post :create, :project => { :name => "blog", |
|
282 | post :create, :project => { :name => "blog", | |
283 | :description => "weblog", |
|
283 | :description => "weblog", | |
284 | :identifier => "blog", |
|
284 | :identifier => "blog", | |
285 | :is_public => 1, |
|
285 | :is_public => 1, | |
286 | :custom_field_values => { '3' => 'Beta' }, |
|
286 | :custom_field_values => { '3' => 'Beta' }, | |
287 | :parent_id => 6 |
|
287 | :parent_id => 6 | |
288 | } |
|
288 | } | |
289 | end |
|
289 | end | |
290 | assert_response :success |
|
290 | assert_response :success | |
291 | project = assigns(:project) |
|
291 | project = assigns(:project) | |
292 | assert_kind_of Project, project |
|
292 | assert_kind_of Project, project | |
293 | assert_not_nil project.errors[:parent_id] |
|
293 | assert_not_nil project.errors[:parent_id] | |
294 | end |
|
294 | end | |
295 | end |
|
295 | end | |
296 | end |
|
296 | end | |
297 |
|
297 | |||
298 | def test_create_should_preserve_modules_on_validation_failure |
|
298 | def test_create_should_preserve_modules_on_validation_failure | |
299 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do |
|
299 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do | |
300 | @request.session[:user_id] = 1 |
|
300 | @request.session[:user_id] = 1 | |
301 | assert_no_difference 'Project.count' do |
|
301 | assert_no_difference 'Project.count' do | |
302 | post :create, :project => { |
|
302 | post :create, :project => { | |
303 | :name => "blog", |
|
303 | :name => "blog", | |
304 | :identifier => "", |
|
304 | :identifier => "", | |
305 | :enabled_module_names => %w(issue_tracking news) |
|
305 | :enabled_module_names => %w(issue_tracking news) | |
306 | } |
|
306 | } | |
307 | end |
|
307 | end | |
308 | assert_response :success |
|
308 | assert_response :success | |
309 | project = assigns(:project) |
|
309 | project = assigns(:project) | |
310 | assert_equal %w(issue_tracking news), project.enabled_module_names.sort |
|
310 | assert_equal %w(issue_tracking news), project.enabled_module_names.sort | |
311 | end |
|
311 | end | |
312 | end |
|
312 | end | |
313 |
|
313 | |||
314 | def test_create_should_not_accept_get |
|
314 | def test_create_should_not_accept_get | |
315 | @request.session[:user_id] = 1 |
|
315 | @request.session[:user_id] = 1 | |
316 | get :create |
|
316 | get :create | |
317 | assert_response :method_not_allowed |
|
317 | assert_response :method_not_allowed | |
318 | end |
|
318 | end | |
319 |
|
319 | |||
320 | def test_show_by_id |
|
320 | def test_show_by_id | |
321 | get :show, :id => 1 |
|
321 | get :show, :id => 1 | |
322 | assert_response :success |
|
322 | assert_response :success | |
323 | assert_template 'show' |
|
323 | assert_template 'show' | |
324 | assert_not_nil assigns(:project) |
|
324 | assert_not_nil assigns(:project) | |
325 | end |
|
325 | end | |
326 |
|
326 | |||
327 | def test_show_by_identifier |
|
327 | def test_show_by_identifier | |
328 | get :show, :id => 'ecookbook' |
|
328 | get :show, :id => 'ecookbook' | |
329 | assert_response :success |
|
329 | assert_response :success | |
330 | assert_template 'show' |
|
330 | assert_template 'show' | |
331 | assert_not_nil assigns(:project) |
|
331 | assert_not_nil assigns(:project) | |
332 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
332 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
333 |
|
333 | |||
334 | assert_tag 'li', :content => /Development status/ |
|
334 | assert_tag 'li', :content => /Development status/ | |
335 | end |
|
335 | end | |
336 |
|
336 | |||
337 | def test_show_should_not_display_hidden_custom_fields |
|
337 | def test_show_should_not_display_hidden_custom_fields | |
338 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false |
|
338 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false | |
339 | get :show, :id => 'ecookbook' |
|
339 | get :show, :id => 'ecookbook' | |
340 | assert_response :success |
|
340 | assert_response :success | |
341 | assert_template 'show' |
|
341 | assert_template 'show' | |
342 | assert_not_nil assigns(:project) |
|
342 | assert_not_nil assigns(:project) | |
343 |
|
343 | |||
344 | assert_no_tag 'li', :content => /Development status/ |
|
344 | assert_no_tag 'li', :content => /Development status/ | |
345 | end |
|
345 | end | |
346 |
|
346 | |||
347 | def test_show_should_not_fail_when_custom_values_are_nil |
|
347 | def test_show_should_not_fail_when_custom_values_are_nil | |
348 | project = Project.find_by_identifier('ecookbook') |
|
348 | project = Project.find_by_identifier('ecookbook') | |
349 | project.custom_values.first.update_attribute(:value, nil) |
|
349 | project.custom_values.first.update_attribute(:value, nil) | |
350 | get :show, :id => 'ecookbook' |
|
350 | get :show, :id => 'ecookbook' | |
351 | assert_response :success |
|
351 | assert_response :success | |
352 | assert_template 'show' |
|
352 | assert_template 'show' | |
353 | assert_not_nil assigns(:project) |
|
353 | assert_not_nil assigns(:project) | |
354 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
354 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
355 | end |
|
355 | end | |
356 |
|
356 | |||
357 | def show_archived_project_should_be_denied |
|
357 | def show_archived_project_should_be_denied | |
358 | project = Project.find_by_identifier('ecookbook') |
|
358 | project = Project.find_by_identifier('ecookbook') | |
359 | project.archive! |
|
359 | project.archive! | |
360 |
|
360 | |||
361 | get :show, :id => 'ecookbook' |
|
361 | get :show, :id => 'ecookbook' | |
362 | assert_response 403 |
|
362 | assert_response 403 | |
363 | assert_nil assigns(:project) |
|
363 | assert_nil assigns(:project) | |
364 | assert_tag :tag => 'p', :content => /archived/ |
|
364 | assert_tag :tag => 'p', :content => /archived/ | |
365 | end |
|
365 | end | |
366 |
|
366 | |||
367 | def test_private_subprojects_hidden |
|
367 | def test_private_subprojects_hidden | |
368 | get :show, :id => 'ecookbook' |
|
368 | get :show, :id => 'ecookbook' | |
369 | assert_response :success |
|
369 | assert_response :success | |
370 | assert_template 'show' |
|
370 | assert_template 'show' | |
371 | assert_no_tag :tag => 'a', :content => /Private child/ |
|
371 | assert_no_tag :tag => 'a', :content => /Private child/ | |
372 | end |
|
372 | end | |
373 |
|
373 | |||
374 | def test_private_subprojects_visible |
|
374 | def test_private_subprojects_visible | |
375 | @request.session[:user_id] = 2 # manager who is a member of the private subproject |
|
375 | @request.session[:user_id] = 2 # manager who is a member of the private subproject | |
376 | get :show, :id => 'ecookbook' |
|
376 | get :show, :id => 'ecookbook' | |
377 | assert_response :success |
|
377 | assert_response :success | |
378 | assert_template 'show' |
|
378 | assert_template 'show' | |
379 | assert_tag :tag => 'a', :content => /Private child/ |
|
379 | assert_tag :tag => 'a', :content => /Private child/ | |
380 | end |
|
380 | end | |
381 |
|
381 | |||
382 | def test_settings |
|
382 | def test_settings | |
383 | @request.session[:user_id] = 2 # manager |
|
383 | @request.session[:user_id] = 2 # manager | |
384 | get :settings, :id => 1 |
|
384 | get :settings, :id => 1 | |
385 | assert_response :success |
|
385 | assert_response :success | |
386 | assert_template 'settings' |
|
386 | assert_template 'settings' | |
387 | end |
|
387 | end | |
388 |
|
388 | |||
389 | def test_update |
|
389 | def test_update | |
390 | @request.session[:user_id] = 2 # manager |
|
390 | @request.session[:user_id] = 2 # manager | |
391 | post :update, :id => 1, :project => {:name => 'Test changed name', |
|
391 | post :update, :id => 1, :project => {:name => 'Test changed name', | |
392 | :issue_custom_field_ids => ['']} |
|
392 | :issue_custom_field_ids => ['']} | |
393 | assert_redirected_to '/projects/ecookbook/settings' |
|
393 | assert_redirected_to '/projects/ecookbook/settings' | |
394 | project = Project.find(1) |
|
394 | project = Project.find(1) | |
395 | assert_equal 'Test changed name', project.name |
|
395 | assert_equal 'Test changed name', project.name | |
396 | end |
|
396 | end | |
397 |
|
397 | |||
398 | def test_modules |
|
398 | def test_modules | |
399 | @request.session[:user_id] = 2 |
|
399 | @request.session[:user_id] = 2 | |
400 | Project.find(1).enabled_module_names = ['issue_tracking', 'news'] |
|
400 | Project.find(1).enabled_module_names = ['issue_tracking', 'news'] | |
401 |
|
401 | |||
402 | post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents'] |
|
402 | post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents'] | |
403 | assert_redirected_to '/projects/ecookbook/settings/modules' |
|
403 | assert_redirected_to '/projects/ecookbook/settings/modules' | |
404 | assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort |
|
404 | assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort | |
405 | end |
|
405 | end | |
406 |
|
406 | |||
407 | def test_modules_should_not_allow_get |
|
407 | def test_modules_should_not_allow_get | |
408 | @request.session[:user_id] = 1 |
|
408 | @request.session[:user_id] = 1 | |
409 | get :modules, :id => 1 |
|
409 | get :modules, :id => 1 | |
410 | assert_response :method_not_allowed |
|
410 | assert_response :method_not_allowed | |
411 | end |
|
411 | end | |
412 |
|
412 | |||
413 | def test_destroy_without_confirmation |
|
413 | def test_destroy_without_confirmation | |
414 | @request.session[:user_id] = 1 # admin |
|
414 | @request.session[:user_id] = 1 # admin | |
415 | delete :destroy, :id => 1 |
|
415 | delete :destroy, :id => 1 | |
416 | assert_response :success |
|
416 | assert_response :success | |
417 | assert_template 'destroy' |
|
417 | assert_template 'destroy' | |
418 | assert_not_nil Project.find_by_id(1) |
|
418 | assert_not_nil Project.find_by_id(1) | |
419 | end |
|
419 | end | |
420 |
|
420 | |||
421 | def test_destroy |
|
421 | def test_destroy | |
422 | @request.session[:user_id] = 1 # admin |
|
422 | @request.session[:user_id] = 1 # admin | |
423 | delete :destroy, :id => 1, :confirm => 1 |
|
423 | delete :destroy, :id => 1, :confirm => 1 | |
424 | assert_redirected_to '/admin/projects' |
|
424 | assert_redirected_to '/admin/projects' | |
425 | assert_nil Project.find_by_id(1) |
|
425 | assert_nil Project.find_by_id(1) | |
426 | end |
|
426 | end | |
427 |
|
427 | |||
428 | def test_archive |
|
428 | def test_archive | |
429 | @request.session[:user_id] = 1 # admin |
|
429 | @request.session[:user_id] = 1 # admin | |
430 | post :archive, :id => 1 |
|
430 | post :archive, :id => 1 | |
431 | assert_redirected_to '/admin/projects' |
|
431 | assert_redirected_to '/admin/projects' | |
432 | assert !Project.find(1).active? |
|
432 | assert !Project.find(1).active? | |
433 | end |
|
433 | end | |
434 |
|
434 | |||
435 | def test_unarchive |
|
435 | def test_unarchive | |
436 | @request.session[:user_id] = 1 # admin |
|
436 | @request.session[:user_id] = 1 # admin | |
437 | Project.find(1).archive |
|
437 | Project.find(1).archive | |
438 | post :unarchive, :id => 1 |
|
438 | post :unarchive, :id => 1 | |
439 | assert_redirected_to '/admin/projects' |
|
439 | assert_redirected_to '/admin/projects' | |
440 | assert Project.find(1).active? |
|
440 | assert Project.find(1).active? | |
441 | end |
|
441 | end | |
442 |
|
442 | |||
443 | def test_project_breadcrumbs_should_be_limited_to_3_ancestors |
|
443 | def test_project_breadcrumbs_should_be_limited_to_3_ancestors | |
444 | CustomField.delete_all |
|
444 | CustomField.delete_all | |
445 | parent = nil |
|
445 | parent = nil | |
446 | 6.times do |i| |
|
446 | 6.times do |i| | |
447 | p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}") |
|
447 | p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}") | |
448 | p.set_parent!(parent) |
|
448 | p.set_parent!(parent) | |
449 | get :show, :id => p |
|
449 | get :show, :id => p | |
450 | assert_tag :h1, :parent => { :attributes => {:id => 'header'}}, |
|
450 | assert_tag :h1, :parent => { :attributes => {:id => 'header'}}, | |
451 | :children => { :count => [i, 3].min, |
|
451 | :children => { :count => [i, 3].min, | |
452 | :only => { :tag => 'a' } } |
|
452 | :only => { :tag => 'a' } } | |
453 |
|
453 | |||
454 | parent = p |
|
454 | parent = p | |
455 | end |
|
455 | end | |
456 | end |
|
456 | end | |
457 |
|
457 | |||
458 | def test_get_copy |
|
458 | def test_get_copy | |
459 | @request.session[:user_id] = 1 # admin |
|
459 | @request.session[:user_id] = 1 # admin | |
460 | get :copy, :id => 1 |
|
460 | get :copy, :id => 1 | |
461 | assert_response :success |
|
461 | assert_response :success | |
462 | assert_template 'copy' |
|
462 | assert_template 'copy' | |
463 | assert assigns(:project) |
|
463 | assert assigns(:project) | |
464 | assert_equal Project.find(1).description, assigns(:project).description |
|
464 | assert_equal Project.find(1).description, assigns(:project).description | |
465 | assert_nil assigns(:project).id |
|
465 | assert_nil assigns(:project).id | |
466 |
|
466 | |||
467 | assert_tag :tag => 'input', |
|
467 | assert_tag :tag => 'input', | |
468 | :attributes => {:name => 'project[enabled_module_names][]', :value => 'issue_tracking'} |
|
468 | :attributes => {:name => 'project[enabled_module_names][]', :value => 'issue_tracking'} | |
469 | end |
|
469 | end | |
470 |
|
470 | |||
471 | def test_get_copy_without_project |
|
|||
472 | @request.session[:user_id] = 1 # admin |
|
|||
473 | get :copy |
|
|||
474 | assert_response :redirect |
|
|||
475 | assert_redirected_to :controller => 'admin', :action => 'projects' |
|
|||
476 | end |
|
|||
477 |
|
||||
478 | def test_post_copy_should_copy_requested_items |
|
471 | def test_post_copy_should_copy_requested_items | |
479 | @request.session[:user_id] = 1 # admin |
|
472 | @request.session[:user_id] = 1 # admin | |
480 | CustomField.delete_all |
|
473 | CustomField.delete_all | |
481 |
|
474 | |||
482 | assert_difference 'Project.count' do |
|
475 | assert_difference 'Project.count' do | |
483 | post :copy, :id => 1, |
|
476 | post :copy, :id => 1, | |
484 | :project => { |
|
477 | :project => { | |
485 | :name => 'Copy', |
|
478 | :name => 'Copy', | |
486 | :identifier => 'unique-copy', |
|
479 | :identifier => 'unique-copy', | |
487 | :tracker_ids => ['1', '2', '3', ''], |
|
480 | :tracker_ids => ['1', '2', '3', ''], | |
488 | :enabled_module_names => %w(issue_tracking time_tracking) |
|
481 | :enabled_module_names => %w(issue_tracking time_tracking) | |
489 | }, |
|
482 | }, | |
490 | :only => %w(issues versions) |
|
483 | :only => %w(issues versions) | |
491 | end |
|
484 | end | |
492 | project = Project.find('unique-copy') |
|
485 | project = Project.find('unique-copy') | |
493 | source = Project.find(1) |
|
486 | source = Project.find(1) | |
494 | assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort |
|
487 | assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort | |
495 |
|
488 | |||
496 | assert_equal source.versions.count, project.versions.count, "All versions were not copied" |
|
489 | assert_equal source.versions.count, project.versions.count, "All versions were not copied" | |
497 | # issues assigned to a closed version won't be copied |
|
490 | # issues assigned to a closed version won't be copied | |
498 | assert_equal source.issues.select {|i| i.fixed_version.nil? || i.fixed_version.open?}.size, |
|
491 | assert_equal source.issues.select {|i| i.fixed_version.nil? || i.fixed_version.open?}.size, | |
499 | project.issues.count, "All issues were not copied" |
|
492 | project.issues.count, "All issues were not copied" | |
500 | assert_equal 0, project.members.count |
|
493 | assert_equal 0, project.members.count | |
501 | end |
|
494 | end | |
502 |
|
495 | |||
503 | def test_post_copy_should_redirect_to_settings_when_successful |
|
496 | def test_post_copy_should_redirect_to_settings_when_successful | |
504 | @request.session[:user_id] = 1 # admin |
|
497 | @request.session[:user_id] = 1 # admin | |
505 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} |
|
498 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} | |
506 | assert_response :redirect |
|
499 | assert_response :redirect | |
507 | assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' |
|
500 | assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' | |
508 | end |
|
501 | end | |
509 |
|
502 | |||
510 | def test_jump_should_redirect_to_active_tab |
|
503 | def test_jump_should_redirect_to_active_tab | |
511 | get :show, :id => 1, :jump => 'issues' |
|
504 | get :show, :id => 1, :jump => 'issues' | |
512 | assert_redirected_to '/projects/ecookbook/issues' |
|
505 | assert_redirected_to '/projects/ecookbook/issues' | |
513 | end |
|
506 | end | |
514 |
|
507 | |||
515 | def test_jump_should_not_redirect_to_inactive_tab |
|
508 | def test_jump_should_not_redirect_to_inactive_tab | |
516 | get :show, :id => 3, :jump => 'documents' |
|
509 | get :show, :id => 3, :jump => 'documents' | |
517 | assert_response :success |
|
510 | assert_response :success | |
518 | assert_template 'show' |
|
511 | assert_template 'show' | |
519 | end |
|
512 | end | |
520 |
|
513 | |||
521 | def test_jump_should_not_redirect_to_unknown_tab |
|
514 | def test_jump_should_not_redirect_to_unknown_tab | |
522 | get :show, :id => 3, :jump => 'foobar' |
|
515 | get :show, :id => 3, :jump => 'foobar' | |
523 | assert_response :success |
|
516 | assert_response :success | |
524 | assert_template 'show' |
|
517 | assert_template 'show' | |
525 | end |
|
518 | end | |
526 |
|
519 | |||
527 | # A hook that is manually registered later |
|
520 | # A hook that is manually registered later | |
528 | class ProjectBasedTemplate < Redmine::Hook::ViewListener |
|
521 | class ProjectBasedTemplate < Redmine::Hook::ViewListener | |
529 | def view_layouts_base_html_head(context) |
|
522 | def view_layouts_base_html_head(context) | |
530 | # Adds a project stylesheet |
|
523 | # Adds a project stylesheet | |
531 | stylesheet_link_tag(context[:project].identifier) if context[:project] |
|
524 | stylesheet_link_tag(context[:project].identifier) if context[:project] | |
532 | end |
|
525 | end | |
533 | end |
|
526 | end | |
534 | # Don't use this hook now |
|
527 | # Don't use this hook now | |
535 | Redmine::Hook.clear_listeners |
|
528 | Redmine::Hook.clear_listeners | |
536 |
|
529 | |||
537 | def test_hook_response |
|
530 | def test_hook_response | |
538 | Redmine::Hook.add_listener(ProjectBasedTemplate) |
|
531 | Redmine::Hook.add_listener(ProjectBasedTemplate) | |
539 | get :show, :id => 1 |
|
532 | get :show, :id => 1 | |
540 | assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'}, |
|
533 | assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'}, | |
541 | :parent => {:tag => 'head'} |
|
534 | :parent => {:tag => 'head'} | |
542 |
|
535 | |||
543 | Redmine::Hook.clear_listeners |
|
536 | Redmine::Hook.clear_listeners | |
544 | end |
|
537 | end | |
545 | end |
|
538 | end |
@@ -1,62 +1,62 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class AdminTest < ActionController::IntegrationTest |
|
20 | class AdminTest < ActionController::IntegrationTest | |
21 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
21 | fixtures :projects, :trackers, :issue_statuses, :issues, | |
22 | :enumerations, :users, :issue_categories, |
|
22 | :enumerations, :users, :issue_categories, | |
23 | :projects_trackers, |
|
23 | :projects_trackers, | |
24 | :roles, |
|
24 | :roles, | |
25 | :member_roles, |
|
25 | :member_roles, | |
26 | :members, |
|
26 | :members, | |
27 | :enabled_modules, |
|
27 | :enabled_modules, | |
28 | :workflows |
|
28 | :workflows | |
29 |
|
29 | |||
30 | def test_add_user |
|
30 | def test_add_user | |
31 | log_user("admin", "admin") |
|
31 | log_user("admin", "admin") | |
32 | get "/users/new" |
|
32 | get "/users/new" | |
33 | assert_response :success |
|
33 | assert_response :success | |
34 | assert_template "users/new" |
|
34 | assert_template "users/new" | |
35 |
post "/users |
|
35 | post "/users", | |
36 | :user => { :login => "psmith", :firstname => "Paul", |
|
36 | :user => { :login => "psmith", :firstname => "Paul", | |
37 | :lastname => "Smith", :mail => "psmith@somenet.foo", |
|
37 | :lastname => "Smith", :mail => "psmith@somenet.foo", | |
38 | :language => "en", :password => "psmith09", |
|
38 | :language => "en", :password => "psmith09", | |
39 | :password_confirmation => "psmith09" } |
|
39 | :password_confirmation => "psmith09" } | |
40 |
|
40 | |||
41 | user = User.find_by_login("psmith") |
|
41 | user = User.find_by_login("psmith") | |
42 | assert_kind_of User, user |
|
42 | assert_kind_of User, user | |
43 | assert_redirected_to "/users/#{ user.id }/edit" |
|
43 | assert_redirected_to "/users/#{ user.id }/edit" | |
44 |
|
44 | |||
45 | logged_user = User.try_to_login("psmith", "psmith09") |
|
45 | logged_user = User.try_to_login("psmith", "psmith09") | |
46 | assert_kind_of User, logged_user |
|
46 | assert_kind_of User, logged_user | |
47 | assert_equal "Paul", logged_user.firstname |
|
47 | assert_equal "Paul", logged_user.firstname | |
48 |
|
48 | |||
49 | put "users/#{user.id}", :id => user.id, :user => { :status => User::STATUS_LOCKED } |
|
49 | put "users/#{user.id}", :id => user.id, :user => { :status => User::STATUS_LOCKED } | |
50 | assert_redirected_to "/users/#{ user.id }/edit" |
|
50 | assert_redirected_to "/users/#{ user.id }/edit" | |
51 | locked_user = User.try_to_login("psmith", "psmith09") |
|
51 | locked_user = User.try_to_login("psmith", "psmith09") | |
52 | assert_equal nil, locked_user |
|
52 | assert_equal nil, locked_user | |
53 | end |
|
53 | end | |
54 |
|
54 | |||
55 | test "Add a user as an anonymous user should fail" do |
|
55 | test "Add a user as an anonymous user should fail" do | |
56 |
post '/users |
|
56 | post '/users', | |
57 | :user => { :login => 'psmith', :firstname => 'Paul'}, |
|
57 | :user => { :login => 'psmith', :firstname => 'Paul'}, | |
58 | :password => "psmith09", :password_confirmation => "psmith09" |
|
58 | :password => "psmith09", :password_confirmation => "psmith09" | |
59 | assert_response :redirect |
|
59 | assert_response :redirect | |
60 | assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fusers" |
|
60 | assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fusers" | |
61 | end |
|
61 | end | |
62 | end |
|
62 | end |
@@ -1,44 +1,44 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class ProjectsTest < ActionController::IntegrationTest |
|
20 | class ProjectsTest < ActionController::IntegrationTest | |
21 | fixtures :projects, :users, :members |
|
21 | fixtures :projects, :users, :members | |
22 |
|
22 | |||
23 | def test_archive_project |
|
23 | def test_archive_project | |
24 | subproject = Project.find(1).children.first |
|
24 | subproject = Project.find(1).children.first | |
25 | log_user("admin", "admin") |
|
25 | log_user("admin", "admin") | |
26 | get "admin/projects" |
|
26 | get "admin/projects" | |
27 | assert_response :success |
|
27 | assert_response :success | |
28 | assert_template "admin/projects" |
|
28 | assert_template "admin/projects" | |
29 |
post "projects/archive" |
|
29 | post "projects/1/archive" | |
30 | assert_redirected_to "/admin/projects" |
|
30 | assert_redirected_to "/admin/projects" | |
31 | assert !Project.find(1).active? |
|
31 | assert !Project.find(1).active? | |
32 |
|
32 | |||
33 | get 'projects/1' |
|
33 | get 'projects/1' | |
34 | assert_response 403 |
|
34 | assert_response 403 | |
35 | get "projects/#{subproject.id}" |
|
35 | get "projects/#{subproject.id}" | |
36 | assert_response 403 |
|
36 | assert_response 403 | |
37 |
|
37 | |||
38 |
post "projects/unarchive" |
|
38 | post "projects/1/unarchive" | |
39 | assert_redirected_to "/admin/projects" |
|
39 | assert_redirected_to "/admin/projects" | |
40 | assert Project.find(1).active? |
|
40 | assert Project.find(1).active? | |
41 | get "projects/1" |
|
41 | get "projects/1" | |
42 | assert_response :success |
|
42 | assert_response :success | |
43 | end |
|
43 | end | |
44 | end |
|
44 | end |
General Comments 0
You need to be logged in to leave comments.
Login now