Browse Source

Cldc 1361 only stock owning orgs see schemes (#838)

* only stock owning orgs see schemes in nav bar

* lint

* added to organisation factory and fixed tests

* removed schemes from secondary navigation bar for non stock owning orgs

* test

* lint

* remove factory la
pull/844/head
Ted-U 2 years ago committed by GitHub
parent
commit
80b4dfecae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      app/helpers/navigation_items_helper.rb
  2. 12
      spec/features/organisation_spec.rb

20
app/helpers/navigation_items_helper.rb

@ -26,12 +26,20 @@ module NavigationItemsHelper
end end
def secondary_items(path, current_organisation_id) def secondary_items(path, current_organisation_id)
[ if current_user.organisation.holds_own_stock?
NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)), [
NavigationItem.new("Schemes", "/organisations/#{current_organisation_id}/schemes", subnav_supported_housing_schemes_path?(path)), NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)),
NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)), NavigationItem.new("Schemes", "/organisations/#{current_organisation_id}/schemes", subnav_supported_housing_schemes_path?(path)),
NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)), NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)),
] NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)),
]
else
[
NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)),
NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)),
NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)),
]
end
end end
def scheme_items(path, current_scheme_id, title) def scheme_items(path, current_scheme_id, title)

12
spec/features/organisation_spec.rb

@ -61,6 +61,18 @@ RSpec.describe "User Features" do
expect(page).to have_link("Schemes", href: "/schemes") expect(page).to have_link("Schemes", href: "/schemes")
end end
end end
context "when the user is support and the organisation does not hold housing stock" do
before do
organisation.update!(holds_own_stock: false)
user.update!(role: "support")
end
it "does not show schemes in the primary or secondary navigation bar on the organisations page" do
visit("/organisations")
expect(page).not_to have_link("Schemes", href: "/schemes", count: 2)
end
end
end end
context "when users are part of organisation" do context "when users are part of organisation" do

Loading…
Cancel
Save