Skip to content

Commit

Permalink
Merge pull request #1881 from ELIXIR-Belgium/issue_1879_fix_search_op…
Browse files Browse the repository at this point in the history
…tions

internationalize the names in the search types. Closes #1879
  • Loading branch information
kdp-cloud authored May 15, 2024
2 parents e0d7cc5 + 45f779b commit 932bb6b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/search_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module SearchHelper

def search_type_options
[['All', '']] | Seek::Util.searchable_types.collect { |c| [(c.name.underscore.humanize == 'Sop' ? t('sop') : c.name.underscore.humanize.pluralize), c.name.underscore.pluralize] }
[['All', '']] | Seek::Util.searchable_types.collect { |c| [(c.name.underscore.humanize == 'Sop' ? t('sop') : t(c.name.underscore).humanize.pluralize), c.name.underscore.pluralize] }
end

def external_search_tooltip_text
Expand Down
48 changes: 48 additions & 0 deletions test/functional/homes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,54 @@ class HomesControllerTest < ActionController::TestCase

end

test 'Show aliases in search options' do
original_load_path = I18n.load_path
I18n.load_path += Dir[Rails.root.join('test', 'config', 'translation_override.en.yml')]
I18n.backend.load_translations
with_config_values({ isa_json_compliance_enabled: true, solr_enabled: true }) do
get :index
assert_response :success
assert_select 'select#search_type' do
assert_select 'option', text: 'Investigation tests', count: 1
assert_select 'option', text: 'Study tests', count: 1
assert_select 'option', text: 'Assay tests', count: 1
assert_select 'option', text: 'Data file tests', count: 1
assert_select 'option', text: 'Document tests', count: 1
assert_select 'option', text: 'SOP_test', count: 1 # this is an exception, the alias is not in the translation file
assert_select 'option', text: 'Presentation tests', count: 1
assert_select 'option', text: 'Event tests', count: 1
assert_select 'option', text: 'Collection tests', count: 1
assert_select 'option', text: 'Sample tests', count: 1
assert_select 'option', text: 'Sample type tests', count: 1
assert_select 'option', text: 'Template tests', count: 1
assert_select 'option', text: 'Person tests', count: 1
assert_select 'option', text: 'Project tests', count: 1
assert_select 'option', text: 'Institution tests', count: 1
assert_select 'option', text: 'Programme tests', count: 1

# Making sure the default values are not shown
assert_select 'option', text: 'Investigations', count: 0
assert_select 'option', text: 'Studies', count: 0
assert_select 'option', text: 'Assays', count: 0
assert_select 'option', text: 'Data files', count: 0
assert_select 'option', text: 'Documents', count: 0
assert_select 'option', text: 'SOP', count: 0
assert_select 'option', text: 'Presentations', count: 0
assert_select 'option', text: 'Events', count: 0
assert_select 'option', text: 'Collections', count: 0
assert_select 'option', text: 'Samples', count: 0
assert_select 'option', text: 'Sample types', count: 0
assert_select 'option', text: 'Templates', count: 0
assert_select 'option', text: 'People', count: 0
assert_select 'option', text: 'Projects', count: 0
assert_select 'option', text: 'Institutions', count: 0
assert_select 'option', text: 'Programmes', count: 0
end
end
I18n.load_path = original_load_path
I18n.backend.load_translations
end

test 'get dataset jsonld from index' do
get :index, format: :jsonld
assert_response :success
Expand Down

0 comments on commit 932bb6b

Please sign in to comment.