@@ -1,187 +1,187 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2009 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class UsersController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | 20 | |
|
21 | 21 | before_filter :require_admin, :except => :show |
|
22 | 22 | |
|
23 | 23 | helper :sort |
|
24 | 24 | include SortHelper |
|
25 | 25 | helper :custom_fields |
|
26 | 26 | include CustomFieldsHelper |
|
27 | 27 | |
|
28 | 28 | def index |
|
29 | 29 | sort_init 'login', 'asc' |
|
30 | 30 | sort_update %w(login firstname lastname mail admin created_on last_login_on) |
|
31 | 31 | |
|
32 | 32 | @status = params[:status] ? params[:status].to_i : 1 |
|
33 | 33 | c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status]) |
|
34 | 34 | |
|
35 | 35 | unless params[:name].blank? |
|
36 | 36 | name = "%#{params[:name].strip.downcase}%" |
|
37 | 37 | c << ["LOWER(login) LIKE ? OR LOWER(firstname) LIKE ? OR LOWER(lastname) LIKE ? OR LOWER(mail) LIKE ?", name, name, name, name] |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | 40 | @user_count = User.count(:conditions => c.conditions) |
|
41 | 41 | @user_pages = Paginator.new self, @user_count, |
|
42 | 42 | per_page_option, |
|
43 | 43 | params['page'] |
|
44 | 44 | @users = User.find :all,:order => sort_clause, |
|
45 | 45 | :conditions => c.conditions, |
|
46 | 46 | :limit => @user_pages.items_per_page, |
|
47 | 47 | :offset => @user_pages.current.offset |
|
48 | 48 | |
|
49 | 49 | render :layout => !request.xhr? |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | def show |
|
53 | 53 | @user = User.find(params[:id]) |
|
54 | 54 | @custom_values = @user.custom_values |
|
55 | 55 | |
|
56 | 56 | # show projects based on current user visibility |
|
57 | 57 | @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) |
|
58 | 58 | |
|
59 | 59 | events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) |
|
60 | 60 | @events_by_day = events.group_by(&:event_date) |
|
61 | 61 | |
|
62 | 62 | unless User.current.admin? |
|
63 | 63 | if !@user.active? || (@user != User.current && @memberships.empty? && events.empty?) |
|
64 | 64 | render_404 |
|
65 | 65 | return |
|
66 | 66 | end |
|
67 | 67 | end |
|
68 | 68 | render :layout => 'base' |
|
69 | 69 | |
|
70 | 70 | rescue ActiveRecord::RecordNotFound |
|
71 | 71 | render_404 |
|
72 | 72 | end |
|
73 | 73 | |
|
74 |
def |
|
|
74 | def new | |
|
75 | 75 | @notification_options = User::MAIL_NOTIFICATION_OPTIONS |
|
76 | 76 | @notification_option = Setting.default_notification_option |
|
77 | 77 | |
|
78 | 78 | @user = User.new(:language => Setting.default_language) |
|
79 | 79 | @auth_sources = AuthSource.find(:all) |
|
80 | 80 | end |
|
81 | 81 | |
|
82 | 82 | verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } |
|
83 | 83 | def create |
|
84 | 84 | @notification_options = User::MAIL_NOTIFICATION_OPTIONS |
|
85 | 85 | @notification_option = Setting.default_notification_option |
|
86 | 86 | |
|
87 | 87 | @user = User.new(params[:user]) |
|
88 | 88 | @user.admin = params[:user][:admin] || false |
|
89 | 89 | @user.login = params[:user][:login] |
|
90 | 90 | @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id |
|
91 | 91 | |
|
92 | 92 | # TODO: Similar to My#account |
|
93 | 93 | @user.mail_notification = params[:notification_option] || 'only_my_events' |
|
94 | 94 | @user.pref.attributes = params[:pref] |
|
95 | 95 | @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') |
|
96 | 96 | |
|
97 | 97 | if @user.save |
|
98 | 98 | @user.pref.save |
|
99 | 99 | @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) |
|
100 | 100 | |
|
101 | 101 | Mailer.deliver_account_information(@user, params[:password]) if params[:send_information] |
|
102 | 102 | flash[:notice] = l(:notice_successful_create) |
|
103 |
redirect_to(params[:continue] ? {:controller => 'users', :action => ' |
|
|
103 | redirect_to(params[:continue] ? {:controller => 'users', :action => 'new'} : | |
|
104 | 104 | {:controller => 'users', :action => 'edit', :id => @user}) |
|
105 | 105 | return |
|
106 | 106 | else |
|
107 | 107 | @auth_sources = AuthSource.find(:all) |
|
108 | 108 | @notification_option = @user.mail_notification |
|
109 | 109 | |
|
110 |
render :action => ' |
|
|
110 | render :action => 'new' | |
|
111 | 111 | end |
|
112 | 112 | end |
|
113 | 113 | |
|
114 | 114 | def edit |
|
115 | 115 | @user = User.find(params[:id]) |
|
116 | 116 | @notification_options = @user.valid_notification_options |
|
117 | 117 | @notification_option = @user.mail_notification |
|
118 | 118 | |
|
119 | 119 | if request.post? |
|
120 | 120 | @user.admin = params[:user][:admin] if params[:user][:admin] |
|
121 | 121 | @user.login = params[:user][:login] if params[:user][:login] |
|
122 | 122 | if params[:password].present? && (@user.auth_source_id.nil? || params[:user][:auth_source_id].blank?) |
|
123 | 123 | @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] |
|
124 | 124 | end |
|
125 | 125 | @user.group_ids = params[:user][:group_ids] if params[:user][:group_ids] |
|
126 | 126 | @user.attributes = params[:user] |
|
127 | 127 | # Was the account actived ? (do it before User#save clears the change) |
|
128 | 128 | was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE]) |
|
129 | 129 | # TODO: Similar to My#account |
|
130 | 130 | @user.mail_notification = params[:notification_option] || 'only_my_events' |
|
131 | 131 | @user.pref.attributes = params[:pref] |
|
132 | 132 | @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') |
|
133 | 133 | |
|
134 | 134 | if @user.save |
|
135 | 135 | @user.pref.save |
|
136 | 136 | @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) |
|
137 | 137 | |
|
138 | 138 | if was_activated |
|
139 | 139 | Mailer.deliver_account_activated(@user) |
|
140 | 140 | elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil? |
|
141 | 141 | Mailer.deliver_account_information(@user, params[:password]) |
|
142 | 142 | end |
|
143 | 143 | flash[:notice] = l(:notice_successful_update) |
|
144 | 144 | redirect_to :back |
|
145 | 145 | end |
|
146 | 146 | end |
|
147 | 147 | @auth_sources = AuthSource.find(:all) |
|
148 | 148 | @membership ||= Member.new |
|
149 | 149 | rescue ::ActionController::RedirectBackError |
|
150 | 150 | redirect_to :controller => 'users', :action => 'edit', :id => @user |
|
151 | 151 | end |
|
152 | 152 | |
|
153 | 153 | def edit_membership |
|
154 | 154 | @user = User.find(params[:id]) |
|
155 | 155 | @membership = Member.edit_membership(params[:membership_id], params[:membership], @user) |
|
156 | 156 | @membership.save if request.post? |
|
157 | 157 | respond_to do |format| |
|
158 | 158 | if @membership.valid? |
|
159 | 159 | format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' } |
|
160 | 160 | format.js { |
|
161 | 161 | render(:update) {|page| |
|
162 | 162 | page.replace_html "tab-content-memberships", :partial => 'users/memberships' |
|
163 | 163 | page.visual_effect(:highlight, "member-#{@membership.id}") |
|
164 | 164 | } |
|
165 | 165 | } |
|
166 | 166 | else |
|
167 | 167 | format.js { |
|
168 | 168 | render(:update) {|page| |
|
169 | 169 | page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', '))) |
|
170 | 170 | } |
|
171 | 171 | } |
|
172 | 172 | end |
|
173 | 173 | end |
|
174 | 174 | end |
|
175 | 175 | |
|
176 | 176 | def destroy_membership |
|
177 | 177 | @user = User.find(params[:id]) |
|
178 | 178 | @membership = Member.find(params[:membership_id]) |
|
179 | 179 | if request.post? && @membership.deletable? |
|
180 | 180 | @membership.destroy |
|
181 | 181 | end |
|
182 | 182 | respond_to do |format| |
|
183 | 183 | format.html { redirect_to :controller => 'users', :action => 'edit', :id => @user, :tab => 'memberships' } |
|
184 | 184 | format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'users/memberships'} } |
|
185 | 185 | end |
|
186 | 186 | end |
|
187 | 187 | end |
@@ -1,48 +1,48 | |||
|
1 | 1 | <div class="contextual"> |
|
2 |
<%= link_to l(:label_user_new), {:action => ' |
|
|
2 | <%= link_to l(:label_user_new), {:action => 'new'}, :class => 'icon icon-add' %> | |
|
3 | 3 | </div> |
|
4 | 4 | |
|
5 | 5 | <h2><%=l(:label_user_plural)%></h2> |
|
6 | 6 | |
|
7 | 7 | <% form_tag({}, :method => :get) do %> |
|
8 | 8 | <fieldset><legend><%= l(:label_filter_plural) %></legend> |
|
9 | 9 | <label><%= l(:field_status) %>:</label> |
|
10 | 10 | <%= select_tag 'status', users_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %> |
|
11 | 11 | <label><%= l(:label_user) %>:</label> |
|
12 | 12 | <%= text_field_tag 'name', params[:name], :size => 30 %> |
|
13 | 13 | <%= submit_tag l(:button_apply), :class => "small", :name => nil %> |
|
14 | 14 | </fieldset> |
|
15 | 15 | <% end %> |
|
16 | 16 | |
|
17 | 17 | |
|
18 | 18 | <div class="autoscroll"> |
|
19 | 19 | <table class="list"> |
|
20 | 20 | <thead><tr> |
|
21 | 21 | <%= sort_header_tag('login', :caption => l(:field_login)) %> |
|
22 | 22 | <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %> |
|
23 | 23 | <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %> |
|
24 | 24 | <%= sort_header_tag('mail', :caption => l(:field_mail)) %> |
|
25 | 25 | <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %> |
|
26 | 26 | <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %> |
|
27 | 27 | <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %> |
|
28 | 28 | <th></th> |
|
29 | 29 | </tr></thead> |
|
30 | 30 | <tbody> |
|
31 | 31 | <% for user in @users -%> |
|
32 | 32 | <tr class="user <%= cycle("odd", "even") %> <%= %w(anon active registered locked)[user.status] %>"> |
|
33 | 33 | <td class="username"><%= avatar(user, :size => "14") %><%= link_to h(user.login), :action => 'edit', :id => user %></td> |
|
34 | 34 | <td class="firstname"><%= h(user.firstname) %></td> |
|
35 | 35 | <td class="lastname"><%= h(user.lastname) %></td> |
|
36 | 36 | <td class="email"><%= mail_to(h(user.mail)) %></td> |
|
37 | 37 | <td align="center"><%= checked_image user.admin? %></td> |
|
38 | 38 | <td class="created_on" align="center"><%= format_time(user.created_on) %></td> |
|
39 | 39 | <td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td> |
|
40 | 40 | <td><small><%= change_status_link(user) %></small></td> |
|
41 | 41 | </tr> |
|
42 | 42 | <% end -%> |
|
43 | 43 | </tbody> |
|
44 | 44 | </table> |
|
45 | 45 | </div> |
|
46 | 46 | <p class="pagination"><%= pagination_links_full @user_pages, @user_count %></p> |
|
47 | 47 | |
|
48 | 48 | <% html_title(l(:label_user_plural)) -%> |
|
1 | NO CONTENT: file renamed from app/views/users/add.rhtml to app/views/users/new.html.erb |
@@ -1,259 +1,258 | |||
|
1 | 1 | ActionController::Routing::Routes.draw do |map| |
|
2 | 2 | # Add your own custom routes here. |
|
3 | 3 | # The priority is based upon order of creation: first created -> highest priority. |
|
4 | 4 | |
|
5 | 5 | # Here's a sample route: |
|
6 | 6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
|
7 | 7 | # Keep in mind you can assign values other than :controller and :action |
|
8 | 8 | |
|
9 | 9 | map.home '', :controller => 'welcome' |
|
10 | 10 | |
|
11 | 11 | map.signin 'login', :controller => 'account', :action => 'login' |
|
12 | 12 | map.signout 'logout', :controller => 'account', :action => 'logout' |
|
13 | 13 | |
|
14 | 14 | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' |
|
15 | 15 | map.connect 'help/:ctrl/:page', :controller => 'help' |
|
16 | 16 | |
|
17 | 17 | map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog' |
|
18 | 18 | map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog' |
|
19 | 19 | map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog' |
|
20 | 20 | |
|
21 | 21 | map.with_options :controller => 'timelog' do |timelog| |
|
22 | 22 | timelog.connect 'projects/:project_id/time_entries', :action => 'details' |
|
23 | 23 | |
|
24 | 24 | timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details| |
|
25 | 25 | time_details.connect 'time_entries' |
|
26 | 26 | time_details.connect 'time_entries.:format' |
|
27 | 27 | time_details.connect 'issues/:issue_id/time_entries' |
|
28 | 28 | time_details.connect 'issues/:issue_id/time_entries.:format' |
|
29 | 29 | time_details.connect 'projects/:project_id/time_entries.:format' |
|
30 | 30 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries' |
|
31 | 31 | time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format' |
|
32 | 32 | end |
|
33 | 33 | timelog.connect 'projects/:project_id/time_entries/report', :action => 'report' |
|
34 | 34 | timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report| |
|
35 | 35 | time_report.connect 'time_entries/report' |
|
36 | 36 | time_report.connect 'time_entries/report.:format' |
|
37 | 37 | time_report.connect 'projects/:project_id/time_entries/report.:format' |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | 40 | timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit| |
|
41 | 41 | time_edit.connect 'issues/:issue_id/time_entries/new' |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | 44 | timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post} |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} |
|
48 | 48 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} |
|
49 | 49 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} |
|
50 | 50 | map.with_options :controller => 'wiki' do |wiki_routes| |
|
51 | 51 | wiki_routes.with_options :conditions => {:method => :get} do |wiki_views| |
|
52 | 52 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i |
|
53 | 53 | wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil |
|
54 | 54 | wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit' |
|
55 | 55 | wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename' |
|
56 | 56 | wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history' |
|
57 | 57 | wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff' |
|
58 | 58 | wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate' |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | wiki_routes.connect 'projects/:id/wiki/:page/:action', |
|
62 | 62 | :action => /edit|rename|destroy|preview|protect/, |
|
63 | 63 | :conditions => {:method => :post} |
|
64 | 64 | end |
|
65 | 65 | |
|
66 | 66 | map.with_options :controller => 'messages' do |messages_routes| |
|
67 | 67 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| |
|
68 | 68 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' |
|
69 | 69 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' |
|
70 | 70 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' |
|
71 | 71 | end |
|
72 | 72 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| |
|
73 | 73 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' |
|
74 | 74 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' |
|
75 | 75 | messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/ |
|
76 | 76 | end |
|
77 | 77 | end |
|
78 | 78 | |
|
79 | 79 | map.with_options :controller => 'boards' do |board_routes| |
|
80 | 80 | board_routes.with_options :conditions => {:method => :get} do |board_views| |
|
81 | 81 | board_views.connect 'projects/:project_id/boards', :action => 'index' |
|
82 | 82 | board_views.connect 'projects/:project_id/boards/new', :action => 'new' |
|
83 | 83 | board_views.connect 'projects/:project_id/boards/:id', :action => 'show' |
|
84 | 84 | board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show' |
|
85 | 85 | board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit' |
|
86 | 86 | end |
|
87 | 87 | board_routes.with_options :conditions => {:method => :post} do |board_actions| |
|
88 | 88 | board_actions.connect 'projects/:project_id/boards', :action => 'new' |
|
89 | 89 | board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/ |
|
90 | 90 | end |
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | map.with_options :controller => 'documents' do |document_routes| |
|
94 | 94 | document_routes.with_options :conditions => {:method => :get} do |document_views| |
|
95 | 95 | document_views.connect 'projects/:project_id/documents', :action => 'index' |
|
96 | 96 | document_views.connect 'projects/:project_id/documents/new', :action => 'new' |
|
97 | 97 | document_views.connect 'documents/:id', :action => 'show' |
|
98 | 98 | document_views.connect 'documents/:id/edit', :action => 'edit' |
|
99 | 99 | end |
|
100 | 100 | document_routes.with_options :conditions => {:method => :post} do |document_actions| |
|
101 | 101 | document_actions.connect 'projects/:project_id/documents', :action => 'new' |
|
102 | 102 | document_actions.connect 'documents/:id/:action', :action => /destroy|edit/ |
|
103 | 103 | end |
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move' |
|
107 | 107 | |
|
108 | 108 | # Misc issue routes. TODO: move into resources |
|
109 | 109 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues' |
|
110 | 110 | map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview |
|
111 | 111 | map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' |
|
112 | 112 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' |
|
113 | 113 | map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get } |
|
114 | 114 | map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post } |
|
115 | 115 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } |
|
116 | 116 | map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy |
|
117 | 117 | |
|
118 | 118 | map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update] |
|
119 | 119 | map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update] |
|
120 | 120 | map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update] |
|
121 | 121 | map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update] |
|
122 | 122 | |
|
123 | 123 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| |
|
124 | 124 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' |
|
125 | 125 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' |
|
126 | 126 | end |
|
127 | 127 | |
|
128 | 128 | # Following two routes conflict with the resources because #index allows POST |
|
129 | 129 | map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post } |
|
130 | 130 | map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post } |
|
131 | 131 | |
|
132 | 132 | map.resources :issues, :member => { :edit => :post }, :collection => {} |
|
133 | 133 | map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } |
|
134 | 134 | |
|
135 | 135 | map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations| |
|
136 | 136 | relations.connect 'issues/:issue_id/relations/:id', :action => 'new' |
|
137 | 137 | relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy' |
|
138 | 138 | end |
|
139 | 139 | |
|
140 | 140 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' |
|
141 | 141 | |
|
142 | 142 | map.with_options :controller => 'users' do |users| |
|
143 | 143 | users.with_options :conditions => {:method => :get} do |user_views| |
|
144 | 144 | user_views.connect 'users', :action => 'index' |
|
145 | 145 | user_views.connect 'users/:id', :action => 'show', :id => /\d+/ |
|
146 |
user_views.connect 'users/new', :action => ' |
|
|
146 | user_views.connect 'users/new', :action => 'new' | |
|
147 | 147 | user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil |
|
148 | 148 | end |
|
149 | 149 | users.with_options :conditions => {:method => :post} do |user_actions| |
|
150 | user_actions.connect 'users', :action => 'add' | |
|
151 | 150 | user_actions.connect 'users/new', :action => 'create' |
|
152 | 151 | user_actions.connect 'users/:id/edit', :action => 'edit' |
|
153 | 152 | user_actions.connect 'users/:id/memberships', :action => 'edit_membership' |
|
154 | 153 | user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership' |
|
155 | 154 | user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership' |
|
156 | 155 | end |
|
157 | 156 | end |
|
158 | 157 | |
|
159 | 158 | # For nice "roadmap" in the url for the index action |
|
160 | 159 | map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' |
|
161 | 160 | |
|
162 | 161 | map.all_news 'news', :controller => 'news', :action => 'index' |
|
163 | 162 | map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index' |
|
164 | 163 | map.preview_news '/news/preview', :controller => 'previews', :action => 'news' |
|
165 | 164 | map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post} |
|
166 | 165 | map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete} |
|
167 | 166 | |
|
168 | 167 | map.resources :projects, :member => { |
|
169 | 168 | :copy => [:get, :post], |
|
170 | 169 | :settings => :get, |
|
171 | 170 | :modules => :post, |
|
172 | 171 | :archive => :post, |
|
173 | 172 | :unarchive => :post |
|
174 | 173 | } do |project| |
|
175 | 174 | project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] |
|
176 | 175 | project.resources :files, :only => [:index, :new, :create] |
|
177 | 176 | project.resources :versions, :collection => {:close_completed => :put}, :member => {:status_by => :post} |
|
178 | 177 | project.resources :news, :shallow => true |
|
179 | 178 | end |
|
180 | 179 | |
|
181 | 180 | # Destroy uses a get request to prompt the user before the actual DELETE request |
|
182 | 181 | map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get} |
|
183 | 182 | |
|
184 | 183 | # TODO: port to be part of the resources route(s) |
|
185 | 184 | map.with_options :controller => 'projects' do |project_mapper| |
|
186 | 185 | project_mapper.with_options :conditions => {:method => :get} do |project_views| |
|
187 | 186 | project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings' |
|
188 | 187 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' |
|
189 | 188 | end |
|
190 | 189 | end |
|
191 | 190 | |
|
192 | 191 | map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| |
|
193 | 192 | activity.connect 'projects/:id/activity' |
|
194 | 193 | activity.connect 'projects/:id/activity.:format' |
|
195 | 194 | activity.connect 'activity', :id => nil |
|
196 | 195 | activity.connect 'activity.:format', :id => nil |
|
197 | 196 | end |
|
198 | 197 | |
|
199 | 198 | |
|
200 | 199 | map.with_options :controller => 'issue_categories' do |categories| |
|
201 | 200 | categories.connect 'projects/:project_id/issue_categories/new', :action => 'new' |
|
202 | 201 | end |
|
203 | 202 | |
|
204 | 203 | map.with_options :controller => 'repositories' do |repositories| |
|
205 | 204 | repositories.with_options :conditions => {:method => :get} do |repository_views| |
|
206 | 205 | repository_views.connect 'projects/:id/repository', :action => 'show' |
|
207 | 206 | repository_views.connect 'projects/:id/repository/edit', :action => 'edit' |
|
208 | 207 | repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' |
|
209 | 208 | repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' |
|
210 | 209 | repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' |
|
211 | 210 | repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' |
|
212 | 211 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' |
|
213 | 212 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' |
|
214 | 213 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
215 | 214 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
216 | 215 | repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' |
|
217 | 216 | # TODO: why the following route is required? |
|
218 | 217 | repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' |
|
219 | 218 | repository_views.connect 'projects/:id/repository/:action/*path' |
|
220 | 219 | end |
|
221 | 220 | |
|
222 | 221 | repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} |
|
223 | 222 | end |
|
224 | 223 | |
|
225 | 224 | map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ |
|
226 | 225 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ |
|
227 | 226 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
228 | 227 | |
|
229 | 228 | map.resources :groups |
|
230 | 229 | |
|
231 | 230 | #left old routes at the bottom for backwards compat |
|
232 | 231 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' |
|
233 | 232 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' |
|
234 | 233 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
|
235 | 234 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' |
|
236 | 235 | map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki' |
|
237 | 236 | map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations' |
|
238 | 237 | map.connect 'projects/:project_id/news/:action', :controller => 'news' |
|
239 | 238 | map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ |
|
240 | 239 | map.with_options :controller => 'repositories' do |omap| |
|
241 | 240 | omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' |
|
242 | 241 | omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' |
|
243 | 242 | omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' |
|
244 | 243 | omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' |
|
245 | 244 | omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' |
|
246 | 245 | omap.connect 'repositories/revision/:id/:rev', :action => 'revision' |
|
247 | 246 | end |
|
248 | 247 | |
|
249 | 248 | map.with_options :controller => 'sys' do |sys| |
|
250 | 249 | sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} |
|
251 | 250 | sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} |
|
252 | 251 | end |
|
253 | 252 | |
|
254 | 253 | # Install the default route as the lowest priority. |
|
255 | 254 | map.connect ':controller/:action/:id' |
|
256 | 255 | map.connect 'robots.txt', :controller => 'welcome', :action => 'robots' |
|
257 | 256 | # Used for OpenID |
|
258 | 257 | map.root :controller => 'account', :action => 'login' |
|
259 | 258 | end |
@@ -1,222 +1,222 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | require 'users_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class UsersController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class UsersControllerTest < ActionController::TestCase |
|
25 | 25 | include Redmine::I18n |
|
26 | 26 | |
|
27 | 27 | fixtures :users, :projects, :members, :member_roles, :roles, :auth_sources |
|
28 | 28 | |
|
29 | 29 | def setup |
|
30 | 30 | @controller = UsersController.new |
|
31 | 31 | @request = ActionController::TestRequest.new |
|
32 | 32 | @response = ActionController::TestResponse.new |
|
33 | 33 | User.current = nil |
|
34 | 34 | @request.session[:user_id] = 1 # admin |
|
35 | 35 | end |
|
36 | 36 | |
|
37 | 37 | def test_index |
|
38 | 38 | get :index |
|
39 | 39 | assert_response :success |
|
40 | 40 | assert_template 'index' |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | def test_index |
|
44 | 44 | get :index |
|
45 | 45 | assert_response :success |
|
46 | 46 | assert_template 'index' |
|
47 | 47 | assert_not_nil assigns(:users) |
|
48 | 48 | # active users only |
|
49 | 49 | assert_nil assigns(:users).detect {|u| !u.active?} |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | def test_index_with_name_filter |
|
53 | 53 | get :index, :name => 'john' |
|
54 | 54 | assert_response :success |
|
55 | 55 | assert_template 'index' |
|
56 | 56 | users = assigns(:users) |
|
57 | 57 | assert_not_nil users |
|
58 | 58 | assert_equal 1, users.size |
|
59 | 59 | assert_equal 'John', users.first.firstname |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | def test_show |
|
63 | 63 | @request.session[:user_id] = nil |
|
64 | 64 | get :show, :id => 2 |
|
65 | 65 | assert_response :success |
|
66 | 66 | assert_template 'show' |
|
67 | 67 | assert_not_nil assigns(:user) |
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | def test_show_should_not_fail_when_custom_values_are_nil |
|
71 | 71 | user = User.find(2) |
|
72 | 72 | |
|
73 | 73 | # Create a custom field to illustrate the issue |
|
74 | 74 | custom_field = CustomField.create!(:name => 'Testing', :field_format => 'text') |
|
75 | 75 | custom_value = user.custom_values.build(:custom_field => custom_field).save! |
|
76 | 76 | |
|
77 | 77 | get :show, :id => 2 |
|
78 | 78 | assert_response :success |
|
79 | 79 | end |
|
80 | 80 | |
|
81 | 81 | def test_show_inactive |
|
82 | 82 | @request.session[:user_id] = nil |
|
83 | 83 | get :show, :id => 5 |
|
84 | 84 | assert_response 404 |
|
85 | 85 | end |
|
86 | 86 | |
|
87 | 87 | def test_show_should_not_reveal_users_with_no_visible_activity_or_project |
|
88 | 88 | @request.session[:user_id] = nil |
|
89 | 89 | get :show, :id => 9 |
|
90 | 90 | assert_response 404 |
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | def test_show_inactive_by_admin |
|
94 | 94 | @request.session[:user_id] = 1 |
|
95 | 95 | get :show, :id => 5 |
|
96 | 96 | assert_response 200 |
|
97 | 97 | assert_not_nil assigns(:user) |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | def test_show_displays_memberships_based_on_project_visibility |
|
101 | 101 | @request.session[:user_id] = 1 |
|
102 | 102 | get :show, :id => 2 |
|
103 | 103 | assert_response :success |
|
104 | 104 | memberships = assigns(:memberships) |
|
105 | 105 | assert_not_nil memberships |
|
106 | 106 | project_ids = memberships.map(&:project_id) |
|
107 | 107 | assert project_ids.include?(2) #private project admin can see |
|
108 | 108 | end |
|
109 | 109 | |
|
110 |
context "GET : |
|
|
110 | context "GET :new" do | |
|
111 | 111 | setup do |
|
112 |
get : |
|
|
112 | get :new | |
|
113 | 113 | end |
|
114 | 114 | |
|
115 | 115 | should_assign_to :user |
|
116 | 116 | should_respond_with :success |
|
117 |
should_render_template : |
|
|
117 | should_render_template :new | |
|
118 | 118 | end |
|
119 | 119 | |
|
120 | 120 | context "POST :create" do |
|
121 | 121 | context "when successful" do |
|
122 | 122 | setup do |
|
123 | 123 | post :create, :user => { |
|
124 | 124 | :firstname => 'John', |
|
125 | 125 | :lastname => 'Doe', |
|
126 | 126 | :login => 'jdoe', |
|
127 | 127 | :password => 'test', |
|
128 | 128 | :password_confirmation => 'test', |
|
129 | 129 | :mail => 'jdoe@gmail.com' |
|
130 | 130 | }, |
|
131 | 131 | :notification_option => 'none' |
|
132 | 132 | end |
|
133 | 133 | |
|
134 | 134 | should_assign_to :user |
|
135 | 135 | should_respond_with :redirect |
|
136 | 136 | should_redirect_to('user edit') { {:controller => 'users', :action => 'edit', :id => User.find_by_login('jdoe')}} |
|
137 | 137 | |
|
138 | 138 | should 'set the users mail notification' do |
|
139 | 139 | user = User.last |
|
140 | 140 | assert_equal 'none', user.mail_notification |
|
141 | 141 | end |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | context "when unsuccessful" do |
|
145 | 145 | setup do |
|
146 | 146 | post :create, :user => {} |
|
147 | 147 | end |
|
148 | 148 | |
|
149 | 149 | should_assign_to :user |
|
150 | 150 | should_respond_with :success |
|
151 |
should_render_template : |
|
|
151 | should_render_template :new | |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | 154 | end |
|
155 | 155 | |
|
156 | 156 | def test_edit |
|
157 | 157 | ActionMailer::Base.deliveries.clear |
|
158 | 158 | post :edit, :id => 2, :user => {:firstname => 'Changed'}, :notification_option => 'all', :pref => {:hide_mail => '1', :comments_sorting => 'desc'} |
|
159 | 159 | |
|
160 | 160 | user = User.find(2) |
|
161 | 161 | assert_equal 'Changed', user.firstname |
|
162 | 162 | assert_equal 'all', user.mail_notification |
|
163 | 163 | assert_equal true, user.pref[:hide_mail] |
|
164 | 164 | assert_equal 'desc', user.pref[:comments_sorting] |
|
165 | 165 | assert ActionMailer::Base.deliveries.empty? |
|
166 | 166 | end |
|
167 | 167 | |
|
168 | 168 | def test_edit_with_activation_should_send_a_notification |
|
169 | 169 | u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr') |
|
170 | 170 | u.login = 'foo' |
|
171 | 171 | u.status = User::STATUS_REGISTERED |
|
172 | 172 | u.save! |
|
173 | 173 | ActionMailer::Base.deliveries.clear |
|
174 | 174 | Setting.bcc_recipients = '1' |
|
175 | 175 | |
|
176 | 176 | post :edit, :id => u.id, :user => {:status => User::STATUS_ACTIVE} |
|
177 | 177 | assert u.reload.active? |
|
178 | 178 | mail = ActionMailer::Base.deliveries.last |
|
179 | 179 | assert_not_nil mail |
|
180 | 180 | assert_equal ['foo.bar@somenet.foo'], mail.bcc |
|
181 | 181 | assert mail.body.include?(ll('fr', :notice_account_activated)) |
|
182 | 182 | end |
|
183 | 183 | |
|
184 | 184 | def test_edit_with_password_change_should_send_a_notification |
|
185 | 185 | ActionMailer::Base.deliveries.clear |
|
186 | 186 | Setting.bcc_recipients = '1' |
|
187 | 187 | |
|
188 | 188 | u = User.find(2) |
|
189 | 189 | post :edit, :id => u.id, :user => {}, :password => 'newpass', :password_confirmation => 'newpass', :send_information => '1' |
|
190 | 190 | assert_equal User.hash_password('newpass'), u.reload.hashed_password |
|
191 | 191 | |
|
192 | 192 | mail = ActionMailer::Base.deliveries.last |
|
193 | 193 | assert_not_nil mail |
|
194 | 194 | assert_equal [u.mail], mail.bcc |
|
195 | 195 | assert mail.body.include?('newpass') |
|
196 | 196 | end |
|
197 | 197 | |
|
198 | 198 | test "POST :edit with a password change to an AuthSource user switching to Internal authentication" do |
|
199 | 199 | # Configure as auth source |
|
200 | 200 | u = User.find(2) |
|
201 | 201 | u.auth_source = AuthSource.find(1) |
|
202 | 202 | u.save! |
|
203 | 203 | |
|
204 | 204 | post :edit, :id => u.id, :user => {:auth_source_id => ''}, :password => 'newpass', :password_confirmation => 'newpass' |
|
205 | 205 | |
|
206 | 206 | assert_equal nil, u.reload.auth_source |
|
207 | 207 | assert_equal User.hash_password('newpass'), u.reload.hashed_password |
|
208 | 208 | end |
|
209 | 209 | |
|
210 | 210 | def test_edit_membership |
|
211 | 211 | post :edit_membership, :id => 2, :membership_id => 1, |
|
212 | 212 | :membership => { :role_ids => [2]} |
|
213 | 213 | assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships' |
|
214 | 214 | assert_equal [2], Member.find(1).role_ids |
|
215 | 215 | end |
|
216 | 216 | |
|
217 | 217 | def test_destroy_membership |
|
218 | 218 | post :destroy_membership, :id => 2, :membership_id => 1 |
|
219 | 219 | assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships' |
|
220 | 220 | assert_nil Member.find_by_id(1) |
|
221 | 221 | end |
|
222 | 222 | end |
@@ -1,49 +1,49 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require "#{File.dirname(__FILE__)}/../test_helper" |
|
19 | 19 | |
|
20 | 20 | class AdminTest < ActionController::IntegrationTest |
|
21 | 21 | fixtures :all |
|
22 | 22 | |
|
23 | 23 | def test_add_user |
|
24 | 24 | log_user("admin", "admin") |
|
25 |
get "/users/ |
|
|
25 | get "/users/new" | |
|
26 | 26 | assert_response :success |
|
27 |
assert_template "users/ |
|
|
27 | assert_template "users/new" | |
|
28 | 28 | post "/users/create", :user => { :login => "psmith", :firstname => "Paul", :lastname => "Smith", :mail => "psmith@somenet.foo", :language => "en" }, :password => "psmith09", :password_confirmation => "psmith09" |
|
29 | 29 | |
|
30 | 30 | user = User.find_by_login("psmith") |
|
31 | 31 | assert_kind_of User, user |
|
32 | 32 | assert_redirected_to "/users/#{ user.id }/edit" |
|
33 | 33 | |
|
34 | 34 | logged_user = User.try_to_login("psmith", "psmith09") |
|
35 | 35 | assert_kind_of User, logged_user |
|
36 | 36 | assert_equal "Paul", logged_user.firstname |
|
37 | 37 | |
|
38 | 38 | post "users/edit", :id => user.id, :user => { :status => User::STATUS_LOCKED } |
|
39 | 39 | assert_redirected_to "/users/#{ user.id }/edit" |
|
40 | 40 | locked_user = User.try_to_login("psmith", "psmith09") |
|
41 | 41 | assert_equal nil, locked_user |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | 44 | test "Add a user as an anonymous user should fail" do |
|
45 | 45 | post '/users/create', :user => { :login => 'psmith', :firstname => 'Paul'}, :password => "psmith09", :password_confirmation => "psmith09" |
|
46 | 46 | assert_response :redirect |
|
47 | 47 | assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fusers%2Fnew" |
|
48 | 48 | end |
|
49 | 49 | end |
@@ -1,302 +1,302 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2010 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require "#{File.dirname(__FILE__)}/../test_helper" |
|
19 | 19 | |
|
20 | 20 | class RoutingTest < ActionController::IntegrationTest |
|
21 | 21 | context "activities" do |
|
22 | 22 | should_route :get, "/activity", :controller => 'activities', :action => 'index', :id => nil |
|
23 | 23 | should_route :get, "/activity.atom", :controller => 'activities', :action => 'index', :id => nil, :format => 'atom' |
|
24 | 24 | end |
|
25 | 25 | |
|
26 | 26 | context "attachments" do |
|
27 | 27 | should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1' |
|
28 | 28 | should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext' |
|
29 | 29 | should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1' |
|
30 | 30 | should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext' |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | context "boards" do |
|
34 | 34 | should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination' |
|
35 | 35 | should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination' |
|
36 | 36 | should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44' |
|
37 | 37 | should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom' |
|
38 | 38 | should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44' |
|
39 | 39 | |
|
40 | 40 | should_route :post, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination' |
|
41 | 41 | should_route :post, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44' |
|
42 | 42 | should_route :post, "/projects/world_domination/boards/44/destroy", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44' |
|
43 | 43 | |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | context "documents" do |
|
47 | 47 | should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567' |
|
48 | 48 | should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567' |
|
49 | 49 | should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22' |
|
50 | 50 | should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22' |
|
51 | 51 | |
|
52 | 52 | should_route :post, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567' |
|
53 | 53 | should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567' |
|
54 | 54 | should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567' |
|
55 | 55 | end |
|
56 | 56 | |
|
57 | 57 | context "issues" do |
|
58 | 58 | # REST actions |
|
59 | 59 | should_route :get, "/issues", :controller => 'issues', :action => 'index' |
|
60 | 60 | should_route :get, "/issues.pdf", :controller => 'issues', :action => 'index', :format => 'pdf' |
|
61 | 61 | should_route :get, "/issues.atom", :controller => 'issues', :action => 'index', :format => 'atom' |
|
62 | 62 | should_route :get, "/issues.xml", :controller => 'issues', :action => 'index', :format => 'xml' |
|
63 | 63 | should_route :get, "/projects/23/issues", :controller => 'issues', :action => 'index', :project_id => '23' |
|
64 | 64 | should_route :get, "/projects/23/issues.pdf", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf' |
|
65 | 65 | should_route :get, "/projects/23/issues.atom", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom' |
|
66 | 66 | should_route :get, "/projects/23/issues.xml", :controller => 'issues', :action => 'index', :project_id => '23', :format => 'xml' |
|
67 | 67 | should_route :get, "/issues/64", :controller => 'issues', :action => 'show', :id => '64' |
|
68 | 68 | should_route :get, "/issues/64.pdf", :controller => 'issues', :action => 'show', :id => '64', :format => 'pdf' |
|
69 | 69 | should_route :get, "/issues/64.atom", :controller => 'issues', :action => 'show', :id => '64', :format => 'atom' |
|
70 | 70 | should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml' |
|
71 | 71 | |
|
72 | 72 | should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23' |
|
73 | 73 | should_route :post, "/projects/23/issues", :controller => 'issues', :action => 'create', :project_id => '23' |
|
74 | 74 | should_route :post, "/issues.xml", :controller => 'issues', :action => 'create', :format => 'xml' |
|
75 | 75 | |
|
76 | 76 | should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64' |
|
77 | 77 | # TODO: Should use PUT |
|
78 | 78 | should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64' |
|
79 | 79 | should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml' |
|
80 | 80 | |
|
81 | 81 | # TODO: Should use DELETE |
|
82 | 82 | should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64' |
|
83 | 83 | should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml' |
|
84 | 84 | |
|
85 | 85 | # Extra actions |
|
86 | 86 | should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64' |
|
87 | 87 | |
|
88 | 88 | should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new' |
|
89 | 89 | should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create' |
|
90 | 90 | |
|
91 | 91 | should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1' |
|
92 | 92 | |
|
93 | 93 | should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show' |
|
94 | 94 | should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update' |
|
95 | 95 | should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name' |
|
96 | 96 | should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name' |
|
97 | 97 | |
|
98 | 98 | should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show' |
|
99 | 99 | should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update' |
|
100 | 100 | should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name' |
|
101 | 101 | should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name' |
|
102 | 102 | |
|
103 | 103 | should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues' |
|
104 | 104 | |
|
105 | 105 | should_route :get, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123' |
|
106 | 106 | should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123' |
|
107 | 107 | should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues' |
|
108 | 108 | should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues' |
|
109 | 109 | |
|
110 | 110 | should_route :get, "/issues/changes", :controller => 'journals', :action => 'index' |
|
111 | 111 | |
|
112 | 112 | should_route :get, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_edit' |
|
113 | 113 | should_route :post, "/issues/bulk_edit", :controller => 'issues', :action => 'bulk_update' |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | context "issue categories" do |
|
117 | 117 | should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test' |
|
118 | 118 | |
|
119 | 119 | should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test' |
|
120 | 120 | end |
|
121 | 121 | |
|
122 | 122 | context "issue relations" do |
|
123 | 123 | should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'new', :issue_id => '1' |
|
124 | 124 | should_route :post, "/issues/1/relations/23/destroy", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23' |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | context "issue reports" do |
|
128 | 128 | should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567' |
|
129 | 129 | should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to' |
|
130 | 130 | end |
|
131 | 131 | |
|
132 | 132 | context "members" do |
|
133 | 133 | should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234' |
|
134 | 134 | end |
|
135 | 135 | |
|
136 | 136 | context "messages" do |
|
137 | 137 | should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22' |
|
138 | 138 | should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala' |
|
139 | 139 | should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala' |
|
140 | 140 | |
|
141 | 141 | should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala' |
|
142 | 142 | should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala' |
|
143 | 143 | should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22' |
|
144 | 144 | should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22' |
|
145 | 145 | end |
|
146 | 146 | |
|
147 | 147 | context "news" do |
|
148 | 148 | should_route :get, "/news", :controller => 'news', :action => 'index' |
|
149 | 149 | should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom' |
|
150 | 150 | should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml' |
|
151 | 151 | should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json' |
|
152 | 152 | should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567' |
|
153 | 153 | should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567' |
|
154 | 154 | should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567' |
|
155 | 155 | should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567' |
|
156 | 156 | should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2' |
|
157 | 157 | should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567' |
|
158 | 158 | should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234' |
|
159 | 159 | should_route :get, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567' |
|
160 | 160 | should_route :get, "/news/preview", :controller => 'previews', :action => 'news' |
|
161 | 161 | |
|
162 | 162 | should_route :post, "/projects/567/news", :controller => 'news', :action => 'create', :project_id => '567' |
|
163 | 163 | should_route :post, "/news/567/comments", :controller => 'comments', :action => 'create', :id => '567' |
|
164 | 164 | |
|
165 | 165 | should_route :put, "/news/567", :controller => 'news', :action => 'update', :id => '567' |
|
166 | 166 | |
|
167 | 167 | should_route :delete, "/news/567", :controller => 'news', :action => 'destroy', :id => '567' |
|
168 | 168 | should_route :delete, "/news/567/comments/15", :controller => 'comments', :action => 'destroy', :id => '567', :comment_id => '15' |
|
169 | 169 | end |
|
170 | 170 | |
|
171 | 171 | context "projects" do |
|
172 | 172 | should_route :get, "/projects", :controller => 'projects', :action => 'index' |
|
173 | 173 | should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom' |
|
174 | 174 | should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml' |
|
175 | 175 | should_route :get, "/projects/new", :controller => 'projects', :action => 'new' |
|
176 | 176 | should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test' |
|
177 | 177 | should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml' |
|
178 | 178 | should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223' |
|
179 | 179 | should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members' |
|
180 | 180 | should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33' |
|
181 | 181 | should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33' |
|
182 | 182 | should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33' |
|
183 | 183 | should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33' |
|
184 | 184 | should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom' |
|
185 | 185 | |
|
186 | 186 | should_route :post, "/projects", :controller => 'projects', :action => 'create' |
|
187 | 187 | should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml' |
|
188 | 188 | should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33' |
|
189 | 189 | should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64' |
|
190 | 190 | should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64' |
|
191 | 191 | |
|
192 | 192 | should_route :put, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'update', :project_id => '64' |
|
193 | 193 | should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223' |
|
194 | 194 | should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml' |
|
195 | 195 | |
|
196 | 196 | should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64' |
|
197 | 197 | should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml' |
|
198 | 198 | should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64' |
|
199 | 199 | end |
|
200 | 200 | |
|
201 | 201 | context "repositories" do |
|
202 | 202 | should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine' |
|
203 | 203 | should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' |
|
204 | 204 | should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine' |
|
205 | 205 | should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom' |
|
206 | 206 | should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457' |
|
207 | 207 | should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457' |
|
208 | 208 | should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff' |
|
209 | 209 | should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c] |
|
210 | 210 | should_route :get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2' |
|
211 | 211 | should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c] |
|
212 | 212 | should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c] |
|
213 | 213 | should_route :get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2' |
|
214 | 214 | should_route :get, "/projects/redmine/repository/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw' |
|
215 | 215 | should_route :get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw' |
|
216 | 216 | should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c] |
|
217 | 217 | should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c] |
|
218 | 218 | should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine' |
|
219 | 219 | |
|
220 | 220 | |
|
221 | 221 | should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine' |
|
222 | 222 | end |
|
223 | 223 | |
|
224 | 224 | context "timelogs" do |
|
225 | 225 | should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567' |
|
226 | 226 | should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook' |
|
227 | 227 | should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567' |
|
228 | 228 | should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' |
|
229 | 229 | should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report' |
|
230 | 230 | should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567' |
|
231 | 231 | should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv' |
|
232 | 232 | should_route :get, "/time_entries", :controller => 'timelog', :action => 'details' |
|
233 | 233 | should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv' |
|
234 | 234 | should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom' |
|
235 | 235 | should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567' |
|
236 | 236 | should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv' |
|
237 | 237 | should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom' |
|
238 | 238 | should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234' |
|
239 | 239 | should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv' |
|
240 | 240 | should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom' |
|
241 | 241 | should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123' |
|
242 | 242 | |
|
243 | 243 | should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55' |
|
244 | 244 | end |
|
245 | 245 | |
|
246 | 246 | context "users" do |
|
247 | 247 | should_route :get, "/users", :controller => 'users', :action => 'index' |
|
248 | 248 | should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44' |
|
249 |
should_route :get, "/users/new", :controller => 'users', :action => ' |
|
|
249 | should_route :get, "/users/new", :controller => 'users', :action => 'new' | |
|
250 | 250 | should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' |
|
251 | 251 | should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership' |
|
252 | 252 | |
|
253 | 253 | should_route :post, "/users/new", :controller => 'users', :action => 'create' |
|
254 | 254 | should_route :post, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' |
|
255 | 255 | should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123' |
|
256 | 256 | should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55' |
|
257 | 257 | should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12' |
|
258 | 258 | end |
|
259 | 259 | |
|
260 | 260 | # TODO: should they all be scoped under /projects/:project_id ? |
|
261 | 261 | context "versions" do |
|
262 | 262 | should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo' |
|
263 | 263 | should_route :get, "/versions/show/1", :controller => 'versions', :action => 'show', :id => '1' |
|
264 | 264 | should_route :get, "/versions/edit/1", :controller => 'versions', :action => 'edit', :id => '1' |
|
265 | 265 | |
|
266 | 266 | should_route :post, "/projects/foo/versions", :controller => 'versions', :action => 'create', :project_id => 'foo' |
|
267 | 267 | should_route :post, "/versions/update/1", :controller => 'versions', :action => 'update', :id => '1' |
|
268 | 268 | |
|
269 | 269 | should_route :delete, "/versions/destroy/1", :controller => 'versions', :action => 'destroy', :id => '1' |
|
270 | 270 | end |
|
271 | 271 | |
|
272 | 272 | context "wiki (singular, project's pages)" do |
|
273 | 273 | should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567' |
|
274 | 274 | should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala' |
|
275 | 275 | should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' |
|
276 | 276 | should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation' |
|
277 | 277 | should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1' |
|
278 | 278 | should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2' |
|
279 | 279 | should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' |
|
280 | 280 | should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index' |
|
281 | 281 | should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index' |
|
282 | 282 | should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index' |
|
283 | 283 | should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'special', :id => '567', :page => 'export' |
|
284 | 284 | |
|
285 | 285 | should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page' |
|
286 | 286 | should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation' |
|
287 | 287 | should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida' |
|
288 | 288 | should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida' |
|
289 | 289 | should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida' |
|
290 | 290 | end |
|
291 | 291 | |
|
292 | 292 | context "wikis (plural, admin setup)" do |
|
293 | 293 | should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' |
|
294 | 294 | |
|
295 | 295 | should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida' |
|
296 | 296 | should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida' |
|
297 | 297 | end |
|
298 | 298 | |
|
299 | 299 | context "administration panel" do |
|
300 | 300 | should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects' |
|
301 | 301 | end |
|
302 | 302 | end |
General Comments 0
You need to be logged in to leave comments.
Login now