Commit 62221a7decc1e19c665c37250ed1f59a9c7bd247
Committed by
Antonio Terceiro
1 parent
b041998d
Exists in
master
and in
29 other branches
Password recovery looks after the environment to define the requestor
(ActionItem1700)
Showing
2 changed files
with
10 additions
and
10 deletions
Show diff stats
app/models/change_password.rb
@@ -45,7 +45,7 @@ class ChangePassword < Task | @@ -45,7 +45,7 @@ class ChangePassword < Task | ||
45 | end | 45 | end |
46 | 46 | ||
47 | before_validation_on_create do |change_password| | 47 | before_validation_on_create do |change_password| |
48 | - change_password.requestor = Person.find_by_identifier(change_password.login) | 48 | + change_password.requestor = Person.find_by_identifier_and_environment_id(change_password.login, change_password.environment_id) |
49 | end | 49 | end |
50 | 50 | ||
51 | ################################################### | 51 | ################################################### |
test/unit/change_password_test.rb
@@ -119,17 +119,17 @@ class ChangePasswordTest < Test::Unit::TestCase | @@ -119,17 +119,17 @@ class ChangePasswordTest < Test::Unit::TestCase | ||
119 | end | 119 | end |
120 | 120 | ||
121 | should 'search for user in the correct environment' do | 121 | should 'search for user in the correct environment' do |
122 | - e1 = Environment.create!(:id => 1, :name => "environment1") | ||
123 | - e2 = Environment.create!(:id => 2, :name => "environment2") | ||
124 | - p1 = create_user('sample-user', :password => 'test', :password_confirmation => 'test', :email => 'sample-user@e1.com', :environment => e1).person | ||
125 | - p2 = create_user('sample-user', :password => 'test', :password_confirmation => 'test', :email => 'sample-user@e2.com', :environment => e2).person | 122 | + e1 = Environment.default |
123 | + e2 = fast_create(Environment) | ||
126 | 124 | ||
127 | - change = ChangePassword.new | ||
128 | - change.login = 'sample-user' | ||
129 | - change.email = 'sample-user@e2.com' | ||
130 | - change.environment_id = e2.id | 125 | + p1 = create_user('sample-user', :password => 'test', :password_confirmation => 'test', :email => 'sample-user@test.com', :environment => e1).person |
126 | + p2 = create_user('sample-user', :password => 'test', :password_confirmation => 'test', :email => 'sample-user@test.com', :environment => e2).person | ||
131 | 127 | ||
132 | - assert change.valid? | 128 | + c1 = ChangePassword.create!(:login => 'sample-user', :email => 'sample-user@test.com', :environment_id => e1.id) |
129 | + c2 = ChangePassword.create!(:login => 'sample-user', :email => 'sample-user@test.com', :environment_id => e2.id) | ||
130 | + | ||
131 | + assert_equal c1.requestor, p1 | ||
132 | + assert_equal c2.requestor, p2 | ||
133 | end | 133 | end |
134 | 134 | ||
135 | end | 135 | end |