Skip to content

Commit

Permalink
fix: Root users incorrectly getting warning they have no rights (#1368)
Browse files Browse the repository at this point in the history
* Don't show root users the no-content warning

When logged in as a root user (who has no content)
and on the home dashboard page
then don't show the no content nag box

Also: users who are editors have content even if they have no tags,
neighbourhoods or partners. Like root users.
  • Loading branch information
ivankocienski authored Jul 6, 2022
1 parent ec39fc5 commit 95d159d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def options_for_roles
end

def user_has_no_rights?(user)
return false if user.root?
return false if user.editor?

return false if user.tag_admin?
return false if user.neighbourhood_admin?
return false if user.partner_admin?
Expand Down
12 changes: 12 additions & 0 deletions test/integration/admin/home_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@ class AdminHomeIntegrationTest < ActionDispatch::IntegrationTest

setup do
@admin = create(:root)
@citizen = create(:citizen)
end

test "Admin home page can't be accessed without a login" do
@default_site = create_default_site
get "http://admin.lvh.me"
assert_redirected_to "http://admin.lvh.me/users/sign_in"
end

test "Admin can access page when logged in" do
sign_in @admin
get "http://admin.lvh.me"
assert_response :success

assert_select 'title', text: "Dashboard | PlaceCal Admin"
end

test "Blank citizen gets a 'no content' warning" do
sign_in @citizen
get "http://admin.lvh.me"
assert_response :success

assert_select 'title', text: "Dashboard | PlaceCal Admin"
assert_select 'h1', text: "Missing Permissions"
end

end

0 comments on commit 95d159d

Please sign in to comment.