Commit 2aa4d754d6be187045eaacf68e0d07ffcd511cdb
Committed by
David Silva
1 parent
8b57c5f8
Exists in
master
and in
5 other branches
Remove trailing whitespace and fix SearchControllerTest
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Showing
2 changed files
with
87 additions
and
25 deletions
Show diff stats
lib/software_language_helper.rb
| @@ -3,11 +3,13 @@ module SoftwareLanguageHelper | @@ -3,11 +3,13 @@ module SoftwareLanguageHelper | ||
| 3 | def self.valid_language? language | 3 | def self.valid_language? language |
| 4 | return false if SoftwareHelper.all_table_is_empty?(language) | 4 | return false if SoftwareHelper.all_table_is_empty?(language) |
| 5 | 5 | ||
| 6 | - programming_language_id_list = ProgrammingLanguage.select(:id).collect {|dd| dd.id } | 6 | + programming_language_id_list = ProgrammingLanguage. |
| 7 | + select(:id). | ||
| 8 | + collect { |dd| dd.id } | ||
| 7 | 9 | ||
| 8 | - return false unless programming_language_id_list.include?(language[:programming_language_id].to_i) | ||
| 9 | - | ||
| 10 | - true | 10 | + return programming_language_id_list.include?( |
| 11 | + language[:programming_language_id].to_i | ||
| 12 | + ) | ||
| 11 | end | 13 | end |
| 12 | 14 | ||
| 13 | def self.list_language new_languages | 15 | def self.list_language new_languages |
| @@ -17,7 +19,8 @@ module SoftwareLanguageHelper | @@ -17,7 +19,8 @@ module SoftwareLanguageHelper | ||
| 17 | new_languages.each do |new_language| | 19 | new_languages.each do |new_language| |
| 18 | if valid_language? new_language | 20 | if valid_language? new_language |
| 19 | language = SoftwareLanguage.new | 21 | language = SoftwareLanguage.new |
| 20 | - language.programming_language = ProgrammingLanguage.find(new_language[:programming_language_id]) | 22 | + language.programming_language = |
| 23 | + ProgrammingLanguage.find(new_language[:programming_language_id]) | ||
| 21 | language.version = new_language[:version] | 24 | language.version = new_language[:version] |
| 22 | language.operating_system = new_language[:operating_system] | 25 | language.operating_system = new_language[:operating_system] |
| 23 | list_languages << language | 26 | list_languages << language |
| @@ -49,7 +52,11 @@ module SoftwareLanguageHelper | @@ -49,7 +52,11 @@ module SoftwareLanguageHelper | ||
| 49 | lambdas_list = [] | 52 | lambdas_list = [] |
| 50 | 53 | ||
| 51 | if not show_information | 54 | if not show_information |
| 52 | - return language_html_structure({:programming_language_id => "", :version => "", :operating_system => ""}) if list_languages.nil? | 55 | + return language_html_structure( |
| 56 | + {:programming_language_id => "", | ||
| 57 | + :version => "", | ||
| 58 | + :operating_system => ""} | ||
| 59 | + ) if list_languages.nil? | ||
| 53 | 60 | ||
| 54 | list_languages.each do |language| | 61 | list_languages.each do |language| |
| 55 | lambdas_list << language_html_structure(language) | 62 | lambdas_list << language_html_structure(language) |
| @@ -69,29 +76,68 @@ module SoftwareLanguageHelper | @@ -69,29 +76,68 @@ module SoftwareLanguageHelper | ||
| 69 | language_name = if language_data[:programming_language_id].blank? | 76 | language_name = if language_data[:programming_language_id].blank? |
| 70 | "" | 77 | "" |
| 71 | else | 78 | else |
| 72 | - ProgrammingLanguage.find(language_data[:programming_language_id], :select=>"name").name | 79 | + ProgrammingLanguage.find( |
| 80 | + language_data[:programming_language_id], | ||
| 81 | + :select=>"name" | ||
| 82 | + ).name | ||
| 73 | end | 83 | end |
| 74 | 84 | ||
| 75 | Proc::new do | 85 | Proc::new do |
| 76 | content_tag('table', | 86 | content_tag('table', |
| 77 | - content_tag('tr', | ||
| 78 | - content_tag('td', label_tag(_("Language Name: ")))+ | ||
| 79 | - content_tag('td', | ||
| 80 | - text_field_tag("language_autocomplete", language_name, :class=>"language_autocomplete", :placeholder=>_("Autocomplete field, type something")) + | ||
| 81 | - content_tag('div', _("Pick an item on the list"), :class=>"autocomplete_validation_message hide-field") ) + | ||
| 82 | - content_tag('td', hidden_field_tag("language[][programming_language_id]", language_data[:programming_language_id], :class=>"programming_language_id", data:{label:language_name})) | 87 | + content_tag( |
| 88 | + 'tr', | ||
| 89 | + content_tag('td', label_tag(_("Language Name: "))) + | ||
| 90 | + content_tag( | ||
| 91 | + 'td', | ||
| 92 | + text_field_tag( | ||
| 93 | + "language_autocomplete", | ||
| 94 | + language_name, | ||
| 95 | + :class=>"language_autocomplete", | ||
| 96 | + :placeholder=>_("Autocomplete field, type something") | ||
| 97 | + ) + | ||
| 98 | + content_tag( | ||
| 99 | + 'div', | ||
| 100 | + _("Pick an item on the list"), | ||
| 101 | + :class=>"autocomplete_validation_message hide-field") | ||
| 102 | + ) + | ||
| 103 | + content_tag( | ||
| 104 | + 'td', | ||
| 105 | + hidden_field_tag("language[][programming_language_id]", | ||
| 106 | + language_data[:programming_language_id], | ||
| 107 | + :class=>"programming_language_id", | ||
| 108 | + data:{label:language_name}) | ||
| 109 | + ) | ||
| 83 | )+ | 110 | )+ |
| 84 | 111 | ||
| 85 | - content_tag('tr', | 112 | + content_tag( |
| 113 | + 'tr', | ||
| 86 | content_tag('td', label_tag(_("Version")))+ | 114 | content_tag('td', label_tag(_("Version")))+ |
| 87 | - content_tag('td', text_field_tag("language[][version]", language_data[:version]))+ | 115 | + content_tag( |
| 116 | + 'td', | ||
| 117 | + text_field_tag("language[][version]",language_data[:version]) | ||
| 118 | + ) + | ||
| 88 | content_tag('td') | 119 | content_tag('td') |
| 89 | )+ | 120 | )+ |
| 90 | 121 | ||
| 91 | - content_tag('tr', | 122 | + content_tag( |
| 123 | + 'tr', | ||
| 92 | content_tag('td', label_tag(_("Operating System")))+ | 124 | content_tag('td', label_tag(_("Operating System")))+ |
| 93 | - content_tag('td', text_field_tag("language[][operating_system]", language_data[:operating_system]))+ | ||
| 94 | - content_tag('td', button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), :align => 'right') | 125 | + content_tag( |
| 126 | + 'td', | ||
| 127 | + text_field_tag( | ||
| 128 | + "language[][operating_system]", | ||
| 129 | + language_data[:operating_system] | ||
| 130 | + ) | ||
| 131 | + ) + | ||
| 132 | + content_tag('td', | ||
| 133 | + button_without_text( | ||
| 134 | + :delete, | ||
| 135 | + _('Delete'), | ||
| 136 | + "#", | ||
| 137 | + :class=>"delete-dynamic-table" | ||
| 138 | + ), | ||
| 139 | + :align => 'right' | ||
| 140 | + ) | ||
| 95 | ), :class => 'dynamic-table software-language-table' | 141 | ), :class => 'dynamic-table software-language-table' |
| 96 | ) | 142 | ) |
| 97 | end | 143 | end |
| @@ -99,10 +145,17 @@ module SoftwareLanguageHelper | @@ -99,10 +145,17 @@ module SoftwareLanguageHelper | ||
| 99 | 145 | ||
| 100 | def self.language_html_show_structure(language) | 146 | def self.language_html_show_structure(language) |
| 101 | Proc::new do | 147 | Proc::new do |
| 102 | - content_tag('table', | ||
| 103 | - content_tag('tr', | 148 | + content_tag( |
| 149 | + 'table', | ||
| 150 | + content_tag( | ||
| 151 | + 'tr', | ||
| 104 | content_tag('td', label_tag(_("Language Name: ")))+ | 152 | content_tag('td', label_tag(_("Language Name: ")))+ |
| 105 | - content_tag('td', ProgrammingLanguage.where(:id => language[:programming_language_id])[0].name)+ | 153 | + content_tag( |
| 154 | + 'td', | ||
| 155 | + ProgrammingLanguage.where( | ||
| 156 | + :id => language[:programming_language_id] | ||
| 157 | + )[0].name | ||
| 158 | + )+ | ||
| 106 | content_tag('td') | 159 | content_tag('td') |
| 107 | )+ | 160 | )+ |
| 108 | 161 |
test/functional/search_controller_test.rb
| @@ -72,6 +72,11 @@ class SearchControllerTest < ActionController::TestCase | @@ -72,6 +72,11 @@ class SearchControllerTest < ActionController::TestCase | ||
| 72 | 72 | ||
| 73 | should "Don't found template in communities search" do | 73 | should "Don't found template in communities search" do |
| 74 | community = create_community("New Community") | 74 | community = create_community("New Community") |
| 75 | + software = create_software_info("New Software") | ||
| 76 | + software.license_info = LicenseInfo.create(:version => "GPL") | ||
| 77 | + software.save! | ||
| 78 | + | ||
| 79 | + institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63") | ||
| 75 | 80 | ||
| 76 | community_template = create_community("New Community Template") | 81 | community_template = create_community("New Community Template") |
| 77 | community_template.is_template = true | 82 | community_template.is_template = true |
| @@ -86,10 +91,14 @@ class SearchControllerTest < ActionController::TestCase | @@ -86,10 +91,14 @@ class SearchControllerTest < ActionController::TestCase | ||
| 86 | ) | 91 | ) |
| 87 | end | 92 | end |
| 88 | 93 | ||
| 89 | - should "Don't found template in software_infos search" do | ||
| 90 | - software = create_software_info("New Software") | ||
| 91 | - software.license_info = LicenseInfo.create(:version => "GPL") | ||
| 92 | - software.save! | 94 | + should "software_infos search by category" do |
| 95 | + software_with_category = create_software_info("New Software With Category") | ||
| 96 | + software_with_category.license_info = LicenseInfo.create(:version => "GPL") | ||
| 97 | + | ||
| 98 | + software_without_category = create_software_info("New Software Without Category") | ||
| 99 | + software_without_category.license_info = LicenseInfo.create(:version => "GPL") | ||
| 100 | + | ||
| 101 | + category = Category.create!(:name => "Health", :environment => @environment, :parent => @category_software) | ||
| 93 | 102 | ||
| 94 | software_template = create_software_info("New Software Template") | 103 | software_template = create_software_info("New Software Template") |
| 95 | software_template.license_info = LicenseInfo.last | 104 | software_template.license_info = LicenseInfo.last |