Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #2140 from sonalkr132/remove-exact-match
Browse files Browse the repository at this point in the history
Remove exact match from search page
  • Loading branch information
sonalkr132 committed Oct 7, 2019
2 parents d2f0e07 + 170e20f commit a61c6e0
Show file tree
Hide file tree
Showing 13 changed files with 1 addition and 38 deletions.
3 changes: 0 additions & 3 deletions app/controllers/searches_controller.rb
Expand Up @@ -5,9 +5,6 @@ def show
return unless params[:query]&.is_a?(String)
@error_msg, @gems = ElasticSearcher.new(params[:query], page: @page).search
limit_total_count if @gems.total_count > Gemcutter::SEARCH_MAX_PAGES * Rubygem.default_per_page

@exact_match = Rubygem.name_is(params[:query]).with_versions.first
redirect_to rubygem_path(@exact_match) if @exact_match && @gems.size == 1
end

def advanced
Expand Down
12 changes: 1 addition & 11 deletions app/views/searches/show.html.erb
Expand Up @@ -9,17 +9,7 @@
<% if @gems %>
<% @subtitle = t('.subtitle', :query => content_tag(:em, h(params[:query]))) %>

<% if @exact_match %>
<header class="gems__header">
<p class="gems__meter"><%= t '.exact_match' %></p>
</header>
<% content_for :head do %>
<link rel="prerender prefetch" href="<%= rubygem_url(@exact_match) %>">
<% end %>
<%= render partial: 'rubygems/rubygem', object: @exact_match %>
<% end %>

<header class="gems__header push">
<header class="gems__header push--s">
<p class="gems__meter"><%= page_entries_info(@gems, :entry_name => 'gem').html_safe %></p>
</header>

Expand Down
1 change: 0 additions & 1 deletion config/locales/de.yml
Expand Up @@ -322,7 +322,6 @@ de:
downloads:
updated:
show:
exact_match: Exakte Übereinstimmung
subtitle: für %{query}
month_update:
week_update:
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Expand Up @@ -332,7 +332,6 @@ en:
downloads: Downloads
updated: Updated
show:
exact_match: Exact match
subtitle: for %{query}
month_update: Updated last month (%{count})
week_update: Updated last week (%{count})
Expand Down
1 change: 0 additions & 1 deletion config/locales/es.yml
Expand Up @@ -332,7 +332,6 @@ es:
downloads: Descargas
updated: Actualizada
show:
exact_match: Coincidencia exacta
subtitle: para %{query}
month_update: Actualizadas en el último mes (%{count})
week_update: Actualizadas en la última semana (%{count})
Expand Down
1 change: 0 additions & 1 deletion config/locales/fr.yml
Expand Up @@ -322,7 +322,6 @@ fr:
downloads: Téléchargements
updated: Mis à jour
show:
exact_match: Titre exact
subtitle: pour %{query}
month_update:
week_update:
Expand Down
1 change: 0 additions & 1 deletion config/locales/ja.yml
Expand Up @@ -322,7 +322,6 @@ ja:
downloads: ダウンロード数
updated: 更新日
show:
exact_match: 完全一致
subtitle: '%{query}の検索結果'
month_update:
week_update:
Expand Down
1 change: 0 additions & 1 deletion config/locales/nl.yml
Expand Up @@ -322,7 +322,6 @@ nl:
downloads:
updated:
show:
exact_match: Exacte match
subtitle: voor %{query}
month_update:
week_update:
Expand Down
1 change: 0 additions & 1 deletion config/locales/pt-BR.yml
Expand Up @@ -322,7 +322,6 @@ pt-BR:
downloads:
updated:
show:
exact_match: Busca exata
subtitle: para %{query}
month_update:
week_update:
Expand Down
1 change: 0 additions & 1 deletion config/locales/zh-CN.yml
Expand Up @@ -322,7 +322,6 @@ zh-CN:
downloads: 下载数
updated: 更新时间
show:
exact_match: 精确匹配
subtitle: "%{query}"
month_update:
week_update:
Expand Down
1 change: 0 additions & 1 deletion config/locales/zh-TW.yml
Expand Up @@ -322,7 +322,6 @@ zh-TW:
downloads: 下載數
updated: 最後更新時間
show:
exact_match: 完全符合
subtitle: "%{query}"
month_update:
week_update:
Expand Down
12 changes: 0 additions & 12 deletions test/functional/searches_controller_test.rb
Expand Up @@ -84,18 +84,6 @@ class SearchesControllerTest < ActionController::TestCase
end
end

context "on GET to show with search parameters with a single exact match" do
setup do
@sinatra = create(:rubygem, name: "sinatra")
create(:version, rubygem: @sinatra)
import_and_refresh
get :show, params: { query: "sinatra" }
end

should respond_with :redirect
should redirect_to("the gem") { rubygem_path(@sinatra) }
end

context "on GET to show with non string search parameter" do
setup do
get :show, params: { query: { foo: "bar" } }
Expand Down
3 changes: 0 additions & 3 deletions test/integration/search_test.rb
Expand Up @@ -14,7 +14,6 @@ class SearchTest < SystemTest
click_button "search_submit"

assert page.has_content? "LDAP"
assert page.has_content? "Exact match"

assert page.has_content? "LDAP-PLUS"
end
Expand All @@ -36,7 +35,6 @@ class SearchTest < SystemTest
rubygem = create(:rubygem, name: "LDAP")
create(:version, rubygem: rubygem, number: "1.1.1", indexed: true)
create(:version, rubygem: rubygem, number: "2.2.2", indexed: false)
create(:version, rubygem: rubygem, number: "3.3.3", indexed: true)
import_and_refresh

visit search_path
Expand All @@ -46,7 +44,6 @@ class SearchTest < SystemTest

assert page.has_content?("1.1.1")
refute page.has_content?("2.2.2")
assert page.has_content?("3.3.3")
end

test "search page with a non valid format" do
Expand Down

0 comments on commit a61c6e0

Please sign in to comment.