Change tests to use ruby/rails assertions.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8249 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ad25e3807d
commit
9b1e831fa6
|
@ -161,33 +161,26 @@ class AccountControllerTest < ActionController::TestCase
|
||||||
assert_nil @request.session[:user_id]
|
assert_nil @request.session[:user_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
context "GET #register" do
|
def test_get_register_with_registration_on
|
||||||
context "with self registration on" do
|
with_settings :self_registration => '3' do
|
||||||
setup do
|
|
||||||
Setting.self_registration = '3'
|
|
||||||
get :register
|
get :register
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'register'
|
||||||
|
assert_not_nil assigns(:user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should_respond_with :success
|
def test_get_register_with_registration_off_should_redirect
|
||||||
should_render_template :register
|
with_settings :self_registration => '0' do
|
||||||
should_assign_to :user
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with self registration off" do
|
|
||||||
setup do
|
|
||||||
Setting.self_registration = '0'
|
|
||||||
get :register
|
get :register
|
||||||
end
|
assert_redirected_to '/'
|
||||||
|
|
||||||
should_redirect_to('/') { home_url }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# See integration/account_test.rb for the full test
|
# See integration/account_test.rb for the full test
|
||||||
context "POST #register" do
|
def test_post_register_with_registration_on
|
||||||
context "with self registration on automatic" do
|
with_settings :self_registration => '3' do
|
||||||
setup do
|
assert_difference 'User.count' do
|
||||||
Setting.self_registration = '3'
|
|
||||||
post :register, :user => {
|
post :register, :user => {
|
||||||
:login => 'register',
|
:login => 'register',
|
||||||
:password => 'test',
|
:password => 'test',
|
||||||
|
@ -196,28 +189,27 @@ class AccountControllerTest < ActionController::TestCase
|
||||||
:lastname => 'Doe',
|
:lastname => 'Doe',
|
||||||
:mail => 'register@example.com'
|
:mail => 'register@example.com'
|
||||||
}
|
}
|
||||||
|
assert_redirected_to '/my/account'
|
||||||
end
|
end
|
||||||
|
user = User.first(:order => 'id DESC')
|
||||||
should_respond_with :redirect
|
assert_equal 'register', user.login
|
||||||
should_assign_to :user
|
assert user.active?
|
||||||
should_redirect_to('my page') { {:controller => 'my', :action => 'account'} }
|
|
||||||
|
|
||||||
should_create_a_new_user { User.last(:conditions => {:login => 'register'}) }
|
|
||||||
|
|
||||||
should 'set the user status to active' do
|
|
||||||
user = User.last(:conditions => {:login => 'register'})
|
|
||||||
assert user
|
|
||||||
assert_equal User::STATUS_ACTIVE, user.status
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with self registration off" do
|
def test_post_register_with_registration_off_should_redirect
|
||||||
setup do
|
with_settings :self_registration => '0' do
|
||||||
Setting.self_registration = '0'
|
assert_no_difference 'User.count' do
|
||||||
post :register
|
post :register, :user => {
|
||||||
end
|
:login => 'register',
|
||||||
|
:password => 'test',
|
||||||
should_redirect_to('/') { home_url }
|
:password_confirmation => 'test',
|
||||||
|
:firstname => 'John',
|
||||||
|
:lastname => 'Doe',
|
||||||
|
:mail => 'register@example.com'
|
||||||
|
}
|
||||||
|
assert_redirected_to '/'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -207,15 +207,6 @@ class ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.should_create_a_new_user(&block)
|
|
||||||
should "create a new user" do
|
|
||||||
user = instance_eval &block
|
|
||||||
assert user
|
|
||||||
assert_kind_of User, user
|
|
||||||
assert !user.new_record?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test that a request allows the three types of API authentication
|
# Test that a request allows the three types of API authentication
|
||||||
#
|
#
|
||||||
# * HTTP Basic with username and password
|
# * HTTP Basic with username and password
|
||||||
|
|
Loading…
Reference in New Issue