summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-18 17:46:55 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-18 17:46:55 +0000
commit9c9ae217716304f7062fc31c2f4e4f8adafee2b1 (patch)
treeca10cbe2297f5a2a77cbbe33a81acd436f597e17 /test
parentf8aa2dc9b71640a4da008e8ef0968a8cd9ce7385 (diff)
downloadredmine-9c9ae217716304f7062fc31c2f4e4f8adafee2b1.tar.gz
redmine-9c9ae217716304f7062fc31c2f4e4f8adafee2b1.zip
There's now 3 account activation strategies (available in application settings):
* activation by email: the user receives an email containing a link to active his account * manual activation: an email is sent to administrators for account approval (default) * automatic activation: the user can log in as soon as he has registered git-svn-id: http://redmine.rubyforge.org/svn/trunk@915 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/integration/account_test.rb43
1 files changed, 42 insertions, 1 deletions
diff --git a/test/integration/account_test.rb b/test/integration/account_test.rb
index 6799b9288..e9d665d19 100644
--- a/test/integration/account_test.rb
+++ b/test/integration/account_test.rb
@@ -56,5 +56,46 @@ class AccountTest < ActionController::IntegrationTest
log_user('jsmith', 'newpass')
assert_equal 0, Token.count
- end
+ end
+
+ def test_register_with_automatic_activation
+ Setting.self_registration = '3'
+
+ get 'account/register'
+ assert_response :success
+ assert_template 'account/register'
+
+ post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
+ :password => "newpass", :password_confirmation => "newpass"
+ assert_redirected_to 'account/login'
+ log_user('newuser', 'newpass')
+ end
+
+ def test_register_with_manual_activation
+ Setting.self_registration = '2'
+
+ post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
+ :password => "newpass", :password_confirmation => "newpass"
+ assert_redirected_to 'account/login'
+ assert !User.find_by_login('newuser').active?
+ end
+
+ def test_register_with_email_activation
+ Setting.self_registration = '1'
+ Token.delete_all
+
+ post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
+ :password => "newpass", :password_confirmation => "newpass"
+ assert_redirected_to 'account/login'
+ assert !User.find_by_login('newuser').active?
+
+ token = Token.find(:first)
+ assert_equal 'register', token.action
+ assert_equal 'newuser@foo.bar', token.user.mail
+ assert !token.expired?
+
+ get 'account/activate', :token => token.value
+ assert_redirected_to 'account/login'
+ log_user('newuser', 'newpass')
+ end
end