Commit 1f06b3f0dc44be058643619a7b0667737adbd293
1 parent
ec22524b
Exists in
master
and in
28 other branches
ActionItem14: tests passing
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@686 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
18 additions
and
32 deletions
Show diff stats
app/models/create_enterprise.rb
| @@ -75,8 +75,24 @@ class CreateEnterprise < Task | @@ -75,8 +75,24 @@ class CreateEnterprise < Task | ||
| 75 | profile_fields.include?(key.to_s) | 75 | profile_fields.include?(key.to_s) |
| 76 | end | 76 | end |
| 77 | 77 | ||
| 78 | + enterprise.user = self.requestor.user | ||
| 79 | + | ||
| 78 | enterprise.organization_info = OrganizationInfo.new(organization_info_data) | 80 | enterprise.organization_info = OrganizationInfo.new(organization_info_data) |
| 79 | enterprise.save! | 81 | enterprise.save! |
| 80 | end | 82 | end |
| 81 | 83 | ||
| 84 | + def description | ||
| 85 | + _('Enterprise registration: "%s"') % self.name | ||
| 86 | + end | ||
| 87 | + | ||
| 88 | + def create_message | ||
| 89 | + end | ||
| 90 | + | ||
| 91 | + def finish_message | ||
| 92 | + end | ||
| 93 | + | ||
| 94 | + def cancel_message | ||
| 95 | + end | ||
| 96 | + | ||
| 97 | + | ||
| 82 | end | 98 | end |
test/unit/create_enterprise_test.rb
| @@ -75,7 +75,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -75,7 +75,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
| 75 | task.approve | 75 | task.approve |
| 76 | end | 76 | end |
| 77 | 77 | ||
| 78 | - should 'actually create an enterprise when finishing the task' do | 78 | + should 'actually create an enterprise when finishing the task and associate the task requestor as its owner through the "user" association' do |
| 79 | 79 | ||
| 80 | Environment.destroy_all | 80 | Environment.destroy_all |
| 81 | environment = Environment.create!(:name => "My environment", :contact_email => 'test@localhost.localdomain', :is_default => true) | 81 | environment = Environment.create!(:name => "My environment", :contact_email => 'test@localhost.localdomain', :is_default => true) |
| @@ -103,37 +103,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -103,37 +103,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
| 103 | task.finish | 103 | task.finish |
| 104 | 104 | ||
| 105 | assert !enterprise.new_record? | 105 | assert !enterprise.new_record? |
| 106 | - end | ||
| 107 | - | ||
| 108 | - should 'associate task requestor as enterprise administrator upon enterprise creation' do | ||
| 109 | - | ||
| 110 | - Environment.destroy_all | ||
| 111 | - environment = Environment.create!(:name => "My environment", :contact_email => 'test@localhost.localdomain', :is_default => true) | ||
| 112 | - region = Region.create!(:name => 'My region', :environment_id => environment.id) | ||
| 113 | - validator = Organization.create!(:name => "My organization", :identifier => 'myorg', :environment_id => environment.id) | ||
| 114 | - region.validators << validator | ||
| 115 | - person = User.create!(:login => 'testuser', :password => 'test', :password_confirmation => 'test', :email => 'testuser@localhost.localdomain').person | ||
| 116 | - | ||
| 117 | - task = CreateEnterprise.create!({ | ||
| 118 | - :name => 'My new enterprise', | ||
| 119 | - :identifier => 'mynewenterprise', | ||
| 120 | - :address => 'satan street, 666', | ||
| 121 | - :contact_phone => '1298372198', | ||
| 122 | - :contact_person => 'random joe', | ||
| 123 | - :legal_form => 'cooperative', | ||
| 124 | - :economic_activity => 'free software', | ||
| 125 | - :region_id => region.id, | ||
| 126 | - :requestor_id => person.id, | ||
| 127 | - :target_id => validator.id, | ||
| 128 | - }) | ||
| 129 | - | ||
| 130 | - enterprise = Enterprise.new | ||
| 131 | - Enterprise.expects(:new).returns(enterprise) | ||
| 132 | - | ||
| 133 | - task.finish | ||
| 134 | - | ||
| 135 | - | ||
| 136 | - flunk "don't know howt to test it yet" | 106 | + assert_equal person.user, enterprise.user |
| 137 | end | 107 | end |
| 138 | 108 | ||
| 139 | end | 109 | end |