Commit a01ff91385134979cd0b5053476819d6b1efa5f2

Authored by Victor Costa
1 parent 31b7f322

rails3: fix ldap plugin

plugins/ldap/Gemfile 0 → 100644
... ... @@ -0,0 +1 @@
  1 +gem "net-ldap"
... ...
plugins/ldap/lib/ext/environment.rb
... ... @@ -6,6 +6,8 @@ class Environment
6 6  
7 7 validates_presence_of :ldap_plugin_host, :if => lambda {|env| !env.ldap_plugin.blank? }
8 8  
  9 + attr_accessible :ldap_plugin_host, :ldap_plugin_port, :ldap_plugin_tls, :ldap_plugin_onthefly_register, :ldap_plugin_account, :ldap_plugin_account_password, :ldap_plugin_filter, :ldap_plugin_base_dn, :ldap_plugin_attr_mail, :ldap_plugin_attr_login, :ldap_plugin_attr_fullname
  10 +
9 11 def ldap_plugin_attributes
10 12 self.ldap_plugin || {}
11 13 end
... ...
plugins/ldap/lib/ldap_plugin.rb
... ... @@ -70,7 +70,7 @@ class LdapPlugin < Noosfero::Plugin
70 70 end
71 71  
72 72 def login_extra_contents
73   - lambda do
  73 + proc do
74 74 @person = Person.new(:environment => @environment)
75 75 @profile_data = @person
76 76 labelled_fields_for :profile_data, @person do |f|
... ...
plugins/ldap/test/functional/ldap_plugin_admin_controller_test.rb
... ... @@ -7,10 +7,6 @@ class LdapPluginAdminController; def rescue_action(e) raise e end; end
7 7 class LdapPluginAdminControllerTest < ActionController::TestCase
8 8  
9 9 def setup
10   - @controller = LdapPluginAdminController.new
11   - @request = ActionController::TestRequest.new
12   - @response = ActionController::TestResponse.new
13   -
14 10 @environment = Environment.default
15 11 user_login = create_admin_user(@environment)
16 12 login_as(user_login)
... ... @@ -33,7 +29,7 @@ class LdapPluginAdminControllerTest &lt; ActionController::TestCase
33 29 @environment.save
34 30 assert_nil @environment.ldap_plugin_host
35 31 post :update, :environment => { :ldap_plugin_host => 'http://something' }
36   - assert_equal 'Ldap configuration updated successfully.', @response.session[:notice]
  32 + assert_equal 'Ldap configuration updated successfully.', @request.session[:notice]
37 33 end
38 34  
39 35 should 'wrong ldap update display a message unsuccessfully' do
... ... @@ -41,7 +37,7 @@ class LdapPluginAdminControllerTest &lt; ActionController::TestCase
41 37 @environment.save
42 38 assert_nil @environment.ldap_plugin_host
43 39 post :update, :environment => { :ldap_plugin_host => '' }
44   - assert_equal 'Ldap configuration could not be saved.', @response.session[:notice]
  40 + assert_equal 'Ldap configuration could not be saved.', @request.session[:notice]
45 41 end
46 42  
47 43 should 'update ldap successfully render index template' do
... ...
plugins/ldap/test/unit/ext/environment_test.rb
... ... @@ -167,20 +167,20 @@ class EnvironmentTest &lt; ActiveSupport::TestCase
167 167 @enviroment.ldap_plugin= {:port => 3000}
168 168 @enviroment.valid?
169 169  
170   - assert @enviroment.errors.invalid?(:ldap_plugin_host)
  170 + assert @enviroment.errors.include?(:ldap_plugin_host)
171 171  
172 172 @enviroment.ldap_plugin_host= "http://somehost.com"
173 173 @enviroment.valid?
174   - assert !@enviroment.errors.invalid?(:ldap_plugin_host)
  174 + assert !@enviroment.errors.include?(:ldap_plugin_host)
175 175 end
176 176  
177 177 should 'validates presence of host only if some ldap configuration is defined' do
178 178 @enviroment.valid?
179   - assert !@enviroment.errors.invalid?(:ldap_plugin_host)
  179 + assert !@enviroment.errors.include?(:ldap_plugin_host)
180 180  
181 181 @enviroment.ldap_plugin= {:port => 3000}
182 182 @enviroment.valid?
183   - assert @enviroment.errors.invalid?(:ldap_plugin_host)
  183 + assert @enviroment.errors.include?(:ldap_plugin_host)
184 184 end
185 185  
186 186 end
... ...
plugins/ldap/views/ldap_plugin_admin/index.html.erb
1 1 <h1><%= _("Ldap Management") %> </h1>
2 2  
3   -<% labelled_form_for(:environment, @environment, :url => {:action => 'update'}) do |f| %>
  3 +<%= labelled_form_for(:environment, @environment, :url => {:action => 'update'}) do |f| %>
4 4  
5 5 <table>
6 6 <tr>
... ...