Commit 655df80b72c663cafd6e421eeb1bb85613d32f21

Authored by Luciano Prestes
Committed by Thiago Ribeiro
1 parent a754c9b6

Add identifier into CreateSoftware task

Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
lib/create_software.rb
... ... @@ -5,12 +5,12 @@ class CreateSoftware &lt; Task
5 5 validates_presence_of :name
6 6  
7 7 attr_accessible :name, :finality, :repository_link, :requestor, :environment,
8   - :reject_explanation, :license_info
  8 + :reject_explanation, :license_info, :identifier
9 9  
10 10 alias :environment :target
11 11 alias :environment= :target=
12 12  
13   - DATA_FIELDS = ['name', 'finality', 'license_info', 'repository_link']
  13 + DATA_FIELDS = ['name', 'identifier', 'finality', 'license_info', 'repository_link']
14 14 DATA_FIELDS.each do |field|
15 15 settings_items field.to_sym
16 16 end
... ... @@ -21,7 +21,11 @@ class CreateSoftware &lt; Task
21 21 template_id = software_template.id
22 22 end
23 23  
  24 + identifier = self.identifier
  25 + identifier ||= self.name.to_slug
  26 +
24 27 community = Community.create!(:name => self.name,
  28 + :identifier => identifier,
25 29 :template_id => template_id)
26 30  
27 31 community.environment = self.environment
... ...
lib/software_info.rb
... ... @@ -172,6 +172,7 @@ class SoftwareInfo &lt; ActiveRecord::Base
172 172 :requestor => requestor,
173 173 :environment => environment,
174 174 :name => name,
  175 + :identifier => identifier,
175 176 :license_info => license_info
176 177 )
177 178 )
... ...
test/unit/software_info_validation_test.rb
... ... @@ -49,6 +49,7 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
49 49  
50 50 @software_info.features = "Do a lot of things"
51 51 @software_info.objectives = "All tests should pass !"
  52 + @software_info.community = @community
52 53 end
53 54  
54 55 def teardown
... ...