Browse Source

WIP - Cldc 752/add navigation bar (#113)

* Navigation bar and specs added

* CLDC-752 - Sign in link added
pull/116/head
Matthew J. Phelan 3 years ago committed by GitHub
parent
commit
6101771f37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      app/views/layouts/application.html.erb
  2. 26
      spec/features/user_spec.rb

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

@ -38,7 +38,14 @@
logotype: 'GOV.UK', logotype: 'GOV.UK',
service_name: 'Share Lettings and Sales for Social Housing in England Data with DLUHC', service_name: 'Share Lettings and Sales for Social Housing in England Data with DLUHC',
service_url: '/' service_url: '/'
) ) do |component|
if current_user.nil?
component.navigation_item(text: 'Case logs', href: '/case_logs')
elsif
component.navigation_item(text: 'Your account', href: '/users/account')
component.navigation_item(text: 'Sign out', href: destroy_user_session_path, options: {:method => :delete})
end
end
%> %>
</header> </header>
<aside class="govuk-width-container"> <aside class="govuk-width-container">

26
spec/features/user_spec.rb

@ -58,8 +58,23 @@ RSpec.describe "User Features" do
end end
end end
context "If a not logged in user tries to access pages that need permissions" do context "If user not logged in" do
it "redirects to log in page" do it "'Your account' link does not display" do
visit("/case_logs")
expect(page).to have_no_link("Your account")
end
it "Can navigate and sign in page with sign in button" do
visit("/")
expect(page).to have_link("Case logs")
click_link("Case logs")
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")
end
it "tries to access account page, redirects to log in page" do
visit("/users/account") visit("/users/account")
expect(page).to have_content("Sign in to your account to submit CORE data") expect(page).to have_content("Sign in to your account to submit CORE data")
end end
@ -73,6 +88,13 @@ RSpec.describe "User Features" do
click_button("Sign in") click_button("Sign in")
end end
it "shows 'Your account' link in navigation if logged in and redirect to correct page" do
visit("/case_logs")
expect(page).to have_link("Your account")
click_link("Your account")
expect(page).to have_current_path("/users/account")
end
it "main page is present and accessible" do it "main page is present and accessible" do
visit("/users/account") visit("/users/account")
expect(page).to have_content("Your account") expect(page).to have_content("Your account")

Loading…
Cancel
Save