Browse Source

feat: add blank homepage, update routing and tests

pull/2121/head
natdeanlewissoftwire 1 year ago
parent
commit
a411046650
  1. 2
      app/controllers/start_controller.rb
  2. 6
      app/helpers/navigation_items_helper.rb
  3. 0
      app/views/home/index.html.erb
  4. 2
      spec/features/start_page_spec.rb
  5. 2
      spec/features/user_spec.rb
  6. 23
      spec/helpers/navigation_items_helper_spec.rb
  7. 1
      spec/requests/auth/passwords_controller_spec.rb
  8. 1
      spec/requests/maintenance_controller_spec.rb
  9. 10
      spec/requests/users_controller_spec.rb

2
app/controllers/start_controller.rb

@ -1,7 +1,7 @@
class StartController < ApplicationController
def index
if current_user
redirect_to(lettings_logs_path)
render "home/index"
end
end

6
app/helpers/navigation_items_helper.rb

@ -4,6 +4,7 @@ module NavigationItemsHelper
def primary_items(path, current_user)
if current_user.support?
[
NavigationItem.new("Home", root_path, home_current?(path)),
NavigationItem.new("Organisations", organisations_path, organisations_current?(path)),
NavigationItem.new("Users", users_path, users_current?(path)),
NavigationItem.new("Lettings logs", lettings_logs_path, lettings_logs_current?(path)),
@ -12,6 +13,7 @@ module NavigationItemsHelper
].compact
else
[
NavigationItem.new("Home", root_path, home_current?(path)),
NavigationItem.new("Lettings logs", lettings_logs_path, lettings_logs_current?(path)),
NavigationItem.new("Sales logs", sales_logs_path, sales_logs_current?(path)),
(NavigationItem.new("Schemes", schemes_path, non_support_supported_housing_schemes_current?(path)) if current_user.organisation.holds_own_stock? || current_user.organisation.stock_owners.present?),
@ -44,6 +46,10 @@ module NavigationItemsHelper
private
def home_current?(path)
path == root_path
end
def lettings_logs_current?(path)
path.starts_with?(lettings_logs_path)
end

0
app/views/home/index.html.erb

2
spec/features/start_page_spec.rb

@ -12,7 +12,7 @@ RSpec.describe "Start Page Features" do
it "takes you to logs" do
visit("/")
expect(page).to have_current_path("/lettings-logs")
expect(page).to have_current_path("/")
end
end

2
spec/features/user_spec.rb

@ -132,7 +132,7 @@ RSpec.describe "User Features" do
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: "pAssword1")
click_button("Sign in")
expect(page).to have_current_path("/lettings-logs")
expect(page).to have_current_path("/")
end
it "tries to access account page, redirects to log in page" do

23
spec/helpers/navigation_items_helper_spec.rb

@ -12,6 +12,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", true),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false),
@ -34,6 +35,7 @@ RSpec.describe NavigationItemsHelper do
let(:stock_owner) { create(:organisation) }
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", true),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
@ -53,6 +55,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the lettings logs page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", true),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
@ -71,6 +74,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the sales logs page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", true),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
@ -89,6 +93,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the users page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
@ -107,6 +112,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on their organisation details page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
@ -125,6 +131,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the account page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
@ -143,6 +150,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the individual user's page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
@ -161,6 +169,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the individual scheme's page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", true),
@ -191,6 +200,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", true),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false),
@ -213,6 +223,7 @@ RSpec.describe NavigationItemsHelper do
let(:stock_owner) { create(:organisation) }
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", true),
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
@ -236,6 +247,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the lettings logs page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", true),
@ -252,6 +264,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the sales logs page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -268,6 +281,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the users page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", true),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -284,6 +298,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the account page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -300,6 +315,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the Schemes page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -316,6 +332,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the individual user's page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", true),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -332,6 +349,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the individual scheme's page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -356,6 +374,7 @@ RSpec.describe NavigationItemsHelper do
context "when the user is on the scheme locations page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -382,6 +401,7 @@ RSpec.describe NavigationItemsHelper do
let(:required_sub_path) { "lettings-logs" }
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -412,6 +432,7 @@ RSpec.describe NavigationItemsHelper do
let(:required_sub_path) { "users" }
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -442,6 +463,7 @@ RSpec.describe NavigationItemsHelper do
let(:required_sub_path) { "schemes" }
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),
@ -472,6 +494,7 @@ RSpec.describe NavigationItemsHelper do
let(:required_sub_path) { "details" }
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Home", "/", false),
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false),

1
spec/requests/auth/passwords_controller_spec.rb

@ -67,7 +67,6 @@ RSpec.describe Auth::PasswordsController, type: :request do
put "/account/password", params: update_password_params
# Devise redirects once after re-sign in with new password and then root redirects as well.
follow_redirect!
follow_redirect!
expect(page).to have_css("div", class: "govuk-notification-banner__heading", text: message)
end
end

1
spec/requests/maintenance_controller_spec.rb

@ -153,7 +153,6 @@ RSpec.describe MaintenanceController, type: :request do
end
it "the cookie banner is visible" do
follow_redirect!
follow_redirect!
expect(page).to have_content("We’d like to use analytics cookies so we can understand how you use the service and make improvements.")
end

10
spec/requests/users_controller_spec.rb

@ -73,11 +73,10 @@ RSpec.describe UsersController, type: :request do
end
describe "title link" do
it "routes user to the /logs page" do
it "routes user to the home page" do
sign_in user
get "/", headers:, params: {}
follow_redirect!
expect(path).to include("/lettings-logs")
expect(path).to include("/")
expected_link = "<a class=\"govuk-header__link govuk-header__link--homepage\" href=\"/\">"
expect(CGI.unescape_html(response.body)).to include(expected_link)
end
@ -2025,10 +2024,9 @@ RSpec.describe UsersController, type: :request do
sign_in user
end
it "routes user to the /logs page" do
it "routes user to the home page" do
get "/", headers:, params: {}
follow_redirect!
expect(path).to include("/lettings-logs")
expect(path).to include("/")
expected_link = "<a class=\"govuk-header__link govuk-header__link--homepage\" href=\"/\">"
expect(CGI.unescape_html(response.body)).to include(expected_link)
end

Loading…
Cancel
Save