aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/shared_searches_controller.rb3
-rw-r--r--app/views/shared_searches/index.html.erb4
-rw-r--r--test/system/shared_searches_test.rb11
3 files changed, 15 insertions, 3 deletions
diff --git a/app/controllers/shared_searches_controller.rb b/app/controllers/shared_searches_controller.rb
index 7b1005e..dd33bc5 100644
--- a/app/controllers/shared_searches_controller.rb
+++ b/app/controllers/shared_searches_controller.rb
@@ -4,7 +4,8 @@ class SharedSearchesController < ApplicationController
skip_before_action :user_authenticated!, only: %i[show]
def index
- @searches = Search.where(shared: true).order(:name)
+ @searches = Search.order(:name)
+ @saved_searches = @searches.where(shared: true)
end
def show
diff --git a/app/views/shared_searches/index.html.erb b/app/views/shared_searches/index.html.erb
index a17537c..f9d3289 100644
--- a/app/views/shared_searches/index.html.erb
+++ b/app/views/shared_searches/index.html.erb
@@ -3,11 +3,11 @@
<div>
<h3><%= I18n.t('searches.shared.title') %></h3>
- <% if @searches.empty? %>
+ <% if @saved_searches.empty? %>
<div><span><%= I18n.t('searches.shared.none') %>.</span></div>
<% else %>
<div id="shared-searches-list">
- <% @searches.each do |s| %>
+ <% @saved_searches.each do |s| %>
<div>
<%= link_to s.name, search_shared_path(s) %>
</div>
diff --git a/test/system/shared_searches_test.rb b/test/system/shared_searches_test.rb
index 6828dbe..5a8cc3e 100644
--- a/test/system/shared_searches_test.rb
+++ b/test/system/shared_searches_test.rb
@@ -15,6 +15,17 @@ class SharedSearchesTest < ApplicationSystemTestCase
assert_text I18n.t('searches.shared.none')
end
+ test 'shared_searches#index shows the searches at the top bar when logged in' do
+ assert_no_text searches(:search1).name
+
+ sign_in!
+
+ find('#toggle-hidden-global-menu').click
+ click_on I18n.t('searches.shared.title').downcase
+
+ assert_text searches(:search1).name
+ end
+
test 'cannot access shared_searches#index if not logged in' do
sign_out_maybe!