From: Eric Davis Date: Mon, 2 Aug 2010 15:43:04 +0000 (+0000) Subject: Refactor: extract method to shoulda macro. X-Git-Tag: 1.1.0~487 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=25037b841bfd52ca05c6c1a179c06fd509f17443;p=redmine.git Refactor: extract method to shoulda macro. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3905 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 61ad97430..2a8c9c66b 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -195,11 +195,7 @@ class AccountControllerTest < ActionController::TestCase should_assign_to :user should_redirect_to('my page') { {:controller => 'my', :action => 'account'} } - should "create a new user" do - user = User.last(:conditions => {:login => 'register'}) - assert user - assert_kind_of User, user - end + should_create_a_new_user { User.last(:conditions => {:login => 'register'}) } should 'set the user status to active' do user = User.last(:conditions => {:login => 'register'}) diff --git a/test/test_helper.rb b/test/test_helper.rb index c934e1bc2..15a1f1570 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -162,4 +162,13 @@ class ActiveSupport::TestCase 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 end