##// END OF EJS Templates
Moved new group user to its own action GroupsController#new_users....
Jean-Philippe Lang -
r13220:1508cd7b8bf9
parent child
Show More
@@ -0,0 +1,9
1 <fieldset class="box">
2 <legend><%= label_tag "user_search", l(:label_user_search) %></legend>
3 <p><%= text_field_tag 'user_search', nil %></p>
4 <%= javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_group_path(@group) }')" %>
5
6 <div id="users">
7 <%= render_principals_for_new_group_users(@group) %>
8 </div>
9 </fieldset>
@@ -0,0 +1,9
1 <h3 class="title"><%= l(:label_user_new) %></h3>
2
3 <%= form_for(@group, :url => group_users_path(@group), :remote => true, :method => :post) do |f| %>
4 <%= render :partial => 'new_users_form' %>
5 <p class="buttons">
6 <%= submit_tag l(:button_add) %>
7 <%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
8 </p>
9 <% end %>
@@ -0,0 +1,6
1 <h2><%= l(:label_user_new) %></h2>
2
3 <%= form_for(@group, :url => group_users_path(@group), :method => :post) do |f| %>
4 <%= render :partial => 'new_users_form' %>
5 <p><%= submit_tag l(:button_add) %></p>
6 <% end %>
@@ -0,0 +1,2
1 $('#ajax-modal').html('<%= escape_javascript(render :partial => 'groups/new_users_modal') %>');
2 showModal('ajax-modal', '700px');
@@ -1,138 +1,141
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 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 GroupsController < ApplicationController
18 class GroupsController < ApplicationController
19 layout 'admin'
19 layout 'admin'
20
20
21 before_filter :require_admin
21 before_filter :require_admin
22 before_filter :find_group, :except => [:index, :new, :create]
22 before_filter :find_group, :except => [:index, :new, :create]
23 accept_api_auth :index, :show, :create, :update, :destroy, :add_users, :remove_user
23 accept_api_auth :index, :show, :create, :update, :destroy, :add_users, :remove_user
24
24
25 helper :custom_fields
25 helper :custom_fields
26 helper :principal_memberships
26 helper :principal_memberships
27
27
28 def index
28 def index
29 respond_to do |format|
29 respond_to do |format|
30 format.html {
30 format.html {
31 @groups = Group.sorted.to_a
31 @groups = Group.sorted.to_a
32 @user_count_by_group_id = user_count_by_group_id
32 @user_count_by_group_id = user_count_by_group_id
33 }
33 }
34 format.api {
34 format.api {
35 scope = Group.sorted
35 scope = Group.sorted
36 scope = scope.givable unless params[:builtin] == '1'
36 scope = scope.givable unless params[:builtin] == '1'
37 @groups = scope.to_a
37 @groups = scope.to_a
38 }
38 }
39 end
39 end
40 end
40 end
41
41
42 def show
42 def show
43 respond_to do |format|
43 respond_to do |format|
44 format.html
44 format.html
45 format.api
45 format.api
46 end
46 end
47 end
47 end
48
48
49 def new
49 def new
50 @group = Group.new
50 @group = Group.new
51 end
51 end
52
52
53 def create
53 def create
54 @group = Group.new
54 @group = Group.new
55 @group.safe_attributes = params[:group]
55 @group.safe_attributes = params[:group]
56
56
57 respond_to do |format|
57 respond_to do |format|
58 if @group.save
58 if @group.save
59 format.html {
59 format.html {
60 flash[:notice] = l(:notice_successful_create)
60 flash[:notice] = l(:notice_successful_create)
61 redirect_to(params[:continue] ? new_group_path : groups_path)
61 redirect_to(params[:continue] ? new_group_path : groups_path)
62 }
62 }
63 format.api { render :action => 'show', :status => :created, :location => group_url(@group) }
63 format.api { render :action => 'show', :status => :created, :location => group_url(@group) }
64 else
64 else
65 format.html { render :action => "new" }
65 format.html { render :action => "new" }
66 format.api { render_validation_errors(@group) }
66 format.api { render_validation_errors(@group) }
67 end
67 end
68 end
68 end
69 end
69 end
70
70
71 def edit
71 def edit
72 end
72 end
73
73
74 def update
74 def update
75 @group.safe_attributes = params[:group]
75 @group.safe_attributes = params[:group]
76
76
77 respond_to do |format|
77 respond_to do |format|
78 if @group.save
78 if @group.save
79 flash[:notice] = l(:notice_successful_update)
79 flash[:notice] = l(:notice_successful_update)
80 format.html { redirect_to(groups_path) }
80 format.html { redirect_to(groups_path) }
81 format.api { render_api_ok }
81 format.api { render_api_ok }
82 else
82 else
83 format.html { render :action => "edit" }
83 format.html { render :action => "edit" }
84 format.api { render_validation_errors(@group) }
84 format.api { render_validation_errors(@group) }
85 end
85 end
86 end
86 end
87 end
87 end
88
88
89 def destroy
89 def destroy
90 @group.destroy
90 @group.destroy
91
91
92 respond_to do |format|
92 respond_to do |format|
93 format.html { redirect_to(groups_path) }
93 format.html { redirect_to(groups_path) }
94 format.api { render_api_ok }
94 format.api { render_api_ok }
95 end
95 end
96 end
96 end
97
97
98 def new_users
99 end
100
98 def add_users
101 def add_users
99 @users = User.where(:id => (params[:user_id] || params[:user_ids])).to_a
102 @users = User.where(:id => (params[:user_id] || params[:user_ids])).to_a
100 @group.users << @users if request.post?
103 @group.users << @users if request.post?
101 respond_to do |format|
104 respond_to do |format|
102 format.html { redirect_to edit_group_path(@group, :tab => 'users') }
105 format.html { redirect_to edit_group_path(@group, :tab => 'users') }
103 format.js
106 format.js
104 format.api { render_api_ok }
107 format.api { render_api_ok }
105 end
108 end
106 end
109 end
107
110
108 def remove_user
111 def remove_user
109 @group.users.delete(User.find(params[:user_id])) if request.delete?
112 @group.users.delete(User.find(params[:user_id])) if request.delete?
110 respond_to do |format|
113 respond_to do |format|
111 format.html { redirect_to edit_group_path(@group, :tab => 'users') }
114 format.html { redirect_to edit_group_path(@group, :tab => 'users') }
112 format.js
115 format.js
113 format.api { render_api_ok }
116 format.api { render_api_ok }
114 end
117 end
115 end
118 end
116
119
117 def autocomplete_for_user
120 def autocomplete_for_user
118 respond_to do |format|
121 respond_to do |format|
119 format.js
122 format.js
120 end
123 end
121 end
124 end
122
125
123 private
126 private
124
127
125 def find_group
128 def find_group
126 @group = Group.find(params[:id])
129 @group = Group.find(params[:id])
127 rescue ActiveRecord::RecordNotFound
130 rescue ActiveRecord::RecordNotFound
128 render_404
131 render_404
129 end
132 end
130
133
131 def user_count_by_group_id
134 def user_count_by_group_id
132 h = User.joins(:groups).group('group_id').count
135 h = User.joins(:groups).group('group_id').count
133 h.keys.each do |key|
136 h.keys.each do |key|
134 h[key.to_i] = h.delete(key)
137 h[key.to_i] = h.delete(key)
135 end
138 end
136 h
139 h
137 end
140 end
138 end
141 end
@@ -1,43 +1,46
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2014 Jean-Philippe Lang
4 # Copyright (C) 2006-2014 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 module GroupsHelper
20 module GroupsHelper
21 def group_settings_tabs(group)
21 def group_settings_tabs(group)
22 tabs = []
22 tabs = []
23 tabs << {:name => 'general', :partial => 'groups/general', :label => :label_general}
23 tabs << {:name => 'general', :partial => 'groups/general', :label => :label_general}
24 tabs << {:name => 'users', :partial => 'groups/users', :label => :label_user_plural} if group.givable?
24 tabs << {:name => 'users', :partial => 'groups/users', :label => :label_user_plural} if group.givable?
25 tabs << {:name => 'memberships', :partial => 'groups/memberships', :label => :label_project_plural}
25 tabs << {:name => 'memberships', :partial => 'groups/memberships', :label => :label_project_plural}
26 tabs
26 tabs
27 end
27 end
28
28
29 def render_principals_for_new_group_users(group)
29 def render_principals_for_new_group_users(group)
30 scope = User.active.sorted.not_in_group(group).like(params[:q])
30 scope = User.active.sorted.not_in_group(group).like(params[:q])
31 principal_count = scope.count
31 principal_count = scope.count
32 principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page']
32 principal_pages = Redmine::Pagination::Paginator.new principal_count, 100, params['page']
33 principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a
33 principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a
34
34
35 s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals')
35 s = content_tag('div',
36 content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals'),
37 :class => 'objects-selection'
38 )
36
39
37 links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
40 links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
38 link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
41 link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
39 }
42 }
40
43
41 s + content_tag('p', links, :class => 'pagination')
44 s + content_tag('p', links, :class => 'pagination')
42 end
45 end
43 end
46 end
@@ -1,39 +1,22
1 <div class="splitcontentleft">
1 <p><%= link_to l(:label_user_new), new_group_users_path(@group), :remote => true, :class => "icon icon-add" %></p>
2
2 <% if @group.users.any? %>
3 <% if @group.users.any? %>
3 <table class="list users">
4 <table class="list users">
4 <thead><tr>
5 <thead><tr>
5 <th><%= l(:label_user) %></th>
6 <th><%= l(:label_user) %></th>
6 <th style="width:15%"></th>
7 <th style="width:15%"></th>
7 </tr></thead>
8 </tr></thead>
8 <tbody>
9 <tbody>
9 <% @group.users.sort.each do |user| %>
10 <% @group.users.sort.each do |user| %>
10 <tr id="user-<%= user.id %>" class="<%= cycle 'odd', 'even' %>">
11 <tr id="user-<%= user.id %>" class="<%= cycle 'odd', 'even' %>">
11 <td class="name"><%= link_to_user user %></td>
12 <td class="name"><%= link_to_user user %></td>
12 <td class="buttons">
13 <td class="buttons">
13 <%= delete_link group_user_path(@group, :user_id => user), :remote => true %>
14 <%= delete_link group_user_path(@group, :user_id => user), :remote => true %>
14 </td>
15 </td>
15 </tr>
16 </tr>
16 <% end %>
17 <% end %>
17 </tbody>
18 </tbody>
18 </table>
19 </table>
19 <% else %>
20 <% else %>
20 <p class="nodata"><%= l(:label_no_data) %></p>
21 <p class="nodata"><%= l(:label_no_data) %></p>
21 <% end %>
22 <% end %>
22 </div>
23
24 <div class="splitcontentright">
25 <%= form_for(@group, :remote => true, :url => group_users_path(@group),
26 :html => {:method => :post}) do |f| %>
27 <fieldset><legend><%=l(:label_user_new)%></legend>
28
29 <p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p>
30 <%= javascript_tag "observeSearchfield('user_search', null, '#{ escape_javascript autocomplete_for_user_group_path(@group) }')" %>
31
32 <div id="users">
33 <%= render_principals_for_new_group_users(@group) %>
34 </div>
35
36 <p><%= submit_tag l(:button_add) %></p>
37 </fieldset>
38 <% end %>
39 </div>
@@ -1,4 +1,5
1 hideModal();
1 $('#tab-content-users').html('<%= escape_javascript(render :partial => 'groups/users') %>');
2 $('#tab-content-users').html('<%= escape_javascript(render :partial => 'groups/users') %>');
2 <% @users.each do |user| %>
3 <% @users.each do |user| %>
3 $('#user-<%= user.id %>').effect("highlight");
4 $('#user-<%= user.id %>').effect("highlight");
4 <% end %>
5 <% end %>
@@ -1,347 +1,348
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 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 Rails.application.routes.draw do
18 Rails.application.routes.draw do
19 root :to => 'welcome#index', :as => 'home'
19 root :to => 'welcome#index', :as => 'home'
20
20
21 match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post]
21 match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post]
22 match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post]
22 match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post]
23 match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register'
23 match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register'
24 match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password'
24 match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password'
25 match 'account/activate', :to => 'account#activate', :via => :get
25 match 'account/activate', :to => 'account#activate', :via => :get
26 get 'account/activation_email', :to => 'account#activation_email', :as => 'activation_email'
26 get 'account/activation_email', :to => 'account#activation_email', :as => 'activation_email'
27
27
28 match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put, :patch]
28 match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put, :patch]
29 match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put, :patch]
29 match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put, :patch]
30 match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put, :patch]
30 match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put, :patch]
31 match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put, :patch]
31 match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put, :patch]
32
32
33 match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
33 match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
34 match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
34 match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
35
35
36 match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
36 match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
37 get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
37 get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
38 match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
38 match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
39 get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
39 get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
40
40
41 post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message'
41 post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message'
42 post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
42 post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
43 post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
43 post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
44 post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
44 post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
45
45
46 # Misc issue routes. TODO: move into resources
46 # Misc issue routes. TODO: move into resources
47 match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
47 match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
48 match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post]
48 match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post]
49 match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get
49 match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get
50 match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
50 match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
51
51
52 match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
52 match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
53 match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
53 match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
54
54
55 get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
55 get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
56 get '/issues/gantt', :to => 'gantts#show'
56 get '/issues/gantt', :to => 'gantts#show'
57
57
58 get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
58 get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
59 get '/issues/calendar', :to => 'calendars#show'
59 get '/issues/calendar', :to => 'calendars#show'
60
60
61 get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
61 get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
62 get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
62 get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
63
63
64 match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
64 match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
65 match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
65 match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
66 match 'my/page', :controller => 'my', :action => 'page', :via => :get
66 match 'my/page', :controller => 'my', :action => 'page', :via => :get
67 match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
67 match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
68 match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post
68 match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post
69 match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post
69 match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post
70 match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
70 match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
71 match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
71 match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
72 match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
72 match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
73 match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
73 match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
74 match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
74 match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
75
75
76 resources :users do
76 resources :users do
77 resources :memberships, :controller => 'principal_memberships'
77 resources :memberships, :controller => 'principal_memberships'
78 end
78 end
79
79
80 post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
80 post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
81 delete 'watchers/watch', :to => 'watchers#unwatch'
81 delete 'watchers/watch', :to => 'watchers#unwatch'
82 get 'watchers/new', :to => 'watchers#new'
82 get 'watchers/new', :to => 'watchers#new'
83 post 'watchers', :to => 'watchers#create'
83 post 'watchers', :to => 'watchers#create'
84 post 'watchers/append', :to => 'watchers#append'
84 post 'watchers/append', :to => 'watchers#append'
85 delete 'watchers', :to => 'watchers#destroy'
85 delete 'watchers', :to => 'watchers#destroy'
86 get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user'
86 get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user'
87 # Specific routes for issue watchers API
87 # Specific routes for issue watchers API
88 post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
88 post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
89 delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
89 delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
90
90
91 resources :projects do
91 resources :projects do
92 member do
92 member do
93 get 'settings(/:tab)', :action => 'settings', :as => 'settings'
93 get 'settings(/:tab)', :action => 'settings', :as => 'settings'
94 post 'modules'
94 post 'modules'
95 post 'archive'
95 post 'archive'
96 post 'unarchive'
96 post 'unarchive'
97 post 'close'
97 post 'close'
98 post 'reopen'
98 post 'reopen'
99 match 'copy', :via => [:get, :post]
99 match 'copy', :via => [:get, :post]
100 end
100 end
101
101
102 shallow do
102 shallow do
103 resources :memberships, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
103 resources :memberships, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
104 collection do
104 collection do
105 get 'autocomplete'
105 get 'autocomplete'
106 end
106 end
107 end
107 end
108 end
108 end
109
109
110 resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
110 resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
111
111
112 get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue'
112 get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue'
113 resources :issues, :only => [:index, :new, :create]
113 resources :issues, :only => [:index, :new, :create]
114 # issue form update
114 # issue form update
115 match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :patch, :post], :as => 'issue_form'
115 match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :patch, :post], :as => 'issue_form'
116
116
117 resources :files, :only => [:index, :new, :create]
117 resources :files, :only => [:index, :new, :create]
118
118
119 resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
119 resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
120 collection do
120 collection do
121 put 'close_completed'
121 put 'close_completed'
122 end
122 end
123 end
123 end
124 get 'versions.:format', :to => 'versions#index'
124 get 'versions.:format', :to => 'versions#index'
125 get 'roadmap', :to => 'versions#index', :format => false
125 get 'roadmap', :to => 'versions#index', :format => false
126 get 'versions', :to => 'versions#index'
126 get 'versions', :to => 'versions#index'
127
127
128 resources :news, :except => [:show, :edit, :update, :destroy]
128 resources :news, :except => [:show, :edit, :update, :destroy]
129 resources :time_entries, :controller => 'timelog' do
129 resources :time_entries, :controller => 'timelog' do
130 get 'report', :on => :collection
130 get 'report', :on => :collection
131 end
131 end
132 resources :queries, :only => [:new, :create]
132 resources :queries, :only => [:new, :create]
133 shallow do
133 shallow do
134 resources :issue_categories
134 resources :issue_categories
135 end
135 end
136 resources :documents, :except => [:show, :edit, :update, :destroy]
136 resources :documents, :except => [:show, :edit, :update, :destroy]
137 resources :boards
137 resources :boards
138 shallow do
138 shallow do
139 resources :repositories, :except => [:index, :show] do
139 resources :repositories, :except => [:index, :show] do
140 member do
140 member do
141 match 'committers', :via => [:get, :post]
141 match 'committers', :via => [:get, :post]
142 end
142 end
143 end
143 end
144 end
144 end
145
145
146 match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
146 match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
147 resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do
147 resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do
148 member do
148 member do
149 get 'rename'
149 get 'rename'
150 post 'rename'
150 post 'rename'
151 get 'history'
151 get 'history'
152 get 'diff'
152 get 'diff'
153 match 'preview', :via => [:post, :put, :patch]
153 match 'preview', :via => [:post, :put, :patch]
154 post 'protect'
154 post 'protect'
155 post 'add_attachment'
155 post 'add_attachment'
156 end
156 end
157 collection do
157 collection do
158 get 'export'
158 get 'export'
159 get 'date_index'
159 get 'date_index'
160 end
160 end
161 end
161 end
162 match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
162 match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
163 get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/}
163 get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/}
164 delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
164 delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
165 get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
165 get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
166 get 'wiki/:id/:version/diff', :to => 'wiki#diff'
166 get 'wiki/:id/:version/diff', :to => 'wiki#diff'
167 end
167 end
168
168
169 resources :issues do
169 resources :issues do
170 collection do
170 collection do
171 match 'bulk_edit', :via => [:get, :post]
171 match 'bulk_edit', :via => [:get, :post]
172 post 'bulk_update'
172 post 'bulk_update'
173 end
173 end
174 resources :time_entries, :controller => 'timelog' do
174 resources :time_entries, :controller => 'timelog' do
175 collection do
175 collection do
176 get 'report'
176 get 'report'
177 end
177 end
178 end
178 end
179 shallow do
179 shallow do
180 resources :relations, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
180 resources :relations, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
181 end
181 end
182 end
182 end
183 match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
183 match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
184
184
185 resources :queries, :except => [:show]
185 resources :queries, :except => [:show]
186
186
187 resources :news, :only => [:index, :show, :edit, :update, :destroy]
187 resources :news, :only => [:index, :show, :edit, :update, :destroy]
188 match '/news/:id/comments', :to => 'comments#create', :via => :post
188 match '/news/:id/comments', :to => 'comments#create', :via => :post
189 match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
189 match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
190
190
191 resources :versions, :only => [:show, :edit, :update, :destroy] do
191 resources :versions, :only => [:show, :edit, :update, :destroy] do
192 post 'status_by', :on => :member
192 post 'status_by', :on => :member
193 end
193 end
194
194
195 resources :documents, :only => [:show, :edit, :update, :destroy] do
195 resources :documents, :only => [:show, :edit, :update, :destroy] do
196 post 'add_attachment', :on => :member
196 post 'add_attachment', :on => :member
197 end
197 end
198
198
199 match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
199 match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
200
200
201 resources :time_entries, :controller => 'timelog', :except => :destroy do
201 resources :time_entries, :controller => 'timelog', :except => :destroy do
202 collection do
202 collection do
203 get 'report'
203 get 'report'
204 get 'bulk_edit'
204 get 'bulk_edit'
205 post 'bulk_update'
205 post 'bulk_update'
206 end
206 end
207 end
207 end
208 match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
208 match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
209 # TODO: delete /time_entries for bulk deletion
209 # TODO: delete /time_entries for bulk deletion
210 match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
210 match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
211
211
212 get 'projects/:id/activity', :to => 'activities#index', :as => :project_activity
212 get 'projects/:id/activity', :to => 'activities#index', :as => :project_activity
213 get 'activity', :to => 'activities#index'
213 get 'activity', :to => 'activities#index'
214
214
215 # repositories routes
215 # repositories routes
216 get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
216 get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
217 get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
217 get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
218
218
219 get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))',
219 get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))',
220 :to => 'repositories#changes'
220 :to => 'repositories#changes'
221
221
222 get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
222 get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
223 get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
223 get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
224 post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
224 post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
225 delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
225 delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
226 get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
226 get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
227 get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
227 get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
228 :controller => 'repositories',
228 :controller => 'repositories',
229 :format => false,
229 :format => false,
230 :constraints => {
230 :constraints => {
231 :action => /(browse|show|entry|raw|annotate|diff)/,
231 :action => /(browse|show|entry|raw|annotate|diff)/,
232 :rev => /[a-z0-9\.\-_]+/
232 :rev => /[a-z0-9\.\-_]+/
233 }
233 }
234
234
235 get 'projects/:id/repository/statistics', :to => 'repositories#stats'
235 get 'projects/:id/repository/statistics', :to => 'repositories#stats'
236 get 'projects/:id/repository/graph', :to => 'repositories#graph'
236 get 'projects/:id/repository/graph', :to => 'repositories#graph'
237
237
238 get 'projects/:id/repository/changes(/*path(.:ext))',
238 get 'projects/:id/repository/changes(/*path(.:ext))',
239 :to => 'repositories#changes'
239 :to => 'repositories#changes'
240
240
241 get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
241 get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
242 get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
242 get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
243 get 'projects/:id/repository/revision', :to => 'repositories#revision'
243 get 'projects/:id/repository/revision', :to => 'repositories#revision'
244 post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
244 post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
245 delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
245 delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
246 get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))',
246 get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))',
247 :controller => 'repositories',
247 :controller => 'repositories',
248 :format => false,
248 :format => false,
249 :constraints => {
249 :constraints => {
250 :action => /(browse|show|entry|raw|annotate|diff)/,
250 :action => /(browse|show|entry|raw|annotate|diff)/,
251 :rev => /[a-z0-9\.\-_]+/
251 :rev => /[a-z0-9\.\-_]+/
252 }
252 }
253 get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
253 get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
254 :controller => 'repositories',
254 :controller => 'repositories',
255 :action => /(browse|show|entry|raw|changes|annotate|diff)/
255 :action => /(browse|show|entry|raw|changes|annotate|diff)/
256 get 'projects/:id/repository/:action(/*path(.:ext))',
256 get 'projects/:id/repository/:action(/*path(.:ext))',
257 :controller => 'repositories',
257 :controller => 'repositories',
258 :action => /(browse|show|entry|raw|changes|annotate|diff)/
258 :action => /(browse|show|entry|raw|changes|annotate|diff)/
259
259
260 get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
260 get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
261 get 'projects/:id/repository', :to => 'repositories#show', :path => nil
261 get 'projects/:id/repository', :to => 'repositories#show', :path => nil
262
262
263 # additional routes for having the file name at the end of url
263 # additional routes for having the file name at the end of url
264 get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
264 get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
265 get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
265 get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
266 get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
266 get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
267 get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
267 get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
268 resources :attachments, :only => [:show, :destroy]
268 resources :attachments, :only => [:show, :destroy]
269
269
270 resources :groups do
270 resources :groups do
271 resources :memberships, :controller => 'principal_memberships'
271 resources :memberships, :controller => 'principal_memberships'
272 member do
272 member do
273 get 'autocomplete_for_user'
273 get 'autocomplete_for_user'
274 end
274 end
275 end
275 end
276
276
277 match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users'
277 get 'groups/:id/users/new', :to => 'groups#new_users', :id => /\d+/, :as => 'new_group_users'
278 match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user'
278 post 'groups/:id/users', :to => 'groups#add_users', :id => /\d+/, :as => 'group_users'
279 delete 'groups/:id/users/:user_id', :to => 'groups#remove_user', :id => /\d+/, :as => 'group_user'
279
280
280 resources :trackers, :except => :show do
281 resources :trackers, :except => :show do
281 collection do
282 collection do
282 match 'fields', :via => [:get, :post]
283 match 'fields', :via => [:get, :post]
283 end
284 end
284 end
285 end
285 resources :issue_statuses, :except => :show do
286 resources :issue_statuses, :except => :show do
286 collection do
287 collection do
287 post 'update_issue_done_ratio'
288 post 'update_issue_done_ratio'
288 end
289 end
289 end
290 end
290 resources :custom_fields, :except => :show
291 resources :custom_fields, :except => :show
291 resources :roles do
292 resources :roles do
292 collection do
293 collection do
293 match 'permissions', :via => [:get, :post]
294 match 'permissions', :via => [:get, :post]
294 end
295 end
295 end
296 end
296 resources :enumerations, :except => :show
297 resources :enumerations, :except => :show
297 match 'enumerations/:type', :to => 'enumerations#index', :via => :get
298 match 'enumerations/:type', :to => 'enumerations#index', :via => :get
298
299
299 get 'projects/:id/search', :controller => 'search', :action => 'index'
300 get 'projects/:id/search', :controller => 'search', :action => 'index'
300 get 'search', :controller => 'search', :action => 'index'
301 get 'search', :controller => 'search', :action => 'index'
301
302
302 match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post
303 match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post
303
304
304 match 'admin', :controller => 'admin', :action => 'index', :via => :get
305 match 'admin', :controller => 'admin', :action => 'index', :via => :get
305 match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
306 match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
306 match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
307 match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
307 match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
308 match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
308 match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
309 match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
309 match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post
310 match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post
310
311
311 resources :auth_sources do
312 resources :auth_sources do
312 member do
313 member do
313 get 'test_connection', :as => 'try_connection'
314 get 'test_connection', :as => 'try_connection'
314 end
315 end
315 collection do
316 collection do
316 get 'autocomplete_for_new_user'
317 get 'autocomplete_for_new_user'
317 end
318 end
318 end
319 end
319
320
320 match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
321 match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
321 match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
322 match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
322 match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]
323 match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]
323 match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
324 match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
324 match 'settings', :controller => 'settings', :action => 'index', :via => :get
325 match 'settings', :controller => 'settings', :action => 'index', :via => :get
325 match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
326 match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
326 match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings'
327 match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings'
327
328
328 match 'sys/projects', :to => 'sys#projects', :via => :get
329 match 'sys/projects', :to => 'sys#projects', :via => :get
329 match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
330 match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
330 match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => [:get, :post]
331 match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => [:get, :post]
331
332
332 match 'uploads', :to => 'attachments#upload', :via => :post
333 match 'uploads', :to => 'attachments#upload', :via => :post
333
334
334 get 'robots.txt', :to => 'welcome#robots'
335 get 'robots.txt', :to => 'welcome#robots'
335
336
336 Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
337 Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
337 file = File.join(plugin_dir, "config/routes.rb")
338 file = File.join(plugin_dir, "config/routes.rb")
338 if File.exists?(file)
339 if File.exists?(file)
339 begin
340 begin
340 instance_eval File.read(file)
341 instance_eval File.read(file)
341 rescue Exception => e
342 rescue Exception => e
342 puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
343 puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
343 exit 1
344 exit 1
344 end
345 end
345 end
346 end
346 end
347 end
347 end
348 end
@@ -1,152 +1,164
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 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 GroupsControllerTest < ActionController::TestCase
20 class GroupsControllerTest < ActionController::TestCase
21 fixtures :projects, :users, :members, :member_roles, :roles, :groups_users
21 fixtures :projects, :users, :members, :member_roles, :roles, :groups_users
22
22
23 def setup
23 def setup
24 @request.session[:user_id] = 1
24 @request.session[:user_id] = 1
25 end
25 end
26
26
27 def test_index
27 def test_index
28 get :index
28 get :index
29 assert_response :success
29 assert_response :success
30 assert_template 'index'
30 assert_template 'index'
31 end
31 end
32
32
33 def test_index_should_show_user_count
33 def test_index_should_show_user_count
34 get :index
34 get :index
35 assert_response :success
35 assert_response :success
36 assert_select 'tr#group-11 td.user_count', :text => '1'
36 assert_select 'tr#group-11 td.user_count', :text => '1'
37 end
37 end
38
38
39 def test_show
39 def test_show
40 get :show, :id => 10
40 get :show, :id => 10
41 assert_response :success
41 assert_response :success
42 assert_template 'show'
42 assert_template 'show'
43 end
43 end
44
44
45 def test_show_invalid_should_return_404
45 def test_show_invalid_should_return_404
46 get :show, :id => 99
46 get :show, :id => 99
47 assert_response 404
47 assert_response 404
48 end
48 end
49
49
50 def test_new
50 def test_new
51 get :new
51 get :new
52 assert_response :success
52 assert_response :success
53 assert_template 'new'
53 assert_template 'new'
54 assert_select 'input[name=?]', 'group[name]'
54 assert_select 'input[name=?]', 'group[name]'
55 end
55 end
56
56
57 def test_create
57 def test_create
58 assert_difference 'Group.count' do
58 assert_difference 'Group.count' do
59 post :create, :group => {:name => 'New group'}
59 post :create, :group => {:name => 'New group'}
60 end
60 end
61 assert_redirected_to '/groups'
61 assert_redirected_to '/groups'
62 group = Group.order('id DESC').first
62 group = Group.order('id DESC').first
63 assert_equal 'New group', group.name
63 assert_equal 'New group', group.name
64 assert_equal [], group.users
64 assert_equal [], group.users
65 end
65 end
66
66
67 def test_create_and_continue
67 def test_create_and_continue
68 assert_difference 'Group.count' do
68 assert_difference 'Group.count' do
69 post :create, :group => {:name => 'New group'}, :continue => 'Create and continue'
69 post :create, :group => {:name => 'New group'}, :continue => 'Create and continue'
70 end
70 end
71 assert_redirected_to '/groups/new'
71 assert_redirected_to '/groups/new'
72 group = Group.order('id DESC').first
72 group = Group.order('id DESC').first
73 assert_equal 'New group', group.name
73 assert_equal 'New group', group.name
74 end
74 end
75
75
76 def test_create_with_failure
76 def test_create_with_failure
77 assert_no_difference 'Group.count' do
77 assert_no_difference 'Group.count' do
78 post :create, :group => {:name => ''}
78 post :create, :group => {:name => ''}
79 end
79 end
80 assert_response :success
80 assert_response :success
81 assert_template 'new'
81 assert_template 'new'
82 end
82 end
83
83
84 def test_edit
84 def test_edit
85 get :edit, :id => 10
85 get :edit, :id => 10
86 assert_response :success
86 assert_response :success
87 assert_template 'edit'
87 assert_template 'edit'
88
88
89 assert_select 'div#tab-content-users'
89 assert_select 'div#tab-content-users'
90 assert_select 'div#tab-content-memberships' do
90 assert_select 'div#tab-content-memberships' do
91 assert_select 'a', :text => 'Private child of eCookbook'
91 assert_select 'a', :text => 'Private child of eCookbook'
92 end
92 end
93 end
93 end
94
94
95 def test_update
95 def test_update
96 new_name = 'New name'
96 new_name = 'New name'
97 put :update, :id => 10, :group => {:name => new_name}
97 put :update, :id => 10, :group => {:name => new_name}
98 assert_redirected_to '/groups'
98 assert_redirected_to '/groups'
99 group = Group.find(10)
99 group = Group.find(10)
100 assert_equal new_name, group.name
100 assert_equal new_name, group.name
101 end
101 end
102
102
103 def test_update_with_failure
103 def test_update_with_failure
104 put :update, :id => 10, :group => {:name => ''}
104 put :update, :id => 10, :group => {:name => ''}
105 assert_response :success
105 assert_response :success
106 assert_template 'edit'
106 assert_template 'edit'
107 end
107 end
108
108
109 def test_destroy
109 def test_destroy
110 assert_difference 'Group.count', -1 do
110 assert_difference 'Group.count', -1 do
111 post :destroy, :id => 10
111 post :destroy, :id => 10
112 end
112 end
113 assert_redirected_to '/groups'
113 assert_redirected_to '/groups'
114 end
114 end
115
115
116 def test_new_users
117 get :new_users, :id => 10
118 assert_response :success
119 assert_template 'new_users'
120 end
121
122 def test_xhr_new_users
123 xhr :get, :new_users, :id => 10
124 assert_response :success
125 assert_equal 'text/javascript', response.content_type
126 end
127
116 def test_add_users
128 def test_add_users
117 assert_difference 'Group.find(10).users.count', 2 do
129 assert_difference 'Group.find(10).users.count', 2 do
118 post :add_users, :id => 10, :user_ids => ['2', '3']
130 post :add_users, :id => 10, :user_ids => ['2', '3']
119 end
131 end
120 end
132 end
121
133
122 def test_xhr_add_users
134 def test_xhr_add_users
123 assert_difference 'Group.find(10).users.count', 2 do
135 assert_difference 'Group.find(10).users.count', 2 do
124 xhr :post, :add_users, :id => 10, :user_ids => ['2', '3']
136 xhr :post, :add_users, :id => 10, :user_ids => ['2', '3']
125 assert_response :success
137 assert_response :success
126 assert_template 'add_users'
138 assert_template 'add_users'
127 assert_equal 'text/javascript', response.content_type
139 assert_equal 'text/javascript', response.content_type
128 end
140 end
129 assert_match /John Smith/, response.body
141 assert_match /John Smith/, response.body
130 end
142 end
131
143
132 def test_remove_user
144 def test_remove_user
133 assert_difference 'Group.find(10).users.count', -1 do
145 assert_difference 'Group.find(10).users.count', -1 do
134 delete :remove_user, :id => 10, :user_id => '8'
146 delete :remove_user, :id => 10, :user_id => '8'
135 end
147 end
136 end
148 end
137
149
138 def test_xhr_remove_user
150 def test_xhr_remove_user
139 assert_difference 'Group.find(10).users.count', -1 do
151 assert_difference 'Group.find(10).users.count', -1 do
140 xhr :delete, :remove_user, :id => 10, :user_id => '8'
152 xhr :delete, :remove_user, :id => 10, :user_id => '8'
141 assert_response :success
153 assert_response :success
142 assert_template 'remove_user'
154 assert_template 'remove_user'
143 assert_equal 'text/javascript', response.content_type
155 assert_equal 'text/javascript', response.content_type
144 end
156 end
145 end
157 end
146
158
147 def test_autocomplete_for_user
159 def test_autocomplete_for_user
148 xhr :get, :autocomplete_for_user, :id => 10, :q => 'smi', :format => 'js'
160 xhr :get, :autocomplete_for_user, :id => 10, :q => 'smi', :format => 'js'
149 assert_response :success
161 assert_response :success
150 assert_include 'John Smith', response.body
162 assert_include 'John Smith', response.body
151 end
163 end
152 end
164 end
@@ -1,98 +1,102
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 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 RoutingGroupsTest < ActionDispatch::IntegrationTest
20 class RoutingGroupsTest < ActionDispatch::IntegrationTest
21 def test_groups_resources
21 def test_groups_resources
22 assert_routing(
22 assert_routing(
23 { :method => 'get', :path => "/groups" },
23 { :method => 'get', :path => "/groups" },
24 { :controller => 'groups', :action => 'index' }
24 { :controller => 'groups', :action => 'index' }
25 )
25 )
26 assert_routing(
26 assert_routing(
27 { :method => 'get', :path => "/groups.xml" },
27 { :method => 'get', :path => "/groups.xml" },
28 { :controller => 'groups', :action => 'index', :format => 'xml' }
28 { :controller => 'groups', :action => 'index', :format => 'xml' }
29 )
29 )
30 assert_routing(
30 assert_routing(
31 { :method => 'post', :path => "/groups" },
31 { :method => 'post', :path => "/groups" },
32 { :controller => 'groups', :action => 'create' }
32 { :controller => 'groups', :action => 'create' }
33 )
33 )
34 assert_routing(
34 assert_routing(
35 { :method => 'post', :path => "/groups.xml" },
35 { :method => 'post', :path => "/groups.xml" },
36 { :controller => 'groups', :action => 'create', :format => 'xml' }
36 { :controller => 'groups', :action => 'create', :format => 'xml' }
37 )
37 )
38 assert_routing(
38 assert_routing(
39 { :method => 'get', :path => "/groups/new" },
39 { :method => 'get', :path => "/groups/new" },
40 { :controller => 'groups', :action => 'new' }
40 { :controller => 'groups', :action => 'new' }
41 )
41 )
42 assert_routing(
42 assert_routing(
43 { :method => 'get', :path => "/groups/1/edit" },
43 { :method => 'get', :path => "/groups/1/edit" },
44 { :controller => 'groups', :action => 'edit', :id => '1' }
44 { :controller => 'groups', :action => 'edit', :id => '1' }
45 )
45 )
46 assert_routing(
46 assert_routing(
47 { :method => 'get', :path => "/groups/1/autocomplete_for_user" },
47 { :method => 'get', :path => "/groups/1/autocomplete_for_user" },
48 { :controller => 'groups', :action => 'autocomplete_for_user', :id => '1' }
48 { :controller => 'groups', :action => 'autocomplete_for_user', :id => '1' }
49 )
49 )
50 assert_routing(
50 assert_routing(
51 { :method => 'get', :path => "/groups/1/autocomplete_for_user.js" },
51 { :method => 'get', :path => "/groups/1/autocomplete_for_user.js" },
52 { :controller => 'groups', :action => 'autocomplete_for_user', :id => '1', :format => 'js' }
52 { :controller => 'groups', :action => 'autocomplete_for_user', :id => '1', :format => 'js' }
53 )
53 )
54 assert_routing(
54 assert_routing(
55 { :method => 'get', :path => "/groups/1" },
55 { :method => 'get', :path => "/groups/1" },
56 { :controller => 'groups', :action => 'show', :id => '1' }
56 { :controller => 'groups', :action => 'show', :id => '1' }
57 )
57 )
58 assert_routing(
58 assert_routing(
59 { :method => 'get', :path => "/groups/1.xml" },
59 { :method => 'get', :path => "/groups/1.xml" },
60 { :controller => 'groups', :action => 'show', :id => '1', :format => 'xml' }
60 { :controller => 'groups', :action => 'show', :id => '1', :format => 'xml' }
61 )
61 )
62 assert_routing(
62 assert_routing(
63 { :method => 'put', :path => "/groups/1" },
63 { :method => 'put', :path => "/groups/1" },
64 { :controller => 'groups', :action => 'update', :id => '1' }
64 { :controller => 'groups', :action => 'update', :id => '1' }
65 )
65 )
66 assert_routing(
66 assert_routing(
67 { :method => 'put', :path => "/groups/1.xml" },
67 { :method => 'put', :path => "/groups/1.xml" },
68 { :controller => 'groups', :action => 'update', :id => '1', :format => 'xml' }
68 { :controller => 'groups', :action => 'update', :id => '1', :format => 'xml' }
69 )
69 )
70 assert_routing(
70 assert_routing(
71 { :method => 'delete', :path => "/groups/1" },
71 { :method => 'delete', :path => "/groups/1" },
72 { :controller => 'groups', :action => 'destroy', :id => '1' }
72 { :controller => 'groups', :action => 'destroy', :id => '1' }
73 )
73 )
74 assert_routing(
74 assert_routing(
75 { :method => 'delete', :path => "/groups/1.xml" },
75 { :method => 'delete', :path => "/groups/1.xml" },
76 { :controller => 'groups', :action => 'destroy', :id => '1', :format => 'xml' }
76 { :controller => 'groups', :action => 'destroy', :id => '1', :format => 'xml' }
77 )
77 )
78 end
78 end
79
79
80 def test_groups
80 def test_groups
81 assert_routing(
81 assert_routing(
82 { :method => 'get', :path => "/groups/567/users/new" },
83 { :controller => 'groups', :action => 'new_users', :id => '567' }
84 )
85 assert_routing(
82 { :method => 'post', :path => "/groups/567/users" },
86 { :method => 'post', :path => "/groups/567/users" },
83 { :controller => 'groups', :action => 'add_users', :id => '567' }
87 { :controller => 'groups', :action => 'add_users', :id => '567' }
84 )
88 )
85 assert_routing(
89 assert_routing(
86 { :method => 'post', :path => "/groups/567/users.xml" },
90 { :method => 'post', :path => "/groups/567/users.xml" },
87 { :controller => 'groups', :action => 'add_users', :id => '567', :format => 'xml' }
91 { :controller => 'groups', :action => 'add_users', :id => '567', :format => 'xml' }
88 )
92 )
89 assert_routing(
93 assert_routing(
90 { :method => 'delete', :path => "/groups/567/users/12" },
94 { :method => 'delete', :path => "/groups/567/users/12" },
91 { :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12' }
95 { :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12' }
92 )
96 )
93 assert_routing(
97 assert_routing(
94 { :method => 'delete', :path => "/groups/567/users/12.xml" },
98 { :method => 'delete', :path => "/groups/567/users/12.xml" },
95 { :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12', :format => 'xml' }
99 { :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12', :format => 'xml' }
96 )
100 )
97 end
101 end
98 end
102 end
General Comments 0
You need to be logged in to leave comments. Login now