|
|
|
@ -22,7 +22,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the lettings logs item set as current" do |
|
|
|
|
expect(primary_items("/lettings-logs", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -46,11 +46,29 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the lettings logs item set as current" do |
|
|
|
|
expect(primary_items("/lettings-logs", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
context "when the user is on the home page" do |
|
|
|
|
let(:expected_navigation_items) do |
|
|
|
|
[ |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Home", "/", true), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}/details", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Stock owners", "/organisations/#{current_user.organisation.id}/stock-owners", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Managing agents", "/organisations/#{current_user.organisation.id}/managing-agents", false), |
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the home item set as current" do |
|
|
|
|
expect(primary_items("/", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the user is on the lettings logs page" do |
|
|
|
|
let(:expected_navigation_items) do |
|
|
|
@ -66,7 +84,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the lettings logs item set as current" do |
|
|
|
|
expect(primary_items("/lettings-logs", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -85,7 +103,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the sales logs item set as current" do |
|
|
|
|
expect(primary_items("/sales-logs", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -123,7 +141,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the organisation item set as current" do |
|
|
|
|
expect(primary_items("/organisations/#{current_user.organisation.id}/details", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -142,7 +160,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with no items set as current" do |
|
|
|
|
expect(primary_items("/account", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -180,7 +198,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with Schemes item set as current" do |
|
|
|
|
it "returns navigation items with schemes item set as current" do |
|
|
|
|
expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -210,7 +228,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the lettings logs item set as current" do |
|
|
|
|
expect(primary_items("/lettings-logs", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -234,7 +252,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the lettings logs item set as current" do |
|
|
|
|
expect(primary_items("/lettings-logs", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -244,6 +262,25 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
context "when the user is a support user" do |
|
|
|
|
let(:current_user) { create(:user, :support) } |
|
|
|
|
|
|
|
|
|
context "when the user is on the home page" do |
|
|
|
|
let(:expected_navigation_items) do |
|
|
|
|
[ |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Home", "/", true), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Lettings logs", "/lettings-logs", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Sales logs", "/sales-logs", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}/details", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Stock owners", "/organisations/#{current_user.organisation.id}/stock-owners", false), |
|
|
|
|
NavigationItemsHelper::NavigationItem.new("Managing agents", "/organisations/#{current_user.organisation.id}/managing-agents", false), |
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the home item set as current" do |
|
|
|
|
expect(primary_items("/", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the user is on the lettings logs page" do |
|
|
|
|
let(:expected_navigation_items) do |
|
|
|
|
[ |
|
|
|
@ -256,7 +293,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the lettings logs item set as current" do |
|
|
|
|
expect(primary_items("/lettings-logs", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -273,7 +310,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the sales logs item set as current" do |
|
|
|
|
expect(primary_items("/sales-logs", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -307,7 +344,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the no items set as current" do |
|
|
|
|
expect(primary_items("/account", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -324,7 +361,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
it "returns navigation items with the schemes item set as current" do |
|
|
|
|
expect(primary_items("/schemes", current_user)).to eq(expected_navigation_items) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -365,7 +402,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with Schemes item set as current" do |
|
|
|
|
it "returns navigation items with schemes item set as current" do |
|
|
|
|
expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items) |
|
|
|
|
expect(scheme_items("/schemes/1", 1)).to eq(expected_scheme_items) |
|
|
|
|
end |
|
|
|
@ -390,7 +427,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with Schemes item set as current" do |
|
|
|
|
it "returns navigation items with schemes item set as current" do |
|
|
|
|
expect(primary_items("/schemes/1/locations", current_user)).to eq(expected_navigation_items) |
|
|
|
|
expect(scheme_items("/schemes/1/locations", 1)).to eq(expected_scheme_items) |
|
|
|
|
end |
|
|
|
@ -422,7 +459,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the logs item set as current" do |
|
|
|
|
it "returns navigation items with the lettings logs item set as current" do |
|
|
|
|
expect(primary_items("/organisations/#{current_user.organisation.id}/#{required_sub_path}", current_user)).to eq(expected_navigation_items) |
|
|
|
|
expect(secondary_items("/organisations/#{current_user.organisation.id}/#{required_sub_path}", current_user.organisation.id)).to eq(expected_secondary_navigation_items) |
|
|
|
|
end |
|
|
|
@ -453,7 +490,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the logs item set as current" do |
|
|
|
|
it "returns navigation items with the users item set as current" do |
|
|
|
|
expect(primary_items("/organisations/#{current_user.organisation.id}/#{required_sub_path}", current_user)).to eq(expected_navigation_items) |
|
|
|
|
expect(secondary_items("/organisations/#{current_user.organisation.id}/#{required_sub_path}", current_user.organisation.id)).to eq(expected_secondary_navigation_items) |
|
|
|
|
end |
|
|
|
@ -515,7 +552,7 @@ RSpec.describe NavigationItemsHelper do
|
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns navigation items with the logs item set as current" do |
|
|
|
|
it "returns navigation items with the organisation item set as current" do |
|
|
|
|
expect(primary_items("/organisations/#{current_user.organisation.id}/#{required_sub_path}", current_user)).to eq(expected_navigation_items) |
|
|
|
|
expect(secondary_items("/organisations/#{current_user.organisation.id}/#{required_sub_path}", current_user.organisation.id)).to eq(expected_secondary_navigation_items) |
|
|
|
|
end |
|
|
|
|