canvas_sync 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -6
- data/db/migrate/20170915210836_create_canvas_sync_job_log.rb +1 -1
- data/lib/canvas_sync.rb +30 -4
- data/lib/canvas_sync/importers/legacy_importer.rb +17 -0
- data/lib/canvas_sync/jobs/report_checker.rb +1 -1
- data/lib/canvas_sync/jobs/report_processor_job.rb +4 -0
- data/lib/canvas_sync/jobs/report_starter.rb +1 -1
- data/lib/canvas_sync/jobs/sync_provisioning_report_job.rb +1 -1
- data/lib/canvas_sync/jobs/sync_terms_job.rb +6 -2
- data/lib/canvas_sync/processors/provisioning_report_processor.rb +37 -11
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/canvas_sync/canvas_sync_spec.rb +2 -2
- data/spec/canvas_sync/jobs/report_checker_spec.rb +3 -2
- data/spec/canvas_sync/jobs/report_processor_job_spec.rb +1 -1
- data/spec/canvas_sync/jobs/report_starter_spec.rb +1 -1
- data/spec/canvas_sync/jobs/sync_provisioning_report_job_spec.rb +3 -3
- data/spec/canvas_sync/jobs/sync_terms_job_spec.rb +3 -2
- data/spec/canvas_sync/jobs/sync_users_job_spec.rb +1 -1
- data/spec/canvas_sync/processors/provisioning_report_processor_spec.rb +7 -0
- metadata +5 -16
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -4391
- data/spec/dummy/log/test.log +0 -0
- data/spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv +0 -3
- data/spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73fb470e4beeaee615dcf4cdb7170c973a2f9edb
|
|
4
|
+
data.tar.gz: df158059b78f81df04576230dee55e6bc230b755
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2af3c510be69d2432e57f21789b2cb2ca3dcdc61c7fa6b3b3d7d31fb67b00d4e45527bc0ca2eb9ee73c12764581676ca8b1cd2faf2adbae12f8155d404692c25
|
|
7
|
+
data.tar.gz: 174b2272acc70ffa36f2be27192fa366afcb9f18940bafda33d4ba8d8780ea24bdd72663ea1a28ece5dbc5dd88e8f2786e7baaab3d670ff7c0e8d964fd6954ad
|
data/README.md
CHANGED
|
@@ -54,13 +54,13 @@ end
|
|
|
54
54
|
Once that's done and you've used the generator to create your models and migrations you can run the standard provisioning sync:
|
|
55
55
|
|
|
56
56
|
```ruby
|
|
57
|
-
CanvasSync.provisioning_sync(<array of models to sync>, <optional term scope>)
|
|
57
|
+
CanvasSync.provisioning_sync(<array of models to sync>, term_scope: <optional term scope>)
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
Example:
|
|
61
61
|
|
|
62
62
|
```ruby
|
|
63
|
-
CanvasSync.provisioning_sync(['users', 'courses'], :active)
|
|
63
|
+
CanvasSync.provisioning_sync(['users', 'courses'], term_scope: :active)
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
This will kick off a string of jobs to sync your specified models.
|
|
@@ -69,6 +69,16 @@ If you pass in the optional `term_scope` the provisioning reports will be run fo
|
|
|
69
69
|
|
|
70
70
|
Imports are inserted in bulk with [https://github.com/zdennis/activerecord-import](activerecord-import) so they should be very fast.
|
|
71
71
|
|
|
72
|
+
## Legacy Support
|
|
73
|
+
|
|
74
|
+
If you have an old style tool that needs to sync data on a row by row basis, you can pass in the `legacy_support: true` option. In order for this to work, your models must have a `create_or_update_from_csv` class method defined that accepts a row argument. This method will get passed each row from the CSV, and it's up to you to persist it.
|
|
75
|
+
|
|
76
|
+
Example:
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
CanvasSync.provisioning_sync(['users', 'courses'], term_scope: :active, legacy_support: true)
|
|
80
|
+
```
|
|
81
|
+
|
|
72
82
|
## CanvasSync::JobLog
|
|
73
83
|
|
|
74
84
|
Running the migrations will create a `canvas_sync_job_logs` table. All the jobs written in this gem will create a `CanvasSync::JobLog` and store data about their arguments, job class, any exceptions, and start/completion time. This will work regardless of your queue adapter.
|
|
@@ -200,7 +210,7 @@ When adding to or updating this gem, make sure you do the following:
|
|
|
200
210
|
|
|
201
211
|
## TODO
|
|
202
212
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
- Add
|
|
213
|
+
- Rethink how options are passed around. The current strategy of having "global_options" and per job options works
|
|
214
|
+
decently, but can be confusing. The difficulty is representing the options in a way that is easily serializable
|
|
215
|
+
by the queue adaptor and easily passed around.
|
|
216
|
+
- Add support for defining "mappings" if your models don't match up with what CanvasSync expects.
|
data/lib/canvas_sync.rb
CHANGED
|
@@ -26,9 +26,14 @@ module CanvasSync
|
|
|
26
26
|
# must be one of SUPPORTED_MODELS
|
|
27
27
|
# @param term_scope [Symbol, nil] An optional symbol representing a scope that exists on the Term model.
|
|
28
28
|
# The provisioning report will be run for each of the terms contained in that scope.
|
|
29
|
-
|
|
29
|
+
# @param legacy_support [Boolean, false] This enables legacy_support, where rows are not bulk inserted.
|
|
30
|
+
# For this to work your models must have a `create_or_udpate_from_csv` class method that takes a row
|
|
31
|
+
# and inserts it into the database.
|
|
32
|
+
# @param account_id [Integer, nil] This optional parameter can be used if your Term creation and
|
|
33
|
+
# canvas_sync_client methods require an account ID.
|
|
34
|
+
def self.provisioning_sync(models, term_scope: nil, legacy_support: false, account_id: nil)
|
|
30
35
|
validate_models!(models)
|
|
31
|
-
invoke_next(default_provisioning_report_chain(models, term_scope))
|
|
36
|
+
invoke_next(default_provisioning_report_chain(models, term_scope, legacy_support, account_id))
|
|
32
37
|
end
|
|
33
38
|
|
|
34
39
|
# Runs a chain of ordered jobs
|
|
@@ -62,10 +67,16 @@ module CanvasSync
|
|
|
62
67
|
#
|
|
63
68
|
# @param models [Array<String>]
|
|
64
69
|
# @param term_scope [String]
|
|
70
|
+
# @param legacy_support [Boolean, false] This enables legacy_support, where rows are not bulk inserted.
|
|
71
|
+
# For this to work your models must have a `create_or_udpate_from_csv` class method that takes a row
|
|
72
|
+
# and inserts it into the database.
|
|
73
|
+
# @param account_id [Integer, nil] This optional parameter can be used if your Term creation and
|
|
74
|
+
# canvas_sync_client methods require an account ID.
|
|
65
75
|
# @return [Hash]
|
|
66
|
-
def self.default_provisioning_report_chain(models, term_scope=nil)
|
|
76
|
+
def self.default_provisioning_report_chain(models, term_scope=nil, legacy_support=false, account_id=nil)
|
|
67
77
|
term_scope = term_scope.to_s if term_scope
|
|
68
78
|
|
|
79
|
+
|
|
69
80
|
# Always sync Terms first
|
|
70
81
|
jobs = [{ job: CanvasSync::Jobs::SyncTermsJob.to_s, options: {} }]
|
|
71
82
|
|
|
@@ -77,7 +88,22 @@ module CanvasSync
|
|
|
77
88
|
|
|
78
89
|
jobs.push({ job: CanvasSync::Jobs::SyncProvisioningReportJob.to_s, options: { term_scope: term_scope, models: models } })
|
|
79
90
|
|
|
80
|
-
|
|
91
|
+
global_options = { legacy_support: legacy_support }
|
|
92
|
+
global_options[:account_id] = account_id if account_id.present?
|
|
93
|
+
|
|
94
|
+
{ jobs: jobs, global_options: global_options }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Calls the canvas_sync_client in your app. If you have specified an account
|
|
98
|
+
# ID when starting the job it will pass the account ID to your canvas_sync_client method.
|
|
99
|
+
#
|
|
100
|
+
# @param options [Hash]
|
|
101
|
+
def self.get_canvas_sync_client(options)
|
|
102
|
+
if options[:account_id]
|
|
103
|
+
canvas_sync_client(options[:account_id])
|
|
104
|
+
else
|
|
105
|
+
canvas_sync_client
|
|
106
|
+
end
|
|
81
107
|
end
|
|
82
108
|
|
|
83
109
|
private
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module CanvasSync
|
|
2
|
+
module Importers
|
|
3
|
+
class LegacyImporter
|
|
4
|
+
# Does a legacy style import, row by row. This will be invoked if you passed
|
|
5
|
+
# "legacy_support: true" when starting the sync. For this to work your models
|
|
6
|
+
# must have a `create_or_update_from_csv` class method defined.
|
|
7
|
+
#
|
|
8
|
+
# @param report_file_path [String]
|
|
9
|
+
# @param klass [Object]
|
|
10
|
+
def self.import(report_file_path, klass, account_id)
|
|
11
|
+
CSV.foreach(report_file_path, headers: true, header_converters: :symbol) do |row|
|
|
12
|
+
klass.create_or_update_from_csv(row, account_id)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -11,7 +11,7 @@ module CanvasSync
|
|
|
11
11
|
# @param options [Hash] hash of options that will be passed to the job processor
|
|
12
12
|
# @return [nil]
|
|
13
13
|
def perform(job_chain, report_name, report_id, processor, options)
|
|
14
|
-
report_status =
|
|
14
|
+
report_status = CanvasSync.get_canvas_sync_client(job_chain[:global_options]).report_status('self', report_name, report_id)
|
|
15
15
|
|
|
16
16
|
case report_status['status'].downcase
|
|
17
17
|
when 'complete'
|
|
@@ -14,6 +14,10 @@ module CanvasSync
|
|
|
14
14
|
# @return [nil]
|
|
15
15
|
def perform(job_chain, report_name, report_url, processor, options)
|
|
16
16
|
download(report_name, report_url) do |file_path|
|
|
17
|
+
options = options.merge({
|
|
18
|
+
legacy_support: job_chain[:global_options][:legacy_support],
|
|
19
|
+
account_id: job_chain[:global_options][:account_id]
|
|
20
|
+
})
|
|
17
21
|
processor.constantize.process(file_path, options)
|
|
18
22
|
end
|
|
19
23
|
|
|
@@ -9,7 +9,7 @@ module CanvasSync
|
|
|
9
9
|
# @param options [Hash] hash of options that will be passed to the job processor
|
|
10
10
|
# @return [nil]
|
|
11
11
|
def perform(job_chain, report_name, report_params, processor, options)
|
|
12
|
-
report =
|
|
12
|
+
report = CanvasSync.get_canvas_sync_client(job_chain[:global_options]).start_report('self', report_name, report_params)
|
|
13
13
|
|
|
14
14
|
CanvasSync::Jobs::ReportChecker.set(wait: report_checker_wait_time).perform_later(
|
|
15
15
|
job_chain,
|
|
@@ -12,7 +12,7 @@ module CanvasSync
|
|
|
12
12
|
# Deep copy the job_chain so each report gets the correct term id passed into
|
|
13
13
|
# its options with no side effects
|
|
14
14
|
duped_job_chain = Marshal.load(Marshal.dump(job_chain))
|
|
15
|
-
duped_job_chain[:
|
|
15
|
+
duped_job_chain[:global_options][:canvas_term_id] = term.canvas_term_id
|
|
16
16
|
start_report(report_params(options, term.canvas_term_id), duped_job_chain, options)
|
|
17
17
|
end
|
|
18
18
|
else
|
|
@@ -8,8 +8,12 @@ module CanvasSync
|
|
|
8
8
|
# @param job_chain [Hash]
|
|
9
9
|
# @param options [Hash]
|
|
10
10
|
def perform(job_chain, options)
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
CanvasSync.get_canvas_sync_client(job_chain[:global_options]).terms('self').all_pages!.each do |term_params|
|
|
12
|
+
if(job_chain[:global_options][:account_id])
|
|
13
|
+
Term.create_or_update(term_params, job_chain[:global_options][:account_id])
|
|
14
|
+
else
|
|
15
|
+
Term.create_or_update(term_params)
|
|
16
|
+
end
|
|
13
17
|
end
|
|
14
18
|
|
|
15
19
|
CanvasSync.invoke_next(job_chain)
|
|
@@ -64,20 +64,26 @@ module CanvasSync
|
|
|
64
64
|
# @param report_file_path [String]
|
|
65
65
|
# @param options [Hash]
|
|
66
66
|
def self.process(report_file_path, options)
|
|
67
|
+
self.new(report_file_path, options)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def initialize(report_file_path, options)
|
|
71
|
+
@options = options
|
|
72
|
+
|
|
67
73
|
if options[:models].length == 1
|
|
68
|
-
|
|
74
|
+
run_import(options[:models][0], report_file_path)
|
|
69
75
|
else
|
|
70
76
|
unzipped_file_path = extract(report_file_path)
|
|
71
77
|
Dir[unzipped_file_path + "/*.csv"].each do |file_path|
|
|
72
78
|
model_name = file_path.split("/").last.split(".").first
|
|
73
|
-
|
|
79
|
+
run_import(model_name, file_path)
|
|
74
80
|
end
|
|
75
81
|
end
|
|
76
82
|
end
|
|
77
83
|
|
|
78
84
|
private
|
|
79
85
|
|
|
80
|
-
def
|
|
86
|
+
def extract(file_path)
|
|
81
87
|
unzipped_file_path = "#{file_path}_unzipped"
|
|
82
88
|
|
|
83
89
|
Zip::File.open(file_path) do |zip_file|
|
|
@@ -91,30 +97,50 @@ module CanvasSync
|
|
|
91
97
|
unzipped_file_path
|
|
92
98
|
end
|
|
93
99
|
|
|
94
|
-
def
|
|
100
|
+
def run_import(model_name, report_file_path)
|
|
101
|
+
if @options[:legacy_support]
|
|
102
|
+
CanvasSync::Importers::LegacyImporter.import(report_file_path, model_name.singularize.capitalize.constantize, @options[:account_id])
|
|
103
|
+
else
|
|
104
|
+
send("bulk_process_#{model_name}", report_file_path)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def bulk_process_users(report_file_path)
|
|
95
109
|
CanvasSync::Importers::BulkImporter.import(
|
|
96
110
|
report_file_path,
|
|
97
111
|
USERS_CSV_MAPPING,
|
|
98
112
|
User,
|
|
99
113
|
:canvas_user_id,
|
|
100
|
-
true
|
|
114
|
+
true
|
|
115
|
+
)
|
|
101
116
|
end
|
|
102
117
|
|
|
103
|
-
def
|
|
104
|
-
CanvasSync::Importers::BulkImporter.import(
|
|
118
|
+
def bulk_process_courses(report_file_path)
|
|
119
|
+
CanvasSync::Importers::BulkImporter.import(
|
|
120
|
+
report_file_path,
|
|
121
|
+
COURSES_CSV_MAPPING,
|
|
122
|
+
Course,
|
|
123
|
+
:canvas_course_id
|
|
124
|
+
)
|
|
105
125
|
end
|
|
106
126
|
|
|
107
|
-
def
|
|
127
|
+
def bulk_process_enrollments(report_file_path)
|
|
108
128
|
CanvasSync::Importers::BulkImporter.import(
|
|
109
129
|
report_file_path,
|
|
110
130
|
ENROLLMENTS_CSV_MAPPING,
|
|
111
131
|
Enrollment,
|
|
112
132
|
:canvas_enrollment_id,
|
|
113
|
-
true
|
|
133
|
+
true
|
|
134
|
+
)
|
|
114
135
|
end
|
|
115
136
|
|
|
116
|
-
def
|
|
117
|
-
CanvasSync::Importers::BulkImporter.import(
|
|
137
|
+
def bulk_process_sections(report_file_path)
|
|
138
|
+
CanvasSync::Importers::BulkImporter.import(
|
|
139
|
+
report_file_path,
|
|
140
|
+
SECTIONS_CSV_MAPPING,
|
|
141
|
+
Section,
|
|
142
|
+
:canvas_section_id
|
|
143
|
+
)
|
|
118
144
|
end
|
|
119
145
|
end
|
|
120
146
|
end
|
data/lib/canvas_sync/version.rb
CHANGED
|
@@ -33,7 +33,7 @@ RSpec.describe CanvasSync do
|
|
|
33
33
|
{ job: CanvasSync::Jobs::SyncUsersJob.to_s, options: {} },
|
|
34
34
|
{ job: CanvasSync::Jobs::SyncProvisioningReportJob.to_s, options: { term_scope: 'active', models: ['courses'] } }
|
|
35
35
|
],
|
|
36
|
-
|
|
36
|
+
global_options: { legacy_support: false }
|
|
37
37
|
})
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -46,7 +46,7 @@ RSpec.describe CanvasSync do
|
|
|
46
46
|
{ job: CanvasSync::Jobs::SyncTermsJob.to_s, options: {} },
|
|
47
47
|
{ job: CanvasSync::Jobs::SyncProvisioningReportJob.to_s, options: { term_scope: nil, models: ['users', 'courses'] } }
|
|
48
48
|
],
|
|
49
|
-
|
|
49
|
+
global_options: { legacy_support: false }
|
|
50
50
|
})
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -5,11 +5,12 @@ RSpec.describe CanvasSync::Jobs::ReportChecker do
|
|
|
5
5
|
let(:report_id) { 1 }
|
|
6
6
|
let(:report_name) { 'provisioning_csv' }
|
|
7
7
|
let(:processor) { 'FakeProcessor' }
|
|
8
|
+
let(:job_chain) { { jobs: [], global_options: {} } }
|
|
8
9
|
|
|
9
10
|
describe '#perform' do
|
|
10
11
|
def start_job
|
|
11
12
|
CanvasSync::Jobs::ReportChecker.perform_now(
|
|
12
|
-
|
|
13
|
+
job_chain,
|
|
13
14
|
'provisioning_csv',
|
|
14
15
|
report_id,
|
|
15
16
|
processor,
|
|
@@ -24,7 +25,7 @@ RSpec.describe CanvasSync::Jobs::ReportChecker do
|
|
|
24
25
|
.and_return({ 'status' => 'complete', 'attachment' => { 'url' => 'blah' } })
|
|
25
26
|
|
|
26
27
|
expect(CanvasSync::Jobs::ReportProcessorJob).to receive(:perform_later)
|
|
27
|
-
.with(
|
|
28
|
+
.with(job_chain, report_name, 'blah', processor, {})
|
|
28
29
|
|
|
29
30
|
start_job
|
|
30
31
|
end
|
|
@@ -6,7 +6,7 @@ RSpec.describe CanvasSync::Jobs::ReportProcessorJob do
|
|
|
6
6
|
let(:report_name) { 'provisioning_csv' }
|
|
7
7
|
let(:report_url) { 'https://test.instructure.com/sample_report_download' }
|
|
8
8
|
let(:processor) { FakeProcessor.to_s }
|
|
9
|
-
let(:job_chain) { [
|
|
9
|
+
let(:job_chain) { { jobs: [], global_options: {} } }
|
|
10
10
|
|
|
11
11
|
describe '#perform' do
|
|
12
12
|
it 'downloads the report to a file and then calls the process method on the processor, and then invokes the next job' do
|
|
@@ -14,7 +14,7 @@ RSpec.describe CanvasSync::Jobs::ReportStarter do
|
|
|
14
14
|
expect(CanvasSync::Jobs::ReportChecker).to receive(:set).and_call_original
|
|
15
15
|
|
|
16
16
|
CanvasSync::Jobs::ReportStarter.perform_now(
|
|
17
|
-
[],
|
|
17
|
+
{ jobs: [], global_options: {} },
|
|
18
18
|
report_name,
|
|
19
19
|
report_params,
|
|
20
20
|
processor,
|
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
RSpec.describe CanvasSync::Jobs::SyncProvisioningReportJob do
|
|
4
4
|
describe '#perform' do
|
|
5
|
-
let(:job_chain) { {jobs: [],
|
|
5
|
+
let(:job_chain) { {jobs: [], global_options: {}} }
|
|
6
6
|
|
|
7
7
|
context 'a term scope is specified' do
|
|
8
8
|
let!(:active_term_1) { FactoryGirl.create(:term) }
|
|
@@ -11,7 +11,7 @@ RSpec.describe CanvasSync::Jobs::SyncProvisioningReportJob do
|
|
|
11
11
|
|
|
12
12
|
it 'enqueues a ReportStarter for a provisioning report for the specified models for each term' do
|
|
13
13
|
expected_job_chain = Marshal.load(Marshal.dump(job_chain))
|
|
14
|
-
expected_job_chain[:
|
|
14
|
+
expected_job_chain[:global_options][:canvas_term_id] = active_term_1.canvas_term_id
|
|
15
15
|
|
|
16
16
|
expect(CanvasSync::Jobs::ReportStarter).to receive(:perform_later)
|
|
17
17
|
.with(
|
|
@@ -28,7 +28,7 @@ RSpec.describe CanvasSync::Jobs::SyncProvisioningReportJob do
|
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
expected_job_chain_2 = Marshal.load(Marshal.dump(job_chain))
|
|
31
|
-
expected_job_chain_2[:
|
|
31
|
+
expected_job_chain_2[:global_options][:canvas_term_id] = active_term_2.canvas_term_id
|
|
32
32
|
|
|
33
33
|
expect(CanvasSync::Jobs::ReportStarter).to receive(:perform_later)
|
|
34
34
|
.with(
|
|
@@ -3,12 +3,13 @@ require 'spec_helper'
|
|
|
3
3
|
RSpec.describe CanvasSync::Jobs::SyncTermsJob do
|
|
4
4
|
describe '#perform' do
|
|
5
5
|
let(:term_params) { open_canvas_fixture('terms')['enrollment_terms'] }
|
|
6
|
+
let(:job_chain) { { jobs: [], global_options: {}} }
|
|
6
7
|
|
|
7
8
|
it 'retrieves all terms from the Canvas API and then invokes the next job' do
|
|
8
|
-
expect(CanvasSync).to receive(:invoke_next).with(
|
|
9
|
+
expect(CanvasSync).to receive(:invoke_next).with(job_chain)
|
|
9
10
|
|
|
10
11
|
expect {
|
|
11
|
-
CanvasSync::Jobs::SyncTermsJob.perform_now(
|
|
12
|
+
CanvasSync::Jobs::SyncTermsJob.perform_now(job_chain, {})
|
|
12
13
|
}.to change { Term.count }.by(term_params.length)
|
|
13
14
|
end
|
|
14
15
|
end
|
|
@@ -9,7 +9,7 @@ RSpec.describe CanvasSync::Jobs::SyncUsersJob do
|
|
|
9
9
|
|
|
10
10
|
expect(CanvasSync::Jobs::ReportChecker).to receive(:set).and_call_original
|
|
11
11
|
|
|
12
|
-
CanvasSync::Jobs::SyncUsersJob.perform_now([], {})
|
|
12
|
+
CanvasSync::Jobs::SyncUsersJob.perform_now({ jobs: [], global_options: {}}, {})
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -37,5 +37,12 @@ RSpec.describe CanvasSync::Processors::ProvisioningReportProcessor do
|
|
|
37
37
|
expect(Course.count).to eq(course_count + 2)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
context 'legacy_support is true' do
|
|
42
|
+
it 'uses the LegacyImporter' do
|
|
43
|
+
expect(User).to receive(:create_or_update_from_csv).at_least(:once)
|
|
44
|
+
subject.process('spec/support/fixtures/reports/users.csv', { models: ['users'], legacy_support: true })
|
|
45
|
+
end
|
|
46
|
+
end
|
|
40
47
|
end
|
|
41
48
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: canvas_sync
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nate Collings
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -226,14 +226,14 @@ dependencies:
|
|
|
226
226
|
requirements:
|
|
227
227
|
- - ">="
|
|
228
228
|
- !ruby/object:Gem::Version
|
|
229
|
-
version:
|
|
229
|
+
version: '4'
|
|
230
230
|
type: :runtime
|
|
231
231
|
prerelease: false
|
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
|
233
233
|
requirements:
|
|
234
234
|
- - ">="
|
|
235
235
|
- !ruby/object:Gem::Version
|
|
236
|
-
version:
|
|
236
|
+
version: '4'
|
|
237
237
|
- !ruby/object:Gem::Dependency
|
|
238
238
|
name: bearcat
|
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -301,6 +301,7 @@ files:
|
|
|
301
301
|
- lib/canvas_sync/generators/templates/term.rb
|
|
302
302
|
- lib/canvas_sync/generators/templates/user.rb
|
|
303
303
|
- lib/canvas_sync/importers/bulk_importer.rb
|
|
304
|
+
- lib/canvas_sync/importers/legacy_importer.rb
|
|
304
305
|
- lib/canvas_sync/job.rb
|
|
305
306
|
- lib/canvas_sync/jobs/report_checker.rb
|
|
306
307
|
- lib/canvas_sync/jobs/report_processor_job.rb
|
|
@@ -345,16 +346,12 @@ files:
|
|
|
345
346
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
|
346
347
|
- spec/dummy/config/routes.rb
|
|
347
348
|
- spec/dummy/config/secrets.yml
|
|
348
|
-
- spec/dummy/db/development.sqlite3
|
|
349
349
|
- spec/dummy/db/migrate/20170905192509_create_enrollments.rb
|
|
350
350
|
- spec/dummy/db/migrate/20170906193506_create_terms.rb
|
|
351
351
|
- spec/dummy/db/migrate/20170906203438_create_sections.rb
|
|
352
352
|
- spec/dummy/db/migrate/20170914181345_create_courses.rb
|
|
353
353
|
- spec/dummy/db/migrate/20170918221413_create_users.rb
|
|
354
354
|
- spec/dummy/db/schema.rb
|
|
355
|
-
- spec/dummy/db/test.sqlite3
|
|
356
|
-
- spec/dummy/log/development.log
|
|
357
|
-
- spec/dummy/log/test.log
|
|
358
355
|
- spec/factories/course_factory.rb
|
|
359
356
|
- spec/factories/enrollment_factory.rb
|
|
360
357
|
- spec/factories/section_factory.rb
|
|
@@ -366,8 +363,6 @@ files:
|
|
|
366
363
|
- spec/support/fixtures/reports/courses.csv
|
|
367
364
|
- spec/support/fixtures/reports/enrollments.csv
|
|
368
365
|
- spec/support/fixtures/reports/provisioning_csv
|
|
369
|
-
- spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv
|
|
370
|
-
- spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv
|
|
371
366
|
- spec/support/fixtures/reports/sections.csv
|
|
372
367
|
- spec/support/fixtures/reports/users.csv
|
|
373
368
|
homepage: https://instructure.com
|
|
@@ -429,16 +424,12 @@ test_files:
|
|
|
429
424
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
|
430
425
|
- spec/dummy/config/routes.rb
|
|
431
426
|
- spec/dummy/config/secrets.yml
|
|
432
|
-
- spec/dummy/db/development.sqlite3
|
|
433
427
|
- spec/dummy/db/migrate/20170905192509_create_enrollments.rb
|
|
434
428
|
- spec/dummy/db/migrate/20170906193506_create_terms.rb
|
|
435
429
|
- spec/dummy/db/migrate/20170906203438_create_sections.rb
|
|
436
430
|
- spec/dummy/db/migrate/20170914181345_create_courses.rb
|
|
437
431
|
- spec/dummy/db/migrate/20170918221413_create_users.rb
|
|
438
432
|
- spec/dummy/db/schema.rb
|
|
439
|
-
- spec/dummy/db/test.sqlite3
|
|
440
|
-
- spec/dummy/log/development.log
|
|
441
|
-
- spec/dummy/log/test.log
|
|
442
433
|
- spec/factories/course_factory.rb
|
|
443
434
|
- spec/factories/enrollment_factory.rb
|
|
444
435
|
- spec/factories/section_factory.rb
|
|
@@ -450,7 +441,5 @@ test_files:
|
|
|
450
441
|
- spec/support/fixtures/reports/courses.csv
|
|
451
442
|
- spec/support/fixtures/reports/enrollments.csv
|
|
452
443
|
- spec/support/fixtures/reports/provisioning_csv
|
|
453
|
-
- spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv
|
|
454
|
-
- spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv
|
|
455
444
|
- spec/support/fixtures/reports/sections.csv
|
|
456
445
|
- spec/support/fixtures/reports/users.csv
|