##// END OF EJS Templates
Resourcified auth_sources....
Jean-Philippe Lang -
r9113:71e636ff7179
parent child
Show More
@@ -1,6 +1,6
1 <h2><%=l(:label_auth_source)%> (<%= h(@auth_source.auth_method_name) %>)</h2>
1 <h2><%=l(:label_auth_source)%> (<%= h(@auth_source.auth_method_name) %>)</h2>
2
2
3 <% form_tag({:action => 'update', :id => @auth_source}, :class => "tabular") do %>
3 <% form_tag({:action => 'update', :id => @auth_source}, :method => :put, :class => "tabular") do %>
4 <%= render :partial => auth_source_partial_name(@auth_source) %>
4 <%= render :partial => auth_source_partial_name(@auth_source) %>
5 <%= submit_tag l(:button_save) %>
5 <%= submit_tag l(:button_save) %>
6 <% end %>
6 <% end %>
@@ -1,35 +1,35
1 <div class="contextual">
1 <div class="contextual">
2 <%= link_to l(:label_auth_source_new), {:action => 'new'}, :class => 'icon icon-add' %>
2 <%= link_to l(:label_auth_source_new), {:action => 'new'}, :class => 'icon icon-add' %>
3 </div>
3 </div>
4
4
5 <h2><%=l(:label_auth_source_plural)%></h2>
5 <h2><%=l(:label_auth_source_plural)%></h2>
6
6
7 <table class="list">
7 <table class="list">
8 <thead><tr>
8 <thead><tr>
9 <th><%=l(:field_name)%></th>
9 <th><%=l(:field_name)%></th>
10 <th><%=l(:field_type)%></th>
10 <th><%=l(:field_type)%></th>
11 <th><%=l(:field_host)%></th>
11 <th><%=l(:field_host)%></th>
12 <th><%=l(:label_user_plural)%></th>
12 <th><%=l(:label_user_plural)%></th>
13 <th></th>
13 <th></th>
14 </tr></thead>
14 </tr></thead>
15 <tbody>
15 <tbody>
16 <% for source in @auth_sources %>
16 <% for source in @auth_sources %>
17 <tr id="auth-source-<%= source.id %>" class="<%= cycle("odd", "even") %>">
17 <tr id="auth-source-<%= source.id %>" class="<%= cycle("odd", "even") %>">
18 <td><%= link_to(h(source.name), :action => 'edit', :id => source)%></td>
18 <td><%= link_to(h(source.name), :action => 'edit', :id => source)%></td>
19 <td align="center"><%= h source.auth_method_name %></td>
19 <td align="center"><%= h source.auth_method_name %></td>
20 <td align="center"><%= h source.host %></td>
20 <td align="center"><%= h source.host %></td>
21 <td align="center"><%= h source.users.count %></td>
21 <td align="center"><%= h source.users.count %></td>
22 <td class="buttons">
22 <td class="buttons">
23 <%= link_to l(:button_test), :action => 'test_connection', :id => source %>
23 <%= link_to l(:button_test), :action => 'test_connection', :id => source %>
24 <%= link_to l(:button_delete), { :action => 'destroy', :id => source },
24 <%= link_to l(:button_delete), { :action => 'destroy', :id => source },
25 :method => :post,
25 :method => :delete,
26 :confirm => l(:text_are_you_sure),
26 :confirm => l(:text_are_you_sure),
27 :class => 'icon icon-del',
27 :class => 'icon icon-del',
28 :disabled => source.users.any? %>
28 :disabled => source.users.any? %>
29 </td>
29 </td>
30 </tr>
30 </tr>
31 <% end %>
31 <% end %>
32 </tbody>
32 </tbody>
33 </table>
33 </table>
34
34
35 <p class="pagination"><%= pagination_links_full @auth_source_pages %></p>
35 <p class="pagination"><%= pagination_links_full @auth_source_pages %></p>
@@ -1,406 +1,391
1 ActionController::Routing::Routes.draw do |map|
1 ActionController::Routing::Routes.draw do |map|
2 # Add your own custom routes here.
2 # Add your own custom routes here.
3 # The priority is based upon order of creation: first created -> highest priority.
3 # The priority is based upon order of creation: first created -> highest priority.
4
4
5 # Here's a sample route:
5 # Here's a sample route:
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 # Keep in mind you can assign values other than :controller and :action
7 # Keep in mind you can assign values other than :controller and :action
8
8
9 map.home '', :controller => 'welcome', :conditions => {:method => :get}
9 map.home '', :controller => 'welcome', :conditions => {:method => :get}
10
10
11 map.signin 'login', :controller => 'account', :action => 'login',
11 map.signin 'login', :controller => 'account', :action => 'login',
12 :conditions => {:method => [:get, :post]}
12 :conditions => {:method => [:get, :post]}
13 map.signout 'logout', :controller => 'account', :action => 'logout',
13 map.signout 'logout', :controller => 'account', :action => 'logout',
14 :conditions => {:method => :get}
14 :conditions => {:method => :get}
15 map.connect 'account/register', :controller => 'account', :action => 'register',
15 map.connect 'account/register', :controller => 'account', :action => 'register',
16 :conditions => {:method => [:get, :post]}
16 :conditions => {:method => [:get, :post]}
17 map.connect 'account/lost_password', :controller => 'account', :action => 'lost_password',
17 map.connect 'account/lost_password', :controller => 'account', :action => 'lost_password',
18 :conditions => {:method => [:get, :post]}
18 :conditions => {:method => [:get, :post]}
19 map.connect 'account/activate', :controller => 'account', :action => 'activate',
19 map.connect 'account/activate', :controller => 'account', :action => 'activate',
20 :conditions => {:method => :get}
20 :conditions => {:method => :get}
21
21
22 map.connect 'projects/:id/wiki', :controller => 'wikis',
22 map.connect 'projects/:id/wiki', :controller => 'wikis',
23 :action => 'edit', :conditions => {:method => :post}
23 :action => 'edit', :conditions => {:method => :post}
24 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis',
24 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis',
25 :action => 'destroy', :conditions => {:method => [:get, :post]}
25 :action => 'destroy', :conditions => {:method => [:get, :post]}
26
26
27 map.with_options :controller => 'messages' do |messages_routes|
27 map.with_options :controller => 'messages' do |messages_routes|
28 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
28 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
29 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
29 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
30 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
30 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
31 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
31 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
32 end
32 end
33 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
33 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
34 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
34 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
35 messages_actions.connect 'boards/:board_id/topics/preview', :action => 'preview'
35 messages_actions.connect 'boards/:board_id/topics/preview', :action => 'preview'
36 messages_actions.connect 'boards/:board_id/topics/quote/:id', :action => 'quote'
36 messages_actions.connect 'boards/:board_id/topics/quote/:id', :action => 'quote'
37 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
37 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
38 messages_actions.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
38 messages_actions.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
39 messages_actions.connect 'boards/:board_id/topics/:id/destroy', :action => 'destroy'
39 messages_actions.connect 'boards/:board_id/topics/:id/destroy', :action => 'destroy'
40 end
40 end
41 end
41 end
42
42
43 # Misc issue routes. TODO: move into resources
43 # Misc issue routes. TODO: move into resources
44 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes',
44 map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes',
45 :action => 'issues', :conditions => { :method => :get }
45 :action => 'issues', :conditions => { :method => :get }
46 # TODO: would look nicer as /issues/:id/preview
46 # TODO: would look nicer as /issues/:id/preview
47 map.preview_new_issue '/issues/preview/new/:project_id', :controller => 'previews',
47 map.preview_new_issue '/issues/preview/new/:project_id', :controller => 'previews',
48 :action => 'issue'
48 :action => 'issue'
49 map.preview_edit_issue '/issues/preview/edit/:id', :controller => 'previews',
49 map.preview_edit_issue '/issues/preview/edit/:id', :controller => 'previews',
50 :action => 'issue'
50 :action => 'issue'
51 map.issues_context_menu '/issues/context_menu',
51 map.issues_context_menu '/issues/context_menu',
52 :controller => 'context_menus', :action => 'issues'
52 :controller => 'context_menus', :action => 'issues'
53
53
54 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
54 map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
55 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new',
55 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new',
56 :id => /\d+/, :conditions => { :method => :post }
56 :id => /\d+/, :conditions => { :method => :post }
57
57
58 map.connect '/journals/diff/:id', :controller => 'journals', :action => 'diff',
58 map.connect '/journals/diff/:id', :controller => 'journals', :action => 'diff',
59 :id => /\d+/, :conditions => { :method => :get }
59 :id => /\d+/, :conditions => { :method => :get }
60 map.connect '/journals/edit/:id', :controller => 'journals', :action => 'edit',
60 map.connect '/journals/edit/:id', :controller => 'journals', :action => 'edit',
61 :id => /\d+/, :conditions => { :method => [:get, :post] }
61 :id => /\d+/, :conditions => { :method => [:get, :post] }
62
62
63 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
63 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
64 gantts_routes.connect '/projects/:project_id/issues/gantt'
64 gantts_routes.connect '/projects/:project_id/issues/gantt'
65 gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
65 gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
66 gantts_routes.connect '/issues/gantt.:format'
66 gantts_routes.connect '/issues/gantt.:format'
67 end
67 end
68
68
69 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
69 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
70 calendars_routes.connect '/projects/:project_id/issues/calendar'
70 calendars_routes.connect '/projects/:project_id/issues/calendar'
71 calendars_routes.connect '/issues/calendar'
71 calendars_routes.connect '/issues/calendar'
72 end
72 end
73
73
74 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
74 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
75 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
75 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
76 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
76 reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
77 end
77 end
78
78
79 map.connect 'my/account', :controller => 'my', :action => 'account',
79 map.connect 'my/account', :controller => 'my', :action => 'account',
80 :conditions => {:method => [:get, :post]}
80 :conditions => {:method => [:get, :post]}
81 map.connect 'my/page', :controller => 'my', :action => 'page',
81 map.connect 'my/page', :controller => 'my', :action => 'page',
82 :conditions => {:method => :get}
82 :conditions => {:method => :get}
83 # Redirects to my/page
83 # Redirects to my/page
84 map.connect 'my', :controller => 'my', :action => 'index',
84 map.connect 'my', :controller => 'my', :action => 'index',
85 :conditions => {:method => :get}
85 :conditions => {:method => :get}
86 map.connect 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key',
86 map.connect 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key',
87 :conditions => {:method => :post}
87 :conditions => {:method => :post}
88 map.connect 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key',
88 map.connect 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key',
89 :conditions => {:method => :post}
89 :conditions => {:method => :post}
90 map.connect 'my/password', :controller => 'my', :action => 'password',
90 map.connect 'my/password', :controller => 'my', :action => 'password',
91 :conditions => {:method => [:get, :post]}
91 :conditions => {:method => [:get, :post]}
92 map.connect 'my/page_layout', :controller => 'my', :action => 'page_layout',
92 map.connect 'my/page_layout', :controller => 'my', :action => 'page_layout',
93 :conditions => {:method => :get}
93 :conditions => {:method => :get}
94 map.connect 'my/add_block', :controller => 'my', :action => 'add_block',
94 map.connect 'my/add_block', :controller => 'my', :action => 'add_block',
95 :conditions => {:method => :post}
95 :conditions => {:method => :post}
96 map.connect 'my/remove_block', :controller => 'my', :action => 'remove_block',
96 map.connect 'my/remove_block', :controller => 'my', :action => 'remove_block',
97 :conditions => {:method => :post}
97 :conditions => {:method => :post}
98 map.connect 'my/order_blocks', :controller => 'my', :action => 'order_blocks',
98 map.connect 'my/order_blocks', :controller => 'my', :action => 'order_blocks',
99 :conditions => {:method => :post}
99 :conditions => {:method => :post}
100
100
101 map.with_options :controller => 'users' do |users|
101 map.with_options :controller => 'users' do |users|
102 users.user_membership 'users/:id/memberships/:membership_id',
102 users.user_membership 'users/:id/memberships/:membership_id',
103 :action => 'edit_membership',
103 :action => 'edit_membership',
104 :conditions => {:method => :put}
104 :conditions => {:method => :put}
105 users.connect 'users/:id/memberships/:membership_id',
105 users.connect 'users/:id/memberships/:membership_id',
106 :action => 'destroy_membership',
106 :action => 'destroy_membership',
107 :conditions => {:method => :delete}
107 :conditions => {:method => :delete}
108 users.user_memberships 'users/:id/memberships',
108 users.user_memberships 'users/:id/memberships',
109 :action => 'edit_membership',
109 :action => 'edit_membership',
110 :conditions => {:method => :post}
110 :conditions => {:method => :post}
111 end
111 end
112 map.resources :users
112 map.resources :users
113
113
114 # For nice "roadmap" in the url for the index action
114 # For nice "roadmap" in the url for the index action
115 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
115 map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
116
116
117 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
117 map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
118 map.connect 'news/:id/comments', :controller => 'comments',
118 map.connect 'news/:id/comments', :controller => 'comments',
119 :action => 'create', :conditions => {:method => :post}
119 :action => 'create', :conditions => {:method => :post}
120 map.connect 'news/:id/comments/:comment_id', :controller => 'comments',
120 map.connect 'news/:id/comments/:comment_id', :controller => 'comments',
121 :action => 'destroy', :conditions => {:method => :delete}
121 :action => 'destroy', :conditions => {:method => :delete}
122
122
123 map.connect 'watchers/new', :controller=> 'watchers', :action => 'new',
123 map.connect 'watchers/new', :controller=> 'watchers', :action => 'new',
124 :conditions => {:method => :get}
124 :conditions => {:method => :get}
125 map.connect 'watchers', :controller=> 'watchers', :action => 'create',
125 map.connect 'watchers', :controller=> 'watchers', :action => 'create',
126 :conditions => {:method => :post}
126 :conditions => {:method => :post}
127 map.connect 'watchers/destroy', :controller=> 'watchers', :action => 'destroy',
127 map.connect 'watchers/destroy', :controller=> 'watchers', :action => 'destroy',
128 :conditions => {:method => :post}
128 :conditions => {:method => :post}
129 map.connect 'watchers/watch', :controller=> 'watchers', :action => 'watch',
129 map.connect 'watchers/watch', :controller=> 'watchers', :action => 'watch',
130 :conditions => {:method => :post}
130 :conditions => {:method => :post}
131 map.connect 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch',
131 map.connect 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch',
132 :conditions => {:method => :post}
132 :conditions => {:method => :post}
133 map.connect 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user',
133 map.connect 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user',
134 :conditions => {:method => :get}
134 :conditions => {:method => :get}
135
135
136 # TODO: port to be part of the resources route(s)
136 # TODO: port to be part of the resources route(s)
137 map.with_options :conditions => {:method => :get} do |project_views|
137 map.with_options :conditions => {:method => :get} do |project_views|
138 project_views.connect 'projects/:id/settings/:tab',
138 project_views.connect 'projects/:id/settings/:tab',
139 :controller => 'projects', :action => 'settings'
139 :controller => 'projects', :action => 'settings'
140 project_views.connect 'projects/:project_id/issues/:copy_from/copy',
140 project_views.connect 'projects/:project_id/issues/:copy_from/copy',
141 :controller => 'issues', :action => 'new'
141 :controller => 'issues', :action => 'new'
142 end
142 end
143
143
144 map.resources :projects, :member => {
144 map.resources :projects, :member => {
145 :copy => [:get, :post],
145 :copy => [:get, :post],
146 :settings => :get,
146 :settings => :get,
147 :modules => :post,
147 :modules => :post,
148 :archive => :post,
148 :archive => :post,
149 :unarchive => :post
149 :unarchive => :post
150 } do |project|
150 } do |project|
151 project.resource :enumerations, :controller => 'project_enumerations',
151 project.resource :enumerations, :controller => 'project_enumerations',
152 :only => [:update, :destroy]
152 :only => [:update, :destroy]
153 # issue form update
153 # issue form update
154 project.issue_form 'issues/new', :controller => 'issues',
154 project.issue_form 'issues/new', :controller => 'issues',
155 :action => 'new', :conditions => {:method => [:post, :put]}
155 :action => 'new', :conditions => {:method => [:post, :put]}
156 project.resources :issues, :only => [:index, :new, :create] do |issues|
156 project.resources :issues, :only => [:index, :new, :create] do |issues|
157 issues.resources :time_entries, :controller => 'timelog',
157 issues.resources :time_entries, :controller => 'timelog',
158 :collection => {:report => :get}
158 :collection => {:report => :get}
159 end
159 end
160
160
161 project.resources :files, :only => [:index, :new, :create]
161 project.resources :files, :only => [:index, :new, :create]
162 project.resources :versions, :shallow => true,
162 project.resources :versions, :shallow => true,
163 :collection => {:close_completed => :put},
163 :collection => {:close_completed => :put},
164 :member => {:status_by => :post}
164 :member => {:status_by => :post}
165 project.resources :news, :shallow => true
165 project.resources :news, :shallow => true
166 project.resources :time_entries, :controller => 'timelog',
166 project.resources :time_entries, :controller => 'timelog',
167 :collection => {:report => :get}
167 :collection => {:report => :get}
168 project.resources :queries, :only => [:new, :create]
168 project.resources :queries, :only => [:new, :create]
169 project.resources :issue_categories, :shallow => true
169 project.resources :issue_categories, :shallow => true
170 project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
170 project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
171 project.resources :boards
171 project.resources :boards
172 project.resources :repositories, :shallow => true, :except => [:index, :show],
172 project.resources :repositories, :shallow => true, :except => [:index, :show],
173 :member => {:committers => [:get, :post]}
173 :member => {:committers => [:get, :post]}
174 project.resources :memberships, :shallow => true, :controller => 'members',
174 project.resources :memberships, :shallow => true, :controller => 'members',
175 :only => [:index, :show, :create, :update, :destroy],
175 :only => [:index, :show, :create, :update, :destroy],
176 :collection => {:autocomplete => :get}
176 :collection => {:autocomplete => :get}
177
177
178 project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
178 project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
179 project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
179 project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
180 project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
180 project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
181 project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
181 project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
182 project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
182 project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
183 project.resources :wiki, :except => [:new, :create], :member => {
183 project.resources :wiki, :except => [:new, :create], :member => {
184 :rename => [:get, :post],
184 :rename => [:get, :post],
185 :history => :get,
185 :history => :get,
186 :preview => :any,
186 :preview => :any,
187 :protect => :post,
187 :protect => :post,
188 :add_attachment => :post
188 :add_attachment => :post
189 }, :collection => {
189 }, :collection => {
190 :export => :get,
190 :export => :get,
191 :date_index => :get
191 :date_index => :get
192 }
192 }
193 end
193 end
194
194
195 map.connect 'news', :controller => 'news', :action => 'index'
195 map.connect 'news', :controller => 'news', :action => 'index'
196 map.connect 'news.:format', :controller => 'news', :action => 'index'
196 map.connect 'news.:format', :controller => 'news', :action => 'index'
197
197
198 map.resources :queries, :except => [:show]
198 map.resources :queries, :except => [:show]
199 map.resources :issues,
199 map.resources :issues,
200 :collection => {:bulk_edit => [:get, :post], :bulk_update => :post} do |issues|
200 :collection => {:bulk_edit => [:get, :post], :bulk_update => :post} do |issues|
201 issues.resources :time_entries, :controller => 'timelog',
201 issues.resources :time_entries, :controller => 'timelog',
202 :collection => {:report => :get}
202 :collection => {:report => :get}
203 issues.resources :relations, :shallow => true,
203 issues.resources :relations, :shallow => true,
204 :controller => 'issue_relations',
204 :controller => 'issue_relations',
205 :only => [:index, :show, :create, :destroy]
205 :only => [:index, :show, :create, :destroy]
206 end
206 end
207 # Bulk deletion
207 # Bulk deletion
208 map.connect '/issues', :controller => 'issues', :action => 'destroy',
208 map.connect '/issues', :controller => 'issues', :action => 'destroy',
209 :conditions => {:method => :delete}
209 :conditions => {:method => :delete}
210
210
211 map.connect '/time_entries/destroy',
211 map.connect '/time_entries/destroy',
212 :controller => 'timelog', :action => 'destroy',
212 :controller => 'timelog', :action => 'destroy',
213 :conditions => { :method => :delete }
213 :conditions => { :method => :delete }
214 map.time_entries_context_menu '/time_entries/context_menu',
214 map.time_entries_context_menu '/time_entries/context_menu',
215 :controller => 'context_menus', :action => 'time_entries'
215 :controller => 'context_menus', :action => 'time_entries'
216
216
217 map.resources :time_entries, :controller => 'timelog',
217 map.resources :time_entries, :controller => 'timelog',
218 :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post}
218 :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post}
219
219
220 map.with_options :controller => 'activities', :action => 'index',
220 map.with_options :controller => 'activities', :action => 'index',
221 :conditions => {:method => :get} do |activity|
221 :conditions => {:method => :get} do |activity|
222 activity.connect 'projects/:id/activity'
222 activity.connect 'projects/:id/activity'
223 activity.connect 'projects/:id/activity.:format'
223 activity.connect 'projects/:id/activity.:format'
224 activity.connect 'activity', :id => nil
224 activity.connect 'activity', :id => nil
225 activity.connect 'activity.:format', :id => nil
225 activity.connect 'activity.:format', :id => nil
226 end
226 end
227
227
228 map.with_options :controller => 'repositories' do |repositories|
228 map.with_options :controller => 'repositories' do |repositories|
229 repositories.with_options :conditions => {:method => :get} do |repository_views|
229 repositories.with_options :conditions => {:method => :get} do |repository_views|
230 repository_views.connect 'projects/:id/repository',
230 repository_views.connect 'projects/:id/repository',
231 :action => 'show'
231 :action => 'show'
232
232
233 repository_views.connect 'projects/:id/repository/:repository_id/statistics',
233 repository_views.connect 'projects/:id/repository/:repository_id/statistics',
234 :action => 'stats'
234 :action => 'stats'
235 repository_views.connect 'projects/:id/repository/:repository_id/graph',
235 repository_views.connect 'projects/:id/repository/:repository_id/graph',
236 :action => 'graph'
236 :action => 'graph'
237
237
238 repository_views.connect 'projects/:id/repository/statistics',
238 repository_views.connect 'projects/:id/repository/statistics',
239 :action => 'stats'
239 :action => 'stats'
240 repository_views.connect 'projects/:id/repository/graph',
240 repository_views.connect 'projects/:id/repository/graph',
241 :action => 'graph'
241 :action => 'graph'
242
242
243 repository_views.connect 'projects/:id/repository/:repository_id/revisions',
243 repository_views.connect 'projects/:id/repository/:repository_id/revisions',
244 :action => 'revisions'
244 :action => 'revisions'
245 repository_views.connect 'projects/:id/repository/:repository_id/revisions.:format',
245 repository_views.connect 'projects/:id/repository/:repository_id/revisions.:format',
246 :action => 'revisions'
246 :action => 'revisions'
247 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev',
247 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev',
248 :action => 'revision'
248 :action => 'revision'
249 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues',
249 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues',
250 :action => 'add_related_issue', :conditions => {:method => :post}
250 :action => 'add_related_issue', :conditions => {:method => :post}
251 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id',
251 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id',
252 :action => 'remove_related_issue', :conditions => {:method => :delete}
252 :action => 'remove_related_issue', :conditions => {:method => :delete}
253 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff',
253 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff',
254 :action => 'diff'
254 :action => 'diff'
255 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff.:format',
255 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff.:format',
256 :action => 'diff'
256 :action => 'diff'
257 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/raw/*path',
257 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/raw/*path',
258 :action => 'entry', :format => 'raw'
258 :action => 'entry', :format => 'raw'
259 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/:action/*path',
259 repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/:action/*path',
260 :requirements => {
260 :requirements => {
261 :action => /(browse|show|entry|changes|annotate|diff)/,
261 :action => /(browse|show|entry|changes|annotate|diff)/,
262 :rev => /[a-z0-9\.\-_]+/
262 :rev => /[a-z0-9\.\-_]+/
263 }
263 }
264 repository_views.connect 'projects/:id/repository/:repository_id/raw/*path',
264 repository_views.connect 'projects/:id/repository/:repository_id/raw/*path',
265 :action => 'entry', :format => 'raw'
265 :action => 'entry', :format => 'raw'
266 repository_views.connect 'projects/:id/repository/:repository_id/:action/*path',
266 repository_views.connect 'projects/:id/repository/:repository_id/:action/*path',
267 :requirements => { :action => /(browse|entry|changes|annotate|diff)/ }
267 :requirements => { :action => /(browse|entry|changes|annotate|diff)/ }
268 repository_views.connect 'projects/:id/repository/:repository_id/show/*path',
268 repository_views.connect 'projects/:id/repository/:repository_id/show/*path',
269 :requirements => { :path => /.+/ }
269 :requirements => { :path => /.+/ }
270
270
271 repository_views.connect 'projects/:id/repository/revisions',
271 repository_views.connect 'projects/:id/repository/revisions',
272 :action => 'revisions'
272 :action => 'revisions'
273 repository_views.connect 'projects/:id/repository/revisions.:format',
273 repository_views.connect 'projects/:id/repository/revisions.:format',
274 :action => 'revisions'
274 :action => 'revisions'
275 repository_views.connect 'projects/:id/repository/revisions/:rev',
275 repository_views.connect 'projects/:id/repository/revisions/:rev',
276 :action => 'revision'
276 :action => 'revision'
277 repository_views.connect 'projects/:id/repository/revisions/:rev/issues',
277 repository_views.connect 'projects/:id/repository/revisions/:rev/issues',
278 :action => 'add_related_issue', :conditions => {:method => :post}
278 :action => 'add_related_issue', :conditions => {:method => :post}
279 repository_views.connect 'projects/:id/repository/revisions/:rev/issues/:issue_id',
279 repository_views.connect 'projects/:id/repository/revisions/:rev/issues/:issue_id',
280 :action => 'remove_related_issue', :conditions => {:method => :delete}
280 :action => 'remove_related_issue', :conditions => {:method => :delete}
281 repository_views.connect 'projects/:id/repository/revisions/:rev/diff',
281 repository_views.connect 'projects/:id/repository/revisions/:rev/diff',
282 :action => 'diff'
282 :action => 'diff'
283 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format',
283 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format',
284 :action => 'diff'
284 :action => 'diff'
285 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path',
285 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path',
286 :action => 'entry', :format => 'raw'
286 :action => 'entry', :format => 'raw'
287 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path',
287 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path',
288 :requirements => {
288 :requirements => {
289 :action => /(browse|show|entry|changes|annotate|diff)/,
289 :action => /(browse|show|entry|changes|annotate|diff)/,
290 :rev => /[a-z0-9\.\-_]+/
290 :rev => /[a-z0-9\.\-_]+/
291 }
291 }
292 repository_views.connect 'projects/:id/repository/raw/*path',
292 repository_views.connect 'projects/:id/repository/raw/*path',
293 :action => 'entry', :format => 'raw'
293 :action => 'entry', :format => 'raw'
294 repository_views.connect 'projects/:id/repository/:action/*path',
294 repository_views.connect 'projects/:id/repository/:action/*path',
295 :requirements => { :action => /(browse|show|entry|changes|annotate|diff)/ }
295 :requirements => { :action => /(browse|show|entry|changes|annotate|diff)/ }
296
296
297 repository_views.connect 'projects/:id/repository/:repository_id',
297 repository_views.connect 'projects/:id/repository/:repository_id',
298 :action => 'show'
298 :action => 'show'
299 end
299 end
300
300
301 repositories.connect 'projects/:id/repository/revision',
301 repositories.connect 'projects/:id/repository/revision',
302 :action => 'revision',
302 :action => 'revision',
303 :conditions => {:method => [:get, :post]}
303 :conditions => {:method => [:get, :post]}
304 end
304 end
305
305
306 # additional routes for having the file name at the end of url
306 # additional routes for having the file name at the end of url
307 map.connect 'attachments/:id/:filename', :controller => 'attachments',
307 map.connect 'attachments/:id/:filename', :controller => 'attachments',
308 :action => 'show', :id => /\d+/, :filename => /.*/,
308 :action => 'show', :id => /\d+/, :filename => /.*/,
309 :conditions => {:method => :get}
309 :conditions => {:method => :get}
310 map.connect 'attachments/download/:id/:filename', :controller => 'attachments',
310 map.connect 'attachments/download/:id/:filename', :controller => 'attachments',
311 :action => 'download', :id => /\d+/, :filename => /.*/,
311 :action => 'download', :id => /\d+/, :filename => /.*/,
312 :conditions => {:method => :get}
312 :conditions => {:method => :get}
313 map.connect 'attachments/download/:id', :controller => 'attachments',
313 map.connect 'attachments/download/:id', :controller => 'attachments',
314 :action => 'download', :id => /\d+/,
314 :action => 'download', :id => /\d+/,
315 :conditions => {:method => :get}
315 :conditions => {:method => :get}
316 map.resources :attachments, :only => [:show, :destroy]
316 map.resources :attachments, :only => [:show, :destroy]
317
317
318 map.resources :groups, :member => {:autocomplete_for_user => :get}
318 map.resources :groups, :member => {:autocomplete_for_user => :get}
319 map.group_users 'groups/:id/users', :controller => 'groups',
319 map.group_users 'groups/:id/users', :controller => 'groups',
320 :action => 'add_users', :id => /\d+/,
320 :action => 'add_users', :id => /\d+/,
321 :conditions => {:method => :post}
321 :conditions => {:method => :post}
322 map.group_user 'groups/:id/users/:user_id', :controller => 'groups',
322 map.group_user 'groups/:id/users/:user_id', :controller => 'groups',
323 :action => 'remove_user', :id => /\d+/,
323 :action => 'remove_user', :id => /\d+/,
324 :conditions => {:method => :delete}
324 :conditions => {:method => :delete}
325 map.connect 'groups/destroy_membership/:id', :controller => 'groups',
325 map.connect 'groups/destroy_membership/:id', :controller => 'groups',
326 :action => 'destroy_membership', :id => /\d+/,
326 :action => 'destroy_membership', :id => /\d+/,
327 :conditions => {:method => :post}
327 :conditions => {:method => :post}
328 map.connect 'groups/edit_membership/:id', :controller => 'groups',
328 map.connect 'groups/edit_membership/:id', :controller => 'groups',
329 :action => 'edit_membership', :id => /\d+/,
329 :action => 'edit_membership', :id => /\d+/,
330 :conditions => {:method => :post}
330 :conditions => {:method => :post}
331
331
332 map.resources :trackers, :except => :show
332 map.resources :trackers, :except => :show
333 map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
333 map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
334 map.resources :custom_fields, :except => :show
334 map.resources :custom_fields, :except => :show
335 map.resources :roles, :except => :show, :collection => {:permissions => [:get, :post]}
335 map.resources :roles, :except => :show, :collection => {:permissions => [:get, :post]}
336 map.resources :enumerations, :except => :show
336 map.resources :enumerations, :except => :show
337
337
338 map.connect 'search', :controller => 'search', :action => 'index', :conditions => {:method => :get}
338 map.connect 'search', :controller => 'search', :action => 'index', :conditions => {:method => :get}
339
339
340 map.connect 'mail_handler', :controller => 'mail_handler',
340 map.connect 'mail_handler', :controller => 'mail_handler',
341 :action => 'index', :conditions => {:method => :post}
341 :action => 'index', :conditions => {:method => :post}
342
342
343 map.connect 'admin', :controller => 'admin', :action => 'index',
343 map.connect 'admin', :controller => 'admin', :action => 'index',
344 :conditions => {:method => :get}
344 :conditions => {:method => :get}
345 map.connect 'admin/projects', :controller => 'admin', :action => 'projects',
345 map.connect 'admin/projects', :controller => 'admin', :action => 'projects',
346 :conditions => {:method => :get}
346 :conditions => {:method => :get}
347 map.connect 'admin/plugins', :controller => 'admin', :action => 'plugins',
347 map.connect 'admin/plugins', :controller => 'admin', :action => 'plugins',
348 :conditions => {:method => :get}
348 :conditions => {:method => :get}
349 map.connect 'admin/info', :controller => 'admin', :action => 'info',
349 map.connect 'admin/info', :controller => 'admin', :action => 'info',
350 :conditions => {:method => :get}
350 :conditions => {:method => :get}
351 map.connect 'admin/test_email', :controller => 'admin', :action => 'test_email',
351 map.connect 'admin/test_email', :controller => 'admin', :action => 'test_email',
352 :conditions => {:method => :get}
352 :conditions => {:method => :get}
353 map.connect 'admin/default_configuration', :controller => 'admin',
353 map.connect 'admin/default_configuration', :controller => 'admin',
354 :action => 'default_configuration', :conditions => {:method => :post}
354 :action => 'default_configuration', :conditions => {:method => :post}
355
355
356 # Used by AuthSourcesControllerTest
356 map.resources :auth_sources, :member => {:test_connection => :get}
357 # TODO : refactor *AuthSourcesController to remove these routes
358 map.connect 'auth_sources', :controller => 'auth_sources',
359 :action => 'index', :conditions => {:method => :get}
360 map.connect 'auth_sources/new', :controller => 'auth_sources',
361 :action => 'new', :conditions => {:method => :get}
362 map.connect 'auth_sources/create', :controller => 'auth_sources',
363 :action => 'create', :conditions => {:method => :post}
364 map.connect 'auth_sources/destroy/:id', :controller => 'auth_sources',
365 :action => 'destroy', :id => /\d+/, :conditions => {:method => :post}
366 map.connect 'auth_sources/test_connection/:id', :controller => 'auth_sources',
367 :action => 'test_connection', :conditions => {:method => :get}
368 map.connect 'auth_sources/edit/:id', :controller => 'auth_sources',
369 :action => 'edit', :id => /\d+/, :conditions => {:method => :get}
370 map.connect 'auth_sources/update/:id', :controller => 'auth_sources',
371 :action => 'update', :id => /\d+/, :conditions => {:method => :post}
372
357
373 map.connect 'workflows', :controller => 'workflows',
358 map.connect 'workflows', :controller => 'workflows',
374 :action => 'index', :conditions => {:method => :get}
359 :action => 'index', :conditions => {:method => :get}
375 map.connect 'workflows/edit', :controller => 'workflows',
360 map.connect 'workflows/edit', :controller => 'workflows',
376 :action => 'edit', :conditions => {:method => [:get, :post]}
361 :action => 'edit', :conditions => {:method => [:get, :post]}
377 map.connect 'workflows/copy', :controller => 'workflows',
362 map.connect 'workflows/copy', :controller => 'workflows',
378 :action => 'copy', :conditions => {:method => [:get, :post]}
363 :action => 'copy', :conditions => {:method => [:get, :post]}
379
364
380 map.connect 'settings', :controller => 'settings',
365 map.connect 'settings', :controller => 'settings',
381 :action => 'index', :conditions => {:method => :get}
366 :action => 'index', :conditions => {:method => :get}
382 map.connect 'settings/edit', :controller => 'settings',
367 map.connect 'settings/edit', :controller => 'settings',
383 :action => 'edit', :conditions => {:method => [:get, :post]}
368 :action => 'edit', :conditions => {:method => [:get, :post]}
384 map.connect 'settings/plugin/:id', :controller => 'settings',
369 map.connect 'settings/plugin/:id', :controller => 'settings',
385 :action => 'plugin', :conditions => {:method => [:get, :post]}
370 :action => 'plugin', :conditions => {:method => [:get, :post]}
386
371
387 map.with_options :controller => 'sys' do |sys|
372 map.with_options :controller => 'sys' do |sys|
388 sys.connect 'sys/projects.:format',
373 sys.connect 'sys/projects.:format',
389 :action => 'projects',
374 :action => 'projects',
390 :conditions => {:method => :get}
375 :conditions => {:method => :get}
391 sys.connect 'sys/projects/:id/repository.:format',
376 sys.connect 'sys/projects/:id/repository.:format',
392 :action => 'create_project_repository',
377 :action => 'create_project_repository',
393 :conditions => {:method => :post}
378 :conditions => {:method => :post}
394 sys.connect 'sys/fetch_changesets',
379 sys.connect 'sys/fetch_changesets',
395 :action => 'fetch_changesets',
380 :action => 'fetch_changesets',
396 :conditions => {:method => :get}
381 :conditions => {:method => :get}
397 end
382 end
398
383
399 map.connect 'uploads.:format', :controller => 'attachments', :action => 'upload', :conditions => {:method => :post}
384 map.connect 'uploads.:format', :controller => 'attachments', :action => 'upload', :conditions => {:method => :post}
400
385
401 map.connect 'robots.txt', :controller => 'welcome',
386 map.connect 'robots.txt', :controller => 'welcome',
402 :action => 'robots', :conditions => {:method => :get}
387 :action => 'robots', :conditions => {:method => :get}
403
388
404 # Used for OpenID
389 # Used for OpenID
405 map.root :controller => 'account', :action => 'login'
390 map.root :controller => 'account', :action => 'login'
406 end
391 end
@@ -1,127 +1,127
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class AuthSourcesControllerTest < ActionController::TestCase
20 class AuthSourcesControllerTest < ActionController::TestCase
21 fixtures :users, :auth_sources
21 fixtures :users, :auth_sources
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
29
30 assert_response :success
30 assert_response :success
31 assert_template 'index'
31 assert_template 'index'
32 assert_not_nil assigns(:auth_sources)
32 assert_not_nil assigns(:auth_sources)
33 end
33 end
34
34
35 def test_new
35 def test_new
36 get :new
36 get :new
37
37
38 assert_response :success
38 assert_response :success
39 assert_template 'new'
39 assert_template 'new'
40
40
41 source = assigns(:auth_source)
41 source = assigns(:auth_source)
42 assert_equal AuthSourceLdap, source.class
42 assert_equal AuthSourceLdap, source.class
43 assert source.new_record?
43 assert source.new_record?
44
44
45 assert_tag 'input', :attributes => {:name => 'type', :value => 'AuthSourceLdap'}
45 assert_tag 'input', :attributes => {:name => 'type', :value => 'AuthSourceLdap'}
46 assert_tag 'input', :attributes => {:name => 'auth_source[host]'}
46 assert_tag 'input', :attributes => {:name => 'auth_source[host]'}
47 end
47 end
48
48
49 def test_create
49 def test_create
50 assert_difference 'AuthSourceLdap.count' do
50 assert_difference 'AuthSourceLdap.count' do
51 post :create, :type => 'AuthSourceLdap', :auth_source => {:name => 'Test', :host => '127.0.0.1', :port => '389', :attr_login => 'cn'}
51 post :create, :type => 'AuthSourceLdap', :auth_source => {:name => 'Test', :host => '127.0.0.1', :port => '389', :attr_login => 'cn'}
52 assert_redirected_to '/auth_sources'
52 assert_redirected_to '/auth_sources'
53 end
53 end
54
54
55 source = AuthSourceLdap.first(:order => 'id DESC')
55 source = AuthSourceLdap.first(:order => 'id DESC')
56 assert_equal 'Test', source.name
56 assert_equal 'Test', source.name
57 assert_equal '127.0.0.1', source.host
57 assert_equal '127.0.0.1', source.host
58 assert_equal 389, source.port
58 assert_equal 389, source.port
59 assert_equal 'cn', source.attr_login
59 assert_equal 'cn', source.attr_login
60 end
60 end
61
61
62 def test_create_with_failure
62 def test_create_with_failure
63 assert_no_difference 'AuthSourceLdap.count' do
63 assert_no_difference 'AuthSourceLdap.count' do
64 post :create, :type => 'AuthSourceLdap', :auth_source => {:name => 'Test', :host => '', :port => '389', :attr_login => 'cn'}
64 post :create, :type => 'AuthSourceLdap', :auth_source => {:name => 'Test', :host => '', :port => '389', :attr_login => 'cn'}
65 assert_response :success
65 assert_response :success
66 assert_template 'new'
66 assert_template 'new'
67 end
67 end
68 assert_error_tag :content => /host can't be blank/i
68 assert_error_tag :content => /host can't be blank/i
69 end
69 end
70
70
71 def test_edit
71 def test_edit
72 get :edit, :id => 1
72 get :edit, :id => 1
73
73
74 assert_response :success
74 assert_response :success
75 assert_template 'edit'
75 assert_template 'edit'
76
76
77 assert_tag 'input', :attributes => {:name => 'auth_source[host]'}
77 assert_tag 'input', :attributes => {:name => 'auth_source[host]'}
78 end
78 end
79
79
80 def test_update
80 def test_update
81 post :update, :id => 1, :auth_source => {:name => 'Renamed', :host => '192.168.0.10', :port => '389', :attr_login => 'uid'}
81 put :update, :id => 1, :auth_source => {:name => 'Renamed', :host => '192.168.0.10', :port => '389', :attr_login => 'uid'}
82 assert_redirected_to '/auth_sources'
82 assert_redirected_to '/auth_sources'
83
83
84 source = AuthSourceLdap.find(1)
84 source = AuthSourceLdap.find(1)
85 assert_equal 'Renamed', source.name
85 assert_equal 'Renamed', source.name
86 assert_equal '192.168.0.10', source.host
86 assert_equal '192.168.0.10', source.host
87 end
87 end
88
88
89 def test_update_with_failure
89 def test_update_with_failure
90 post :update, :id => 1, :auth_source => {:name => 'Renamed', :host => '', :port => '389', :attr_login => 'uid'}
90 put :update, :id => 1, :auth_source => {:name => 'Renamed', :host => '', :port => '389', :attr_login => 'uid'}
91 assert_response :success
91 assert_response :success
92 assert_template 'edit'
92 assert_template 'edit'
93 assert_error_tag :content => /host can't be blank/i
93 assert_error_tag :content => /host can't be blank/i
94 end
94 end
95
95
96 def test_destroy
96 def test_destroy
97 assert_difference 'AuthSourceLdap.count', -1 do
97 assert_difference 'AuthSourceLdap.count', -1 do
98 post :destroy, :id => 1
98 delete :destroy, :id => 1
99 end
99 end
100 end
100 end
101
101
102 def test_destroy_auth_source_in_use
102 def test_destroy_auth_source_in_use
103 User.find(2).update_attribute :auth_source_id, 1
103 User.find(2).update_attribute :auth_source_id, 1
104
104
105 assert_no_difference 'AuthSourceLdap.count' do
105 assert_no_difference 'AuthSourceLdap.count' do
106 post :destroy, :id => 1
106 delete :destroy, :id => 1
107 end
107 end
108 end
108 end
109
109
110 def test_test_connection
110 def test_test_connection
111 AuthSourceLdap.any_instance.stubs(:test_connection).returns(true)
111 AuthSourceLdap.any_instance.stubs(:test_connection).returns(true)
112
112
113 get :test_connection, :id => 1
113 get :test_connection, :id => 1
114 assert_redirected_to '/auth_sources'
114 assert_redirected_to '/auth_sources'
115 assert_not_nil flash[:notice]
115 assert_not_nil flash[:notice]
116 assert_match /successful/i, flash[:notice]
116 assert_match /successful/i, flash[:notice]
117 end
117 end
118
118
119 def test_test_connection_with_failure
119 def test_test_connection_with_failure
120 AuthSourceLdap.any_instance.stubs(:test_connection).raises(Exception.new("Something went wrong"))
120 AuthSourceLdap.any_instance.stubs(:test_connection).raises(Exception.new("Something went wrong"))
121
121
122 get :test_connection, :id => 1
122 get :test_connection, :id => 1
123 assert_redirected_to '/auth_sources'
123 assert_redirected_to '/auth_sources'
124 assert_not_nil flash[:error]
124 assert_not_nil flash[:error]
125 assert_include '(Something went wrong)', flash[:error]
125 assert_include '(Something went wrong)', flash[:error]
126 end
126 end
127 end
127 end
@@ -1,55 +1,55
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../../test_helper', __FILE__)
18 require File.expand_path('../../../test_helper', __FILE__)
19
19
20 class RoutingAuthSourcesTest < ActionController::IntegrationTest
20 class RoutingAuthSourcesTest < ActionController::IntegrationTest
21 def test_auth_sources
21 def test_auth_sources
22 assert_routing(
22 assert_routing(
23 { :method => 'get', :path => "/auth_sources" },
23 { :method => 'get', :path => "/auth_sources" },
24 { :controller => 'auth_sources', :action => 'index' }
24 { :controller => 'auth_sources', :action => 'index' }
25 )
25 )
26 assert_routing(
26 assert_routing(
27 { :method => 'get', :path => "/auth_sources/new" },
27 { :method => 'get', :path => "/auth_sources/new" },
28 { :controller => 'auth_sources', :action => 'new' }
28 { :controller => 'auth_sources', :action => 'new' }
29 )
29 )
30 assert_routing(
30 assert_routing(
31 { :method => 'post', :path => "/auth_sources/create" },
31 { :method => 'post', :path => "/auth_sources" },
32 { :controller => 'auth_sources', :action => 'create' }
32 { :controller => 'auth_sources', :action => 'create' }
33 )
33 )
34 assert_routing(
34 assert_routing(
35 { :method => 'post', :path => "/auth_sources/destroy/1234" },
35 { :method => 'get', :path => "/auth_sources/1234/edit" },
36 { :controller => 'auth_sources', :action => 'destroy',
36 { :controller => 'auth_sources', :action => 'edit',
37 :id => '1234' }
37 :id => '1234' }
38 )
38 )
39 assert_routing(
39 assert_routing(
40 { :method => 'get', :path => "/auth_sources/test_connection/1234" },
40 { :method => 'put', :path => "/auth_sources/1234" },
41 { :controller => 'auth_sources', :action => 'test_connection',
41 { :controller => 'auth_sources', :action => 'update',
42 :id => '1234' }
42 :id => '1234' }
43 )
43 )
44 assert_routing(
44 assert_routing(
45 { :method => 'get', :path => "/auth_sources/edit/1234" },
45 { :method => 'delete', :path => "/auth_sources/1234" },
46 { :controller => 'auth_sources', :action => 'edit',
46 { :controller => 'auth_sources', :action => 'destroy',
47 :id => '1234' }
47 :id => '1234' }
48 )
48 )
49 assert_routing(
49 assert_routing(
50 { :method => 'post', :path => "/auth_sources/update/1234" },
50 { :method => 'get', :path => "/auth_sources/1234/test_connection" },
51 { :controller => 'auth_sources', :action => 'update',
51 { :controller => 'auth_sources', :action => 'test_connection',
52 :id => '1234' }
52 :id => '1234' }
53 )
53 )
54 end
54 end
55 end
55 end
General Comments 0
You need to be logged in to leave comments. Login now