diff --git a/app/views/organisations/logs.html.erb b/app/views/organisations/logs.html.erb index b22f4370d..e330817da 100644 --- a/app/views/organisations/logs.html.erb +++ b/app/views/organisations/logs.html.erb @@ -1,9 +1,5 @@ <% item_label = format_label(@pagy.count, "log") %> -<% if @searched.present? %> - <% title = "#{@organisation.name} (#{@pagy.count} #{item_label} matching ‘#{@searched}’)" %> -<% else %> - <% title = "#{@organisation.name} (Logs)" %> -<% end %> +<% title = format_title(request.path, @searched, "Logs", current_user, item_label, @pagy.count, nil) %> <% content_for :title, title %> diff --git a/spec/helpers/title_helper_spec.rb b/spec/helpers/title_helper_spec.rb index da08309eb..12341b654 100644 --- a/spec/helpers/title_helper_spec.rb +++ b/spec/helpers/title_helper_spec.rb @@ -13,13 +13,32 @@ RSpec.describe TitleHelper do end describe "#format_title" do + let(:page_title) { "Title" } + let(:item_label) { "label" } + let(:search_item) { nil } + let(:count) { 1 } + let(:organisation_name) { nil } + context "coordinator user" do + let(:user) { FactoryBot.create(:user, :data_coordinator) } + + context "specific organisation details path" do + let(:path) { "organisations/1/details" } + let(:page_title) { "Organisation details" } + let(:organisation_name) { nil } + + context "search is missing" do + let(:expected_title) { page_title } + + it "returns expected title when no search" do + expect(format_title(path, nil, page_title, user, item_label, count, organisation_name)).to eq(expected_title) + end + end + end + end + + context "support user" do let(:user) { FactoryBot.create(:user, :support) } - let(:page_title) { "Title" } - let(:item_label) { "label" } - let(:search_item) { nil } - let(:count) { 1 } - let(:organisation_name) { nil } context "highest level links" do context "organisation path" do