Commit a01ff91385134979cd0b5053476819d6b1efa5f2
1 parent
31b7f322
Exists in
master
and in
27 other branches
rails3: fix ldap plugin
Showing
6 changed files
with
11 additions
and
12 deletions
Show diff stats
| @@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
| 1 | +gem "net-ldap" |
plugins/ldap/lib/ext/environment.rb
| @@ -6,6 +6,8 @@ class Environment | @@ -6,6 +6,8 @@ class Environment | ||
| 6 | 6 | ||
| 7 | validates_presence_of :ldap_plugin_host, :if => lambda {|env| !env.ldap_plugin.blank? } | 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 | def ldap_plugin_attributes | 11 | def ldap_plugin_attributes |
| 10 | self.ldap_plugin || {} | 12 | self.ldap_plugin || {} |
| 11 | end | 13 | end |
plugins/ldap/lib/ldap_plugin.rb
| @@ -70,7 +70,7 @@ class LdapPlugin < Noosfero::Plugin | @@ -70,7 +70,7 @@ class LdapPlugin < Noosfero::Plugin | ||
| 70 | end | 70 | end |
| 71 | 71 | ||
| 72 | def login_extra_contents | 72 | def login_extra_contents |
| 73 | - lambda do | 73 | + proc do |
| 74 | @person = Person.new(:environment => @environment) | 74 | @person = Person.new(:environment => @environment) |
| 75 | @profile_data = @person | 75 | @profile_data = @person |
| 76 | labelled_fields_for :profile_data, @person do |f| | 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,10 +7,6 @@ class LdapPluginAdminController; def rescue_action(e) raise e end; end | ||
| 7 | class LdapPluginAdminControllerTest < ActionController::TestCase | 7 | class LdapPluginAdminControllerTest < ActionController::TestCase |
| 8 | 8 | ||
| 9 | def setup | 9 | def setup |
| 10 | - @controller = LdapPluginAdminController.new | ||
| 11 | - @request = ActionController::TestRequest.new | ||
| 12 | - @response = ActionController::TestResponse.new | ||
| 13 | - | ||
| 14 | @environment = Environment.default | 10 | @environment = Environment.default |
| 15 | user_login = create_admin_user(@environment) | 11 | user_login = create_admin_user(@environment) |
| 16 | login_as(user_login) | 12 | login_as(user_login) |
| @@ -33,7 +29,7 @@ class LdapPluginAdminControllerTest < ActionController::TestCase | @@ -33,7 +29,7 @@ class LdapPluginAdminControllerTest < ActionController::TestCase | ||
| 33 | @environment.save | 29 | @environment.save |
| 34 | assert_nil @environment.ldap_plugin_host | 30 | assert_nil @environment.ldap_plugin_host |
| 35 | post :update, :environment => { :ldap_plugin_host => 'http://something' } | 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 | end | 33 | end |
| 38 | 34 | ||
| 39 | should 'wrong ldap update display a message unsuccessfully' do | 35 | should 'wrong ldap update display a message unsuccessfully' do |
| @@ -41,7 +37,7 @@ class LdapPluginAdminControllerTest < ActionController::TestCase | @@ -41,7 +37,7 @@ class LdapPluginAdminControllerTest < ActionController::TestCase | ||
| 41 | @environment.save | 37 | @environment.save |
| 42 | assert_nil @environment.ldap_plugin_host | 38 | assert_nil @environment.ldap_plugin_host |
| 43 | post :update, :environment => { :ldap_plugin_host => '' } | 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 | end | 41 | end |
| 46 | 42 | ||
| 47 | should 'update ldap successfully render index template' do | 43 | should 'update ldap successfully render index template' do |
plugins/ldap/test/unit/ext/environment_test.rb
| @@ -167,20 +167,20 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -167,20 +167,20 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
| 167 | @enviroment.ldap_plugin= {:port => 3000} | 167 | @enviroment.ldap_plugin= {:port => 3000} |
| 168 | @enviroment.valid? | 168 | @enviroment.valid? |
| 169 | 169 | ||
| 170 | - assert @enviroment.errors.invalid?(:ldap_plugin_host) | 170 | + assert @enviroment.errors.include?(:ldap_plugin_host) |
| 171 | 171 | ||
| 172 | @enviroment.ldap_plugin_host= "http://somehost.com" | 172 | @enviroment.ldap_plugin_host= "http://somehost.com" |
| 173 | @enviroment.valid? | 173 | @enviroment.valid? |
| 174 | - assert !@enviroment.errors.invalid?(:ldap_plugin_host) | 174 | + assert !@enviroment.errors.include?(:ldap_plugin_host) |
| 175 | end | 175 | end |
| 176 | 176 | ||
| 177 | should 'validates presence of host only if some ldap configuration is defined' do | 177 | should 'validates presence of host only if some ldap configuration is defined' do |
| 178 | @enviroment.valid? | 178 | @enviroment.valid? |
| 179 | - assert !@enviroment.errors.invalid?(:ldap_plugin_host) | 179 | + assert !@enviroment.errors.include?(:ldap_plugin_host) |
| 180 | 180 | ||
| 181 | @enviroment.ldap_plugin= {:port => 3000} | 181 | @enviroment.ldap_plugin= {:port => 3000} |
| 182 | @enviroment.valid? | 182 | @enviroment.valid? |
| 183 | - assert @enviroment.errors.invalid?(:ldap_plugin_host) | 183 | + assert @enviroment.errors.include?(:ldap_plugin_host) |
| 184 | end | 184 | end |
| 185 | 185 | ||
| 186 | end | 186 | end |
plugins/ldap/views/ldap_plugin_admin/index.html.erb
| 1 | <h1><%= _("Ldap Management") %> </h1> | 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 | <table> | 5 | <table> |
| 6 | <tr> | 6 | <tr> |