We only want to render the account link and login items in the header. And we want only render the Multitenancy and Administrators sections in the admin sidebar. We include the administrators management so it's possible to give permissions to other users to manage tenants. In order to restrict access to other sections by typing the URL or following a link, we're only enabling the rest of the routes when we aren't in the multitenancy management mode.
48 lines
1.6 KiB
Ruby
48 lines
1.6 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Layout::AdminHeaderComponent do
|
|
let(:user) { create(:user) }
|
|
before { Setting["org_name"] = "CONSUL" }
|
|
|
|
around do |example|
|
|
with_request_url("/") { example.run }
|
|
end
|
|
|
|
context "management section", controller: Management::BaseController do
|
|
it "shows the menu button and menu for administrators" do
|
|
create(:administrator, user: user)
|
|
|
|
render_inline Layout::AdminHeaderComponent.new(user)
|
|
|
|
expect(page).to have_link "Go back to CONSUL"
|
|
expect(page).to have_link "You don't have new notifications"
|
|
expect(page).to have_link "My content"
|
|
expect(page).to have_link "My account"
|
|
expect(page).to have_link "Sign out"
|
|
expect(page).to have_css "[data-toggle]"
|
|
end
|
|
|
|
it "does not show the menu button and menu for managers" do
|
|
create(:manager, user: user)
|
|
|
|
render_inline Layout::AdminHeaderComponent.new(user)
|
|
|
|
expect(page).to have_link "Go back to CONSUL"
|
|
expect(page).not_to have_content "You don't have new notifications"
|
|
expect(page).not_to have_content "My content"
|
|
expect(page).not_to have_content "My account"
|
|
expect(page).not_to have_content "Sign out"
|
|
expect(page).not_to have_css "[data-toggle]"
|
|
end
|
|
end
|
|
|
|
it "does not show link to root path when multitenancy_management_mode is enabled" do
|
|
allow(Rails.application.config).to receive(:multitenancy_management_mode).and_return(true)
|
|
create(:administrator, user: user)
|
|
|
|
render_inline Layout::AdminHeaderComponent.new(user)
|
|
|
|
expect(page).not_to have_link "Go back to CONSUL"
|
|
end
|
|
end
|