add courses and subaccounts to qraphql AccountType
closes PLAT-5253 flag = none Test Plan: - verify that you can see courses and sub-accounts under the main account type in /graphiql Change-Id: I98db4a0e64c70c9886171fc3e27bd14cfdc16df7 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/221285 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Marc Phillips <mphillips@instructure.com> QA-Review: Xander Moffatt <xmoffatt@instructure.com> Product-Review: Clint Furse <cfurse@instructure.com>
This commit is contained in:
parent
e97db6ab80
commit
fcc574fd7b
|
@ -31,5 +31,16 @@ module Types
|
|||
# batch load it in a reasonable way.
|
||||
object.resolved_outcome_proficiency&.outcome_proficiency_ratings
|
||||
end
|
||||
|
||||
field :courses_connection, CourseType.connection_type, null: true
|
||||
def courses_connection
|
||||
return unless object.grants_right?(current_user, :read_course_list)
|
||||
object.associated_courses
|
||||
end
|
||||
|
||||
field :sub_accounts_connection, AccountType.connection_type, null: true
|
||||
def sub_accounts_connection
|
||||
object.sub_accounts.order(:id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,8 @@ describe Types::AccountType do
|
|||
before(:once) do
|
||||
teacher_in_course(active_all: true)
|
||||
student_in_course(active_all: false)
|
||||
account_admin_user
|
||||
@sub_account = account_model parent_account: @course.root_account
|
||||
end
|
||||
|
||||
let(:account) { @course.root_account }
|
||||
|
@ -43,4 +45,16 @@ describe Types::AccountType do
|
|||
account_type.resolve('proficiencyRatingsConnection { nodes { _id } }').sort
|
||||
).to eq OutcomeProficiencyRating.all.map { |r| r.id.to_s }.sort
|
||||
end
|
||||
|
||||
it 'works for courses' do
|
||||
expect(account_type.resolve('coursesConnection { nodes { _id } }', current_user: @admin)).to eq [@course.id.to_s]
|
||||
end
|
||||
|
||||
it 'requires read_course_list permission' do
|
||||
expect(account_type.resolve('coursesConnection { nodes { _id } }', current_user: @teacher)).to be_nil
|
||||
end
|
||||
|
||||
it 'works for subaccounts' do
|
||||
expect(account_type.resolve('subAccountsConnection { nodes { _id } }')).to eq [@sub_account.id.to_s]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue