Commit 2aa4d754d6be187045eaacf68e0d07ffcd511cdb

Authored by Luciano Prestes
Committed by David Silva
1 parent 8b57c5f8
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Remove trailing whitespace and fix SearchControllerTest

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
lib/software_language_helper.rb
... ... @@ -3,11 +3,13 @@ module SoftwareLanguageHelper
3 3 def self.valid_language? language
4 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 13 end
12 14  
13 15 def self.list_language new_languages
... ... @@ -17,7 +19,8 @@ module SoftwareLanguageHelper
17 19 new_languages.each do |new_language|
18 20 if valid_language? new_language
19 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 24 language.version = new_language[:version]
22 25 language.operating_system = new_language[:operating_system]
23 26 list_languages << language
... ... @@ -49,7 +52,11 @@ module SoftwareLanguageHelper
49 52 lambdas_list = []
50 53  
51 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 61 list_languages.each do |language|
55 62 lambdas_list << language_html_structure(language)
... ... @@ -69,29 +76,68 @@ module SoftwareLanguageHelper
69 76 language_name = if language_data[:programming_language_id].blank?
70 77 ""
71 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 83 end
74 84  
75 85 Proc::new do
76 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 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 119 content_tag('td')
89 120 )+
90 121  
91   - content_tag('tr',
  122 + content_tag(
  123 + 'tr',
92 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 141 ), :class => 'dynamic-table software-language-table'
96 142 )
97 143 end
... ... @@ -99,10 +145,17 @@ module SoftwareLanguageHelper
99 145  
100 146 def self.language_html_show_structure(language)
101 147 Proc::new do
102   - content_tag('table',
103   - content_tag('tr',
  148 + content_tag(
  149 + 'table',
  150 + content_tag(
  151 + 'tr',
104 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 159 content_tag('td')
107 160 )+
108 161  
... ...
test/functional/search_controller_test.rb
... ... @@ -72,6 +72,11 @@ class SearchControllerTest &lt; ActionController::TestCase
72 72  
73 73 should "Don't found template in communities search" do
74 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 81 community_template = create_community("New Community Template")
77 82 community_template.is_template = true
... ... @@ -86,10 +91,14 @@ class SearchControllerTest &lt; ActionController::TestCase
86 91 )
87 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 103 software_template = create_software_info("New Software Template")
95 104 software_template.license_info = LicenseInfo.last
... ...