Browse Source

tests and code to make sure users are highlighted

pull/656/head
JG 3 years ago
parent
commit
a1997f88ec
  1. 2
      app/helpers/navigation_items_helper.rb
  2. 30
      spec/helpers/navigation_items_helper_spec.rb

2
app/helpers/navigation_items_helper.rb

@ -57,7 +57,7 @@ private
end end
def subnav_users_path?(path) def subnav_users_path?(path)
path.include?("/organisations") && path.include?("/users") (path.include?("/organisations") && path.include?("/users")) || path.include?("/users/")
end end
def subnav_logs_path?(path) def subnav_logs_path?(path)

30
spec/helpers/navigation_items_helper_spec.rb

@ -67,6 +67,21 @@ RSpec.describe NavigationItemsHelper do
expect(primary_items("/account", current_user)).to eq(expected_navigation_items) expect(primary_items("/account", current_user)).to eq(expected_navigation_items)
end end
end end
context "when the user is on the individual user's page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", true),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
]
end
it "returns navigation items with the users item set as current" do
expect(primary_items("/users/1", current_user)).to eq(expected_navigation_items)
end
end
end end
context "when the user is a support user" do context "when the user is a support user" do
@ -132,6 +147,21 @@ RSpec.describe NavigationItemsHelper do
end end
end end
context "when the user is on the individual user's page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", true),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
]
end
it "returns navigation items with the users item set as current" do
expect(primary_items("/users/1", current_user)).to eq(expected_navigation_items)
end
end
context "when the user is on the specific organisation's page" do context "when the user is on the specific organisation's page" do
context "when the user is on organisation logs page" do context "when the user is on organisation logs page" do
let(:required_sub_path) { "logs" } let(:required_sub_path) { "logs" }

Loading…
Cancel
Save