Skip to content

Commit

Permalink
Add additional fields to Content Migrations API
Browse files Browse the repository at this point in the history
Closes CNVS-29501

Test Plan:
* In a course, create some content migrations by exporting/importing
  course content
* GET /api/v1/courses/:course_id/content_migrations/:id
  using site admin credentials
* The response should contain infomation within an `audit_info` key
* Hit the same endpoint with teacher, student, or other non-site-admin
  credentials
* The API should not contain the extra information and should behave
  as before

Change-Id: Ia121b2ff72e9be553c1de74be2fd259038526dc5
Reviewed-on: https://gerrit.instructure.com/102193
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <[email protected]>
QA-Review: Heath Hales <[email protected]>
Product-Review: Dan Minkevitch <[email protected]>
  • Loading branch information
Dan Minkevitch committed Feb 16, 2017
1 parent 60e9740 commit 66f5ef2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/api/v1/content_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ def content_migration_json(migration, current_user, session, attachment_prefligh
json['migration_type_title'] = plugin.meta[:name].call
end
end

# For easier auditing for support requests
if Account.site_admin.grants_right?(current_user, :manage_courses)
json[:audit_info] = migration.respond_to?(:slice) &&
migration.slice(:id,
:user_id,
:migration_settings,
:started_at,
:finished_at,
:created_at,
:updated_at,
:progress,
:context_type,
:source_course_id,
:migration_type)
end

json
end

Expand Down
14 changes: 14 additions & 0 deletions spec/apis/v1/content_migrations_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@
expect(@migration.migration_issues.first.description).to eq "The file upload process timed out."
end

context "Site Admin" do
it "should contain additional auditing information for site admins" do
course_with_teacher_logged_in(:course => @course, :active_all => true, :user => site_admin_user)
json = api_call(:get, @migration_url, @params)
expect(json['audit_info']).not_to be_falsey
end

it "should not contain additional auditing information if not site admin" do
course_with_teacher_logged_in(:course => @course, :active_all => true, :user => user_with_pseudonym)
json = api_call(:get, @migration_url, @params)
expect(json['audit_info']).to be_falsey
end
end

context "User" do
before do
@migration = @user.content_migrations.create
Expand Down

0 comments on commit 66f5ef2

Please sign in to comment.