Browse Source

Differentiate between internal and external interfaces (#660)

* Differentiate support and public interfaces

Co-authored-by: baarkerlounger <db@slothlife.xyz>
pull/666/head
Paul Robert Lloyd 3 years ago committed by GitHub
parent
commit
5c58550bd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/frontend/styles/_header.scss
  2. 16
      app/helpers/application_helper.rb
  3. 4
      app/views/layouts/application.html.erb
  4. 36
      spec/helpers/application_helper_spec.rb

5
app/frontend/styles/_header.scss

@ -21,3 +21,8 @@
}
}
}
.app-header--orange,
.app-header--orange .govuk-header__container {
border-bottom-color: govuk-colour("orange");
}

16
app/helpers/application_helper.rb

@ -9,6 +9,22 @@ module ApplicationHelper
end
end
def govuk_header_classes(current_user)
if current_user && current_user.support?
"app-header app-header--orange"
else
"app-header"
end
end
def govuk_phase_banner_tag(current_user)
if current_user && current_user.support?
{ colour: "orange", text: "Support beta" }
else
{ text: "Beta" }
end
end
private
def paginated_title(title, pagy)

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

@ -43,7 +43,7 @@
<%= govuk_skip_link %>
<%= govuk_header(
classes: "app-header",
classes: govuk_header_classes(current_user),
service_url: current_user.nil? ? "/" : "/logs",
navigation_classes: "govuk-header__navigation--end",
) do |component|
@ -60,7 +60,7 @@
<%= govuk_phase_banner(
classes: "govuk-width-container",
tag: { text: "Beta" },
tag: govuk_phase_banner_tag(current_user),
text: "This is a new service – help us improve it by #{feedback_link}".html_safe,
) %>

36
spec/helpers/application_helper_spec.rb

@ -6,6 +6,42 @@ RSpec.describe ApplicationHelper do
let(:subsection) { form.get_subsection("household_characteristics") }
let(:case_log) { FactoryBot.build(:case_log, :in_progress) }
let(:pagy) { nil }
let(:current_user) { FactoryBot.create(:user) }
describe "govuk_header_classes" do
context "with external user" do
it "shows the standard app header" do
expect(govuk_header_classes(current_user)).to eq("app-header")
end
end
context "with internal support user" do
let(:current_user) { FactoryBot.create(:user, :support) }
it "shows an orange header" do
expect(govuk_header_classes(current_user)).to eq("app-header app-header--orange")
end
end
end
describe "govuk_phase_banner_tag" do
context "with external user" do
it "shows the standard phase tag" do
expect(govuk_phase_banner_tag(current_user)).to eq({ text: "Beta" })
end
end
context "with support user" do
let(:current_user) { FactoryBot.create(:user, :support) }
it "shows an orange phase tag" do
expect(govuk_phase_banner_tag(current_user)).to eq({
colour: "orange",
text: "Support beta",
})
end
end
end
describe "browser_title" do
context "with no pagination" do

Loading…
Cancel
Save