diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-01 21:06:30 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-01 21:16:50 +0200 |
| commit | 3e6ae9e523b410e9f100c8840ee9b6cc77043537 (patch) | |
| tree | 17bff04515631930a9849f661399ce1bfe43d03a | |
| parent | 94c48771afa30e4594832dd3be4987f6ba7b6ea5 (diff) | |
| download | operum-3e6ae9e523b410e9f100c8840ee9b6cc77043537.tar.gz operum-3e6ae9e523b410e9f100c8840ee9b6cc77043537.zip | |
Show all searches at the top bar always
Since 8d954606eaf3 ("Do not allow to show non-shared searches"), we were
only showing saved searches, but that collided with the @searches on the
top bar. This went unnoticed until now, in which the top bar will always
display all searches, while the shared searches content will only
display the shared ones.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
| -rw-r--r-- | app/controllers/shared_searches_controller.rb | 3 | ||||
| -rw-r--r-- | app/views/shared_searches/index.html.erb | 4 | ||||
| -rw-r--r-- | test/system/shared_searches_test.rb | 11 |
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! |
