canvas_sync 0.17.23.beta7 → 0.17.26.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.23.beta7".freeze
2
+ VERSION = "0.17.26.beta1".freeze
3
3
  end
data/lib/canvas_sync.rb CHANGED
@@ -80,6 +80,7 @@ module CanvasSync
80
80
  ].freeze
81
81
 
82
82
  JobBatches::ChainBuilder.register_chain_job(CanvasSync::Jobs::SyncTermsJob, :sub_jobs)
83
+ JobBatches::ChainBuilder.register_chain_job(CanvasSync::Jobs::TermBatchesJob, :sub_jobs)
83
84
  JobBatches::ChainBuilder.register_chain_job(CanvasSync::Jobs::BeginSyncChainJob, 0)
84
85
 
85
86
  class << self
@@ -130,12 +131,8 @@ module CanvasSync
130
131
  models,
131
132
  term_scope: nil,
132
133
  term_scoped_models: DEFAULT_TERM_SCOPE_MODELS,
133
- legacy_support: false,
134
- account_id: nil,
135
- updated_after: nil,
136
- full_sync_every: nil,
137
- batch_genre: nil,
138
- options: {}
134
+ options: {},
135
+ **kwargs
139
136
  ) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/LineLength
140
137
  return unless models.present?
141
138
  models.map! &:to_s
@@ -155,7 +152,7 @@ module CanvasSync
155
152
  context_module_items: CanvasSync::Jobs::SyncContextModuleItemsJob,
156
153
  }.with_indifferent_access
157
154
 
158
- root_chain = JobBatches::ChainBuilder.new(CanvasSync::Jobs::BeginSyncChainJob)
155
+ root_chain = base_canvas_sync_chain(**kwargs, globals: options[:global] || kwargs[:globals])
159
156
  concurrent_root_chain = JobBatches::ChainBuilder.new(JobBatches::ConcurrentBatchJob)
160
157
  root_chain << concurrent_root_chain
161
158
  current_chain = concurrent_root_chain
@@ -211,6 +208,20 @@ module CanvasSync
211
208
  # Wrap it all up
212
209
  ###############################
213
210
 
211
+ root_chain
212
+ end
213
+
214
+ def base_canvas_sync_chain(
215
+ legacy_support: false, # Import records 1 by 1 instead of with bulk upserts
216
+ account_id: nil, # legacy/non PandaPal apps
217
+ updated_after: nil,
218
+ full_sync_every: nil,
219
+ batch_genre: nil,
220
+ globals: {},
221
+ &blk
222
+ )
223
+ root_chain = JobBatches::ChainBuilder.new(CanvasSync::Jobs::BeginSyncChainJob)
224
+
214
225
  global_options = {
215
226
  legacy_support: legacy_support,
216
227
  updated_after: updated_after,
@@ -218,10 +229,12 @@ module CanvasSync
218
229
  batch_genre: batch_genre,
219
230
  }
220
231
  global_options[:account_id] = account_id if account_id.present?
221
- global_options.merge!(options[:global]) if options[:global].present?
232
+ global_options.merge!(globals) if globals
222
233
 
223
234
  root_chain.params[1] = global_options
224
235
 
236
+ root_chain.apply_block(&blk)
237
+
225
238
  root_chain
226
239
  end
227
240
 
@@ -35,11 +35,18 @@ RSpec.describe CanvasSync::Processors::ProvisioningReportProcessor do
35
35
  end
36
36
 
37
37
  it 'processes xlist' do
38
+ subject.process('spec/support/fixtures/reports/sections.csv', { models: ['sections'] }, 1)
39
+ expect(Section.find_by(canvas_id: 2).name).to eq "Lame Section"
40
+
38
41
  subject.process('spec/support/fixtures/reports/xlist.csv', { models: ['xlist'] }, 1)
42
+
39
43
  expect(Section.where.not(canvas_nonxlist_course_id: nil).count).to eq 1
40
44
  cross_listed_section = Section.where.not(canvas_nonxlist_course_id: nil).first
41
45
  expect(cross_listed_section.canvas_id).to eq 2
42
- expect(cross_listed_section.canvas_nonxlist_course_id).to eq 2
46
+ expect(cross_listed_section.canvas_nonxlist_course_id).to eq 3
47
+
48
+ expect(cross_listed_section.canvas_course_id).to eq 2
49
+ expect(cross_listed_section.name).to eq "Lame Section"
43
50
  end
44
51
 
45
52
  it 'processes groups' do