Commit babb6d68549c65e0d52f6d0d0ce47aad81099eef
Committed by
Thiago Ribeiro
1 parent
5811ad69
Exists in
refactor_software_info_365
Change indentifier to domain in software creation
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Showing
2 changed files
with
43 additions
and
1 deletions
Show diff stats
controllers/software_communities_plugin_myprofile_controller.rb
| ... | ... | @@ -17,6 +17,9 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
| 17 | 17 | LicenseInfo.find(params[:license][:license_infos_id]) |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | + @software_info.community = @community | |
| 21 | + @software_info.license_info = @license_info | |
| 22 | + | |
| 20 | 23 | control_software_creation |
| 21 | 24 | update_new_software_errors |
| 22 | 25 | end |
| ... | ... | @@ -58,7 +61,11 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
| 58 | 61 | |
| 59 | 62 | def add_software_erros |
| 60 | 63 | @errors = [] |
| 61 | - @errors |= @community.errors.full_messages if @community | |
| 64 | + if @community | |
| 65 | + error = @community.errors.delete(:identifier) | |
| 66 | + @errors |= [_("Domain %s") % error.first ] if error | |
| 67 | + @errors |= @community.errors.full_messages | |
| 68 | + end | |
| 62 | 69 | @errors |= @software_info.errors.full_messages if @software_info |
| 63 | 70 | @errors |= @license_info.errors.full_messages if @license_info |
| 64 | 71 | end | ... | ... |
test/functional/software_communities_plugin_myprofile_controller_test.rb
| ... | ... | @@ -151,4 +151,39 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
| 151 | 151 | assert_equal SoftwareInfo.last.license_info.version, another_license_version |
| 152 | 152 | assert_equal SoftwareInfo.last.license_info.link, another_license_link |
| 153 | 153 | end |
| 154 | + | |
| 155 | + should "show error messages on create software_info" do | |
| 156 | + post( | |
| 157 | + :new_software, | |
| 158 | + :community => {}, | |
| 159 | + :software_info => {}, | |
| 160 | + :license => {}, | |
| 161 | + :profile => @person.identifier | |
| 162 | + ) | |
| 163 | + assert_includes @response.body, "Domain can't be blank" | |
| 164 | + assert_includes @response.body, "Name can't be blank" | |
| 165 | + assert_includes @response.body, "Finality can't be blank" | |
| 166 | + assert_includes @response.body, "Version can't be blank" | |
| 167 | + end | |
| 168 | + | |
| 169 | + should "show domain not available error" do | |
| 170 | + @environment.add_admin(@person) | |
| 171 | + | |
| 172 | + post( | |
| 173 | + :new_software, | |
| 174 | + :community => {:name =>"New Software", :identifier => "new-software"}, | |
| 175 | + :software_info => {:finality => "something", :repository_link => ""}, | |
| 176 | + :license =>{:license_infos_id => LicenseInfo.last.id}, | |
| 177 | + :profile => @person.identifier | |
| 178 | + ) | |
| 179 | + post( | |
| 180 | + :new_software, | |
| 181 | + :community => {:name =>"New Software", :identifier => "new-software"}, | |
| 182 | + :software_info => {:finality => "something", :repository_link => ""}, | |
| 183 | + :license =>{:license_infos_id => LicenseInfo.last.id}, | |
| 184 | + :profile => @person.identifier | |
| 185 | + ) | |
| 186 | + | |
| 187 | + assert_includes @response.body, "Domain is not available" | |
| 188 | + end | |
| 154 | 189 | end | ... | ... |