Browse Source

Merge pull request #133 from communitiesuk/session-based-header-navigation

Show correct links in header navigation when signed in/out
pull/126/head^2
Paul Robert Lloyd 3 years ago committed by GitHub
parent
commit
acb1808f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/views/layouts/application.html.erb
  2. 6
      spec/features/user_spec.rb

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

@ -37,10 +37,11 @@
service_url: '/'
) do |component|
if current_user.nil?
component.navigation_item(text: 'Case logs', href: case_logs_path)
component.navigation_item(text: 'Sign in', href: user_session_path)
elsif
component.navigation_item(text: 'Case logs', href: case_logs_path)
component.navigation_item(text: 'Your organisation', href: "/organisations/#{current_user.organisation.id}")
component.navigation_item(text: 'Your account', href: '/users/account')
component.navigation_item(text: 'Your account', href: users_account_path)
component.navigation_item(text: 'Sign out', href: destroy_user_session_path, options: {:method => :delete})
end
end

6
spec/features/user_spec.rb

@ -87,12 +87,12 @@ RSpec.describe "User Features" do
it "Can navigate and sign in page with sign in button" do
visit("/")
expect(page).to have_link("Case logs")
click_link("Case logs")
expect(page).to have_link("Sign in")
click_link("Sign in")
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: "pAssword1")
click_button("Sign in")
expect(page).to have_current_path("/case-logs")
expect(page).to have_current_path("/")
end
it "tries to access account page, redirects to log in page" do

Loading…
Cancel
Save