Browse Source

CLDC-763 (#136)

* refactor

* refactor

* update default title

* Add tests for application helper
pull/137/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
ca6bf4c2ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/helpers/application_helper.rb
  2. 2
      app/views/case_logs/edit.html.erb
  3. 2
      app/views/case_logs/index.html.erb
  4. 2
      app/views/devise/sessions/new.html.erb
  5. 2
      app/views/form/check_answers.html.erb
  6. 2
      app/views/form/page.html.erb
  7. 2
      app/views/layouts/application.html.erb
  8. 2
      app/views/organisations/show.html.erb
  9. 2
      app/views/organisations/users.html.erb
  10. 2
      app/views/users/show.html.erb
  11. 20
      spec/helpers/application_helper.rb

3
app/helpers/application_helper.rb

@ -1,2 +1,5 @@
module ApplicationHelper
def browser_title(title)
[title, t("service_name"), "GOV.UK"].select(&:present?).join(" - ")
end
end

2
app/views/case_logs/edit.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Case log #{@case_log.id} – #{t('service_name')} - GOV.UK" %>
<% content_for :title, "Case log #{@case_log.id}" %>
<%= turbo_frame_tag "case_log_form", target: "_top" do %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">

2
app/views/case_logs/index.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Case logs – #{t('service_name')} - GOV.UK" %>
<% content_for :title, "Case logs" %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h1 class="govuk-heading-l">Your logs</h1>

2
app/views/devise/sessions/new.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Sign in – #{t('service_name')} - GOV.UK" %>
<% content_for :title, "Sign in" %>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

2
app/views/form/check_answers.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Check answers – #{t('service_name')} - GOV.UK" %>
<% content_for :title, "Check answers" %>
<%= turbo_frame_tag "case_log_form", target: "_top" do %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters-from-desktop">

2
app/views/form/page.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "#{subsection} – #{t('service_name')} - GOV.UK" %>
<% content_for :title, subsection %>
<% content_for :before_content do %>
<%= govuk_back_link(

2
app/views/layouts/application.html.erb

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" class="govuk-template">
<head>
<title><%= yield(:title).present? ? yield(:title) : t('service_name') %></title>
<title><%= browser_title(yield(:title)) %></title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= tag :meta, name: 'viewport', content: 'width=device-width, initial-scale=1' %>

2
app/views/organisations/show.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Your organisation (Details) – #{t('service_name')} - GOV.UK" %>
<% content_for :title, "Your organisation (Details)" %>
<% content_for :tab_title do %>
<%= "Details" %>
<% end %>

2
app/views/organisations/users.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Your organisation (Users) – #{t('service_name')} - GOV.UK" %>
<% content_for :title, "Your organisation (Users)" %>
<% content_for :tab_title do %>
<%= "Users" %>
<% end %>

2
app/views/users/show.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Your account – #{t('service_name')} - GOV.UK" %>
<% content_for :title, "Your account" %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">

20
spec/helpers/application_helper.rb

@ -0,0 +1,20 @@
require "rails_helper"
RSpec.describe ApplicationHelper do
form_handler = FormHandler.instance
let(:form) { form_handler.get_form("test_form") }
let(:subsection) { form.get_subsection("household_characteristics") }
let(:case_log) { FactoryBot.build(:case_log, :in_progress) }
describe "browser_title" do
it "returns correct browser title when title is given" do
expect(browser_title("title"))
.to eq("title - #{t('service_name')} - GOV.UK")
end
it "returns correct browser title when title is not given" do
expect(browser_title(nil))
.to eq("#{t('service_name')} - GOV.UK")
end
end
end
Loading…
Cancel
Save