show content shares tab to admins w/o enrollments
test plan: - as an account admin user with no course enrollments, you should (1) see the content share tab in your user profile (2) clicking it should work and take you to a page that shows a "no content shared" message if you have not yet received any shares fixes LA-171 flag=direct_share Change-Id: If421c418bf29ce520644dbc52653e2f31a91c637 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/217636 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Tested-by: Jenkins Reviewed-by: James Williams <jamesw@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
03abd24284
commit
ce78ab5500
|
@ -473,7 +473,7 @@ class ProfileController < ApplicationController
|
|||
end
|
||||
|
||||
def content_shares
|
||||
raise not_found if !@domain_root_account.feature_enabled?(:direct_share) || !@current_user.non_student_enrollment?
|
||||
raise not_found unless @domain_root_account.feature_enabled?(:direct_share) && @current_user.can_content_share?
|
||||
|
||||
@user ||= @current_user
|
||||
set_active_tab 'content_shares'
|
||||
|
|
|
@ -1815,6 +1815,17 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def account_membership?
|
||||
return @_account_membership if defined?(@_account_membership)
|
||||
@_account_membership = Rails.cache.fetch_with_batched_keys(['has_account_user', ApplicationController.region ].cache_key, batch_object: self, batched_keys: :account_users) do
|
||||
self.account_users.shard(in_region_associated_shards).active.exists?
|
||||
end
|
||||
end
|
||||
|
||||
def can_content_share?
|
||||
non_student_enrollment? || account_membership?
|
||||
end
|
||||
|
||||
def participating_current_and_concluded_course_ids
|
||||
cached_course_ids('current_and_concluded') do |enrollments|
|
||||
enrollments.current_and_concluded.not_inactive_by_date_ignoring_access
|
||||
|
|
|
@ -105,7 +105,7 @@ class UserProfile < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def insert_content_shares_tab(tabs, user, opts)
|
||||
if user && user.non_student_enrollment? && opts[:root_account]&.feature_enabled?(:direct_share)
|
||||
if user && opts[:root_account]&.feature_enabled?(:direct_share) && user.can_content_share?
|
||||
tabs << {
|
||||
id: TAB_CONTENT_SHARES,
|
||||
label: I18n.t("Shared Content"),
|
||||
|
|
|
@ -257,6 +257,12 @@ describe ProfileController do
|
|||
expect(assigns.dig(:js_env, :COMMON_CARTRIDGE_VIEWER_URL)).to eq('the_ccv_url')
|
||||
end
|
||||
|
||||
it "should show if the user has an account membership" do
|
||||
user_session(account_admin_user)
|
||||
get 'content_shares', params: {user_id: @admin.id}
|
||||
expect(response).to render_template('content_shares')
|
||||
end
|
||||
|
||||
it "should 404 if user has only student enrollments" do
|
||||
user_session(@student)
|
||||
get 'content_shares', params: {user_id: @student.id}
|
||||
|
|
|
@ -43,6 +43,13 @@ describe UserProfile do
|
|||
expect(tabs.map { |t| t[:id] }).to include UserProfile::TAB_CONTENT_SHARES
|
||||
end
|
||||
|
||||
it "should show shared content tab when user has account membership" do
|
||||
account_admin_user(account: account)
|
||||
account.enable_feature!(:direct_share)
|
||||
tabs = @admin.profile.tabs_available(@admin, :root_account => account)
|
||||
expect(tabs.map { |t| t[:id] }).to include UserProfile::TAB_CONTENT_SHARES
|
||||
end
|
||||
|
||||
it "should not show shared content tab when user has only student enrollments" do
|
||||
student_in_course(:active_all => true)
|
||||
account.enable_feature!(:direct_share)
|
||||
|
|
Loading…
Reference in New Issue