Commit 48fdc451054c701ce07c60894dfdb0f3f82d76eb
1 parent
5dc512ec
Exists in
master
and in
27 other branches
Fix account controller test
Showing
2 changed files
with
6 additions
and
6 deletions
Show diff stats
app/models/user.rb
| ... | ... | @@ -54,7 +54,7 @@ class User < ActiveRecord::Base |
| 54 | 54 | |
| 55 | 55 | user.person = p |
| 56 | 56 | end |
| 57 | - if user.environment.enabled?('skip_new_user_email_confirmation') | |
| 57 | + if user.environment.enabled?('skip_new_user_email_confirmation') | |
| 58 | 58 | if user.environment.enabled?('admin_must_approve_new_users') |
| 59 | 59 | create_moderate_task |
| 60 | 60 | else |
| ... | ... | @@ -102,7 +102,7 @@ class User < ActiveRecord::Base |
| 102 | 102 | validates_length_of :email, :within => 3..100, :if => (lambda {|user| !user.email.blank?}) |
| 103 | 103 | validates_uniqueness_of :login, :email, :case_sensitive => false, :scope => :environment_id |
| 104 | 104 | before_save :encrypt_password |
| 105 | - before_save :normalize_email | |
| 105 | + before_save :normalize_email, if: proc{ |u| u.email.present? } | |
| 106 | 106 | validates_format_of :email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda {|user| !user.email.blank?}) |
| 107 | 107 | |
| 108 | 108 | validates_inclusion_of :terms_accepted, :in => [ '1' ], :if => lambda { |u| ! u.terms_of_use.blank? }, :message => N_('{fn} must be checked in order to signup.').fix_i18n | ... | ... |
test/functional/account_controller_test.rb
| ... | ... | @@ -818,17 +818,17 @@ class AccountControllerTest < ActionController::TestCase |
| 818 | 818 | end |
| 819 | 819 | |
| 820 | 820 | should 'login with an alternative authentication defined by plugin' do |
| 821 | + user = create_user | |
| 821 | 822 | class Plugin1 < Noosfero::Plugin |
| 822 | - def alternative_authentication | |
| 823 | - User.new(:login => 'testuser') | |
| 824 | - end | |
| 825 | 823 | end |
| 824 | + Plugin1.send(:define_method, :alternative_authentication){ user } | |
| 825 | + | |
| 826 | 826 | Noosfero::Plugin.stubs(:all).returns([Plugin1.name]) |
| 827 | 827 | Environment.default.enable_plugin(Plugin1.name) |
| 828 | 828 | |
| 829 | 829 | post :login, :user => {:login => "testuser"} |
| 830 | 830 | |
| 831 | - assert_equal 'testuser', assigns(:current_user).login | |
| 831 | + assert_equal user.login, assigns(:current_user).login | |
| 832 | 832 | assert_response :redirect |
| 833 | 833 | end |
| 834 | 834 | ... | ... |