##// 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 %>
@@ -22,7 +22,7
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? %>
@@ -353,22 +353,7 ActionController::Routing::Routes.draw do |map|
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}
@@ -78,7 +78,7 class AuthSourcesControllerTest < ActionController::TestCase
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)
@@ -87,7 +87,7 class AuthSourcesControllerTest < ActionController::TestCase
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
@@ -95,7 +95,7 class AuthSourcesControllerTest < ActionController::TestCase
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
@@ -103,7 +103,7 class AuthSourcesControllerTest < ActionController::TestCase
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
@@ -28,27 +28,27 class RoutingAuthSourcesTest < ActionController::IntegrationTest
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
General Comments 0
You need to be logged in to leave comments. Login now