Commit 6f5eea6b57eb8c8fbe7586db5917b711d251897a
1 parent
674c5786
Exists in
staging
and in
42 other branches
Rails3: Fix EnterpriseActivation unit tests
Showing
1 changed file
with
11 additions
and
5 deletions
Show diff stats
test/unit/enterprise_activation_test.rb
| @@ -21,16 +21,18 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | @@ -21,16 +21,18 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | ||
| 21 | should 'require an enterprise' do | 21 | should 'require an enterprise' do |
| 22 | t = EnterpriseActivation.new | 22 | t = EnterpriseActivation.new |
| 23 | t.valid? | 23 | t.valid? |
| 24 | - assert t.errors.invalid?(:enterprise_id), "enterprise must be required" | 24 | + assert t.errors[:enterprise_id].any?, "enterprise must be required" |
| 25 | 25 | ||
| 26 | ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent') | 26 | ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent') |
| 27 | t.enterprise = ent | 27 | t.enterprise = ent |
| 28 | t.valid? | 28 | t.valid? |
| 29 | - assert !t.errors.invalid?(:enterprise_id), "must validate after enterprise is set" | 29 | + assert !t.errors[:enterprise_id].any?, "must validate after enterprise is set" |
| 30 | end | 30 | end |
| 31 | 31 | ||
| 32 | should 'activate enterprise when finished' do | 32 | should 'activate enterprise when finished' do |
| 33 | - ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent', :enabled => false) | 33 | + ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent').tap do |e| |
| 34 | + e.enabled = false | ||
| 35 | + end | ||
| 34 | t = EnterpriseActivation.create!(:enterprise => ent) | 36 | t = EnterpriseActivation.create!(:enterprise => ent) |
| 35 | t.requestor = profiles(:ze) | 37 | t.requestor = profiles(:ze) |
| 36 | 38 | ||
| @@ -41,7 +43,9 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | @@ -41,7 +43,9 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | ||
| 41 | end | 43 | end |
| 42 | 44 | ||
| 43 | should 'require requestor to finish' do | 45 | should 'require requestor to finish' do |
| 44 | - ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent', :enabled => false) | 46 | + ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent').tap do |e| |
| 47 | + e.enabled = false | ||
| 48 | + end | ||
| 45 | t = EnterpriseActivation.create!(:enterprise => ent) | 49 | t = EnterpriseActivation.create!(:enterprise => ent) |
| 46 | 50 | ||
| 47 | assert_raise EnterpriseActivation::RequestorRequired do | 51 | assert_raise EnterpriseActivation::RequestorRequired do |
| @@ -50,7 +54,9 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | @@ -50,7 +54,9 @@ class EnterpriseActivationTest < ActiveSupport::TestCase | ||
| 50 | end | 54 | end |
| 51 | 55 | ||
| 52 | should 'put requestor as enterprise owner when finishing' do | 56 | should 'put requestor as enterprise owner when finishing' do |
| 53 | - ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent', :enabled => false) | 57 | + ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent').tap do |e| |
| 58 | + e.enabled = false | ||
| 59 | + end | ||
| 54 | t = EnterpriseActivation.create!(:enterprise => ent) | 60 | t = EnterpriseActivation.create!(:enterprise => ent) |
| 55 | 61 | ||
| 56 | person = profiles(:ze) | 62 | person = profiles(:ze) |