Commit a754c9b63608bc027292625465c723cb5feb3a5d
Committed by
Thiago Ribeiro
1 parent
d6b096c2
Exists in
refactor_software_info_365
Add tests for create software task
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Showing
2 changed files
with
24 additions
and
5 deletions
Show diff stats
lib/software_info.rb
... | ... | @@ -166,7 +166,7 @@ class SoftwareInfo < ActiveRecord::Base |
166 | 166 | another_license_link = attributes.delete(:another_license_link) |
167 | 167 | |
168 | 168 | software_info = SoftwareInfo.new(attributes) |
169 | - if !environment.admins.include? requestor | |
169 | + unless environment.admins.include? requestor | |
170 | 170 | CreateSoftware.create!( |
171 | 171 | attributes.merge( |
172 | 172 | :requestor => requestor, |
... | ... | @@ -189,15 +189,16 @@ class SoftwareInfo < ActiveRecord::Base |
189 | 189 | community.template_id = software_template.id |
190 | 190 | end |
191 | 191 | |
192 | - software_info.license_info = license_info | |
193 | - software_info.save | |
194 | - community.software_info = software_info | |
195 | 192 | community.save! |
196 | 193 | community.add_admin(requestor) |
194 | + | |
195 | + software_info.community = community | |
196 | + software_info.license_info = license_info | |
197 | + software_info.save! | |
197 | 198 | end |
198 | 199 | |
199 | 200 | software_info.verify_license_info(another_license_version, another_license_link) |
200 | - software_info.save! | |
201 | + software_info.save | |
201 | 202 | software_info |
202 | 203 | end |
203 | 204 | ... | ... |
test/functional/software_communities_plugin_myprofile_controller_test.rb
... | ... | @@ -186,4 +186,22 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
186 | 186 | |
187 | 187 | assert_includes @response.body, "Domain is not available" |
188 | 188 | end |
189 | + | |
190 | + should "create software with admin moderation" do | |
191 | + @environment.enable('admin_must_approve_new_communities') | |
192 | + | |
193 | + post( | |
194 | + :new_software, | |
195 | + :community => {:name =>"New Software", :identifier => "new-software"}, | |
196 | + :software_info => {:finality => "something", :repository_link => ""}, | |
197 | + :license =>{:license_infos_id => LicenseInfo.last.id}, | |
198 | + :profile => @person.identifier | |
199 | + ) | |
200 | + | |
201 | + @environment.add_admin(@person) | |
202 | + Task.last.send('finish', @person) | |
203 | + | |
204 | + assert_equal "New Software", Task.last.data[:name] | |
205 | + assert_equal "New Software", SoftwareInfo.last.community.name | |
206 | + end | |
189 | 207 | end | ... | ... |