summaryrefslogtreecommitdiffstats
path: root/test/functional/users_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/users_controller_test.rb')
-rw-r--r--test/functional/users_controller_test.rb53
1 files changed, 37 insertions, 16 deletions
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index e9aad1a98..5f62b1549 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -107,6 +107,43 @@ class UsersControllerTest < Test::Unit::TestCase
)
end
+ def test_edit
+ ActionMailer::Base.deliveries.clear
+ post :edit, :id => 2, :user => {:firstname => 'Changed'}
+ assert_equal 'Changed', User.find(2).firstname
+ assert ActionMailer::Base.deliveries.empty?
+ end
+
+ def test_edit_with_activation_should_send_a_notification
+ u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr')
+ u.login = 'foo'
+ u.status = User::STATUS_REGISTERED
+ u.save!
+ ActionMailer::Base.deliveries.clear
+ Setting.bcc_recipients = '1'
+
+ post :edit, :id => u.id, :user => {:status => User::STATUS_ACTIVE}
+ assert u.reload.active?
+ mail = ActionMailer::Base.deliveries.last
+ assert_not_nil mail
+ assert_equal ['foo.bar@somenet.foo'], mail.bcc
+ assert mail.body.include?(ll('fr', :notice_account_activated))
+ end
+
+ def test_edit_with_password_change_should_send_a_notification
+ ActionMailer::Base.deliveries.clear
+ Setting.bcc_recipients = '1'
+
+ u = User.find(2)
+ post :edit, :id => u.id, :user => {}, :password => 'newpass', :password_confirmation => 'newpass', :send_information => '1'
+ assert_equal User.hash_password('newpass'), u.reload.hashed_password
+
+ mail = ActionMailer::Base.deliveries.last
+ assert_not_nil mail
+ assert_equal [u.mail], mail.bcc
+ assert mail.body.include?('newpass')
+ end
+
def test_add_membership_routing
assert_routing(
{:method => :post, :path => '/users/123/memberships'},
@@ -128,22 +165,6 @@ class UsersControllerTest < Test::Unit::TestCase
assert_equal [2], Member.find(1).role_ids
end
- def test_edit_with_activation_should_send_a_notification
- u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr')
- u.login = 'foo'
- u.status = User::STATUS_REGISTERED
- u.save!
- ActionMailer::Base.deliveries.clear
- Setting.bcc_recipients = '1'
-
- post :edit, :id => u.id, :user => {:status => User::STATUS_ACTIVE}
- assert u.reload.active?
- mail = ActionMailer::Base.deliveries.last
- assert_not_nil mail
- assert_equal ['foo.bar@somenet.foo'], mail.bcc
- assert mail.body.include?(ll('fr', :notice_account_activated))
- end
-
def test_destroy_membership
assert_routing(
#TODO: use DELETE method on user_membership_path, modify form