don't show "customize this menu" link to sub-account admins
test plan: * enable help links in the rails console with `Setting.set('show_feedback_link', 'true')` * confirm that the "Customize this menu" link at the bottom of the help panel only shows up if you are a root account admin, not a sub-account admin closes #CNVS-31217 Change-Id: I0cb8d09b11e5bc663069cbac4782fd8a683e752d Reviewed-on: https://gerrit.instructure.com/89418 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Stephen Jensen <sejensen@instructure.com> QA-Review: Heath Hales <hhales@instructure.com>
This commit is contained in:
parent
a800f66a5e
commit
2474d08b6b
|
@ -45,7 +45,7 @@ define([
|
|||
|
||||
// if the current user is an admin, show the settings link to
|
||||
// customize this menu
|
||||
if (window.ENV.current_user_roles.indexOf("admin") > -1) {
|
||||
if (window.ENV.current_user_roles.indexOf("root_admin") > -1) {
|
||||
links.push(
|
||||
<li key="admin" className="ic-NavMenu-list-item ic-NavMenu-list-item--feature-item">
|
||||
<a
|
||||
|
|
|
@ -2300,14 +2300,20 @@ class User < ActiveRecord::Base
|
|||
|
||||
def roles(root_account)
|
||||
return @roles if @roles
|
||||
@roles = Rails.cache.fetch(['user_roles_for_root_account', self, root_account].cache_key) do
|
||||
@roles = Rails.cache.fetch(['user_roles_for_root_account2', self, root_account].cache_key) do
|
||||
roles = ['user']
|
||||
|
||||
enrollment_types = root_account.all_enrollments.where(user_id: self, workflow_state: 'active').uniq.pluck(:type)
|
||||
roles << 'student' unless (enrollment_types & %w[StudentEnrollment StudentViewEnrollment]).empty?
|
||||
roles << 'teacher' unless (enrollment_types & %w[TeacherEnrollment TaEnrollment DesignerEnrollment]).empty?
|
||||
roles << 'observer' unless (enrollment_types & %w[ObserverEnrollment]).empty?
|
||||
roles << 'admin' unless root_account.all_account_users_for(self).empty?
|
||||
|
||||
account_users = root_account.all_account_users_for(self)
|
||||
if account_users.any?
|
||||
roles << 'admin'
|
||||
root_ids = [root_account.id, Account.site_admin.id]
|
||||
roles << 'root_admin' if account_users.any?{|au| root_ids.include?(au.account_id) }
|
||||
end
|
||||
roles
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2972,10 +2972,16 @@ describe User do
|
|||
expect(@user.roles(@account)).to eq %w[user observer]
|
||||
end
|
||||
|
||||
it "includes 'admin' if the user has an admin user record" do
|
||||
@account.account_users.create!(:user => @user, :role => admin_role)
|
||||
it "includes 'admin' if the user has a sub-account admin user record" do
|
||||
sub_account = @account.sub_accounts.create!
|
||||
sub_account.account_users.create!(:user => @user, :role => admin_role)
|
||||
expect(@user.roles(@account)).to eq %w[user admin]
|
||||
end
|
||||
|
||||
it "includes 'root_admin' if the user has a root account admin user record" do
|
||||
@account.account_users.create!(:user => @user, :role => admin_role)
|
||||
expect(@user.roles(@account)).to eq %w[user admin root_admin]
|
||||
end
|
||||
end
|
||||
|
||||
it "should not grant user_notes rights to restricted users" do
|
||||
|
|
|
@ -127,4 +127,30 @@ describe "help dialog" do
|
|||
expect(f("#help-dialog a[href='#create_ticket']")).to be_displayed
|
||||
end
|
||||
end
|
||||
|
||||
context "customization link" do
|
||||
before :each do
|
||||
user_logged_in(:active_all => true)
|
||||
Setting.set('show_feedback_link', 'true')
|
||||
end
|
||||
|
||||
it "should show the link to root account admins" do
|
||||
Account.default.account_users.create!(:user => @user)
|
||||
get "/"
|
||||
wait_for_ajaximations
|
||||
f('#global_nav_help_link').click
|
||||
wait_for_ajaximations
|
||||
expect(ff("#help_tray .ic-NavMenu-list-item__link").last).to include_text("Customize this menu")
|
||||
end
|
||||
|
||||
it "should not show the link to sub account admins" do
|
||||
sub = Account.default.sub_accounts.create!
|
||||
sub.account_users.create!(:user => @user)
|
||||
get "/"
|
||||
wait_for_ajaximations
|
||||
f('#global_nav_help_link').click
|
||||
wait_for_ajaximations
|
||||
expect(ff("#help_tray .ic-NavMenu-list-item__link").last).to_not include_text("Customize this menu")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue