Commit 1f06b3f0dc44be058643619a7b0667737adbd293

Authored by AntonioTerceiro
1 parent ec22524b

ActionItem14: tests passing



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@686 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/create_enterprise.rb
... ... @@ -75,8 +75,24 @@ class CreateEnterprise < Task
75 75 profile_fields.include?(key.to_s)
76 76 end
77 77  
  78 + enterprise.user = self.requestor.user
  79 +
78 80 enterprise.organization_info = OrganizationInfo.new(organization_info_data)
79 81 enterprise.save!
80 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 98 end
... ...
test/unit/create_enterprise_test.rb
... ... @@ -75,7 +75,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase
75 75 task.approve
76 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 80 Environment.destroy_all
81 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 103 task.finish
104 104  
105 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 107 end
138 108  
139 109 end
... ...