diff --git a/app/controllers/master_courses/master_templates_controller.rb b/app/controllers/master_courses/master_templates_controller.rb
index accee277447..b636fb6318c 100644
--- a/app/controllers/master_courses/master_templates_controller.rb
+++ b/app/controllers/master_courses/master_templates_controller.rb
@@ -515,6 +515,7 @@ class MasterCourses::MasterTemplatesController < ApplicationController
def migrations_index
# sort id desc
migrations = Api.paginate(@template.master_migrations.order("id DESC"), self, api_v1_course_blueprint_migrations_url)
+ ActiveRecord::Associations::Preloader.new.preload(migrations, :user)
render :json => migrations.map{|migration| master_migration_json(migration, @current_user, session) }
end
@@ -591,6 +592,7 @@ class MasterCourses::MasterTemplatesController < ApplicationController
where(:migration_type => 'master_course_import', :child_subscription_id => @subscription).
order('id DESC')
migrations = Api.paginate(migrations, self, api_v1_course_blueprint_imports_url)
+ ActiveRecord::Associations::Preloader.new.preload(migrations, :user)
render :json => migrations.map{ |migration| master_migration_json(migration.master_migration, @current_user,
session, :child_migration => migration,
:subscription => @subscription) }
diff --git a/app/jsx/blueprint_courses/components/SyncHistoryItem.js b/app/jsx/blueprint_courses/components/SyncHistoryItem.js
index 4c8cc5fa1ce..73ff47e7a06 100644
--- a/app/jsx/blueprint_courses/components/SyncHistoryItem.js
+++ b/app/jsx/blueprint_courses/components/SyncHistoryItem.js
@@ -37,7 +37,12 @@ const SyncHistoryItem = ({migration, heading, ChangeComponent}) => {
- {I18n.t('%{count} pushed changes', {count: changes.length})}
+ {migration.user?.display_name
+ ? I18n.t('%{count} changes pushed by %{user}', {
+ count: changes.length,
+ user: migration.user.display_name
+ })
+ : I18n.t('%{count} pushed changes', {count: changes.length})}
{comment && {`"${comment}"`}}
diff --git a/lib/api/v1/master_courses.rb b/lib/api/v1/master_courses.rb
index 4063129df4b..eee29df893c 100644
--- a/lib/api/v1/master_courses.rb
+++ b/lib/api/v1/master_courses.rb
@@ -16,6 +16,8 @@
# with this program. If not, see .
module Api::V1::MasterCourses
+ include Api::V1::User
+
def master_template_json(template, user, session, opts={})
hash = api_json(template, user, session, :only => %w(id course_id), :methods => %w{last_export_completed_at associated_course_count})
migration = template.active_migration
@@ -33,6 +35,7 @@ module Api::V1::MasterCourses
hash['template_id'] = migration.master_template_id
end
hash['id'] = opts[:child_migration].id if opts[:child_migration]
+ hash['user'] = user_display_json(migration.user)
hash
end
diff --git a/spec/apis/v1/master_courses/master_templates_api_spec.rb b/spec/apis/v1/master_courses/master_templates_api_spec.rb
index 996cb402b73..c2daa3b79df 100644
--- a/spec/apis/v1/master_courses/master_templates_api_spec.rb
+++ b/spec/apis/v1/master_courses/master_templates_api_spec.rb
@@ -230,6 +230,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
json = api_call(:get, "/api/v1/courses/#{@course.id}/blueprint_templates/default/migrations/#{@migration.id}",
@base_params.merge(:action => 'migrations_show', :id => @migration.to_param))
expect(json['workflow_state']).to eq 'queued'
+ expect(json['user']['display_name']).to eq @user.short_name
expect(json['comment']).to eq 'Hark!'
end
@@ -239,6 +240,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
migration2 = MasterCourses::MasterMigration.start_new_migration!(@template, @user)
json = api_call(:get, "/api/v1/courses/#{@course.id}/blueprint_templates/default/migrations", @base_params.merge(:action => 'migrations_index'))
+ expect(json[0]['user']['display_name']).to eq @user.short_name
pairs = json.map{|hash| [hash['id'], hash['workflow_state']]}
expect(pairs).to eq [[migration2.id, 'queued'], [@migration.id, 'completed']]
end
@@ -263,6 +265,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
@base_params.merge(:subscription_id => @sub.to_param, :course_id => @child_course.to_param, :action => 'imports_show', :id => @minion_migration.to_param))
expect(json['workflow_state']).to eq 'completed'
expect(json['subscription_id']).to eq @sub.id
+ expect(json['user']['display_name']).to eq @user.short_name
expect(json['comment']).to eq 'Hark!'
end
@@ -272,6 +275,7 @@ describe MasterCourses::MasterTemplatesController, type: :request do
expect(json.size).to eq 1
expect(json[0]['id']).to eq @minion_migration.id
expect(json[0]['subscription_id']).to eq @sub.id
+ expect(json[0]['user']['display_name']).to eq @user.short_name
end
it "filters by subscription and enumerates old subscriptions" do
diff --git a/spec/javascripts/jsx/blueprint_courses/components/SyncHistoryItemSpec.js b/spec/javascripts/jsx/blueprint_courses/components/SyncHistoryItemSpec.js
index 61925a38050..ac65f48f2dc 100644
--- a/spec/javascripts/jsx/blueprint_courses/components/SyncHistoryItemSpec.js
+++ b/spec/javascripts/jsx/blueprint_courses/components/SyncHistoryItemSpec.js
@@ -58,3 +58,10 @@ test('renders changes using the appropriate prop component', () => {
const node = tree.find('.bcs__history-item .test-change')
equal(node.length, props.migration.changes.length)
})
+
+test('includes the name of the person who started the sync', () => {
+ const tree = enzyme.mount()
+ const node = tree.find('.bcs__history-item__title')
+ const text = node.text()
+ notEqual(text.indexOf('changes pushed by Bob Jones'), -1)
+})
diff --git a/spec/javascripts/jsx/blueprint_courses/getSampleData.js b/spec/javascripts/jsx/blueprint_courses/getSampleData.js
index 33662a679f8..23d27dd4467 100644
--- a/spec/javascripts/jsx/blueprint_courses/getSampleData.js
+++ b/spec/javascripts/jsx/blueprint_courses/getSampleData.js
@@ -18,8 +18,14 @@
export default function getSampleData() {
return {
- terms: [{id: '1', name: 'Term One'}, {id: '2', name: 'Term Two'}],
- subAccounts: [{id: '1', name: 'Account One'}, {id: '2', name: 'Account Two'}],
+ terms: [
+ {id: '1', name: 'Term One'},
+ {id: '2', name: 'Term Two'}
+ ],
+ subAccounts: [
+ {id: '1', name: 'Account One'},
+ {id: '2', name: 'Account Two'}
+ ],
childCourse: {
id: '1',
enrollment_term_id: '1',
@@ -67,6 +73,9 @@ export default function getSampleData() {
id: '2',
workflow_state: 'completed',
created_at: '2013-08-28T23:59:00-06:00',
+ user: {
+ display_name: 'Bob Jones'
+ },
changes: [
{
asset_id: '2',