canvas_sync 0.27.12 → 0.27.13
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 465e968a497bd2dc0bbba5d978bc37a42257122f74132e2f9d7a72c4ed7f9082
|
|
4
|
+
data.tar.gz: 113288ee3a4bea44ba48d837f917f111e8e0bb9de2f8e43c0d5e30eb78aa0361
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2afe2d77cc726e26bdce33058d89bfd279f890dd5832c30c33575960387111f309ac15f6f2632406861cb1f3a4e34ce0ff16509612bb987f3e96974ceabc327b
|
|
7
|
+
data.tar.gz: 3c926ea08522792eae8fd6daaafcc343888aed77b55e943d1fca08a8ddf174d01db1fc26ebe786cd613eab18dc0d9d15221a2fe739a5a46d4dda4e626e48f498
|
|
@@ -27,12 +27,15 @@ module CanvasSync
|
|
|
27
27
|
class << self
|
|
28
28
|
def from_context
|
|
29
29
|
report_batch = JobBatches::Batch.current
|
|
30
|
-
base_context = report_batch&.parent&.context
|
|
31
30
|
state = report_batch&.context
|
|
32
|
-
|
|
31
|
+
|
|
32
|
+
# Only a report Batch carries :report_class. Any other Batch in the chain inherits a
|
|
33
|
+
# context from its parents, so check for the key itself rather than asking whether the
|
|
34
|
+
# context is present.
|
|
35
|
+
return nil if state.nil? || state[:report_class].blank?
|
|
33
36
|
|
|
34
37
|
cls = state[:report_class].constantize
|
|
35
|
-
cls.new(state[:report_options],
|
|
38
|
+
cls.new(state[:report_options], report_batch.parent&.context, state)
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
def perform_later(options)
|
data/lib/canvas_sync/version.rb
CHANGED
|
@@ -86,6 +86,30 @@ RSpec.describe CanvasSync::Jobs::ReportSyncTask do
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
describe ".from_context" do
|
|
89
|
+
# Stands in for JobBatches::ContextHash, which reads keys via #[] but routes every other Hash
|
|
90
|
+
# method through #flatten. Flattening loads (and locks down) the whole ancestor chain, so
|
|
91
|
+
# from_context has to stay on #[] - anything else costs the Batch the ability to record its
|
|
92
|
+
# own progress later in the job.
|
|
93
|
+
class FlattenTattlingContext
|
|
94
|
+
attr_reader :flatten_count
|
|
95
|
+
|
|
96
|
+
def initialize(hash)
|
|
97
|
+
@hash = hash.with_indifferent_access
|
|
98
|
+
@flatten_count = 0
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def [](key)
|
|
102
|
+
@hash[key]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def flatten
|
|
106
|
+
@flatten_count += 1
|
|
107
|
+
@hash
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
delegate_missing_to :flatten
|
|
111
|
+
end
|
|
112
|
+
|
|
89
113
|
it "reconstructs task from batch context" do
|
|
90
114
|
stub_batch_context({ canvas_term_id: 1 })
|
|
91
115
|
allow(CanvasSync::JobBatches::Batch.current).to receive(:context)
|
|
@@ -96,6 +120,38 @@ RSpec.describe CanvasSync::Jobs::ReportSyncTask do
|
|
|
96
120
|
expect(task).to be_a(SyncSpecsTask)
|
|
97
121
|
expect(task.options).to eq({ include_all: true })
|
|
98
122
|
end
|
|
123
|
+
|
|
124
|
+
it "returns nil when the context belongs to a non-report Batch" do
|
|
125
|
+
# A Batch elsewhere in the sync chain inherits a context from its parents, so the context is
|
|
126
|
+
# populated - it just has no :report_class.
|
|
127
|
+
stub_batch_context({ canvas_term_id: 1 })
|
|
128
|
+
allow(CanvasSync::JobBatches::Batch.current).to receive(:context)
|
|
129
|
+
.and_return({ sync_batch_id: 42, account_id: 'self' }.with_indifferent_access)
|
|
130
|
+
|
|
131
|
+
expect(CanvasSync::Jobs::ReportSyncTask.from_context).to be_nil
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "returns nil when there is no current Batch" do
|
|
135
|
+
allow(CanvasSync::JobBatches::Batch).to receive(:current).and_return(nil)
|
|
136
|
+
|
|
137
|
+
expect(CanvasSync::Jobs::ReportSyncTask.from_context).to be_nil
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "does not flatten the context, for a report Batch or any other" do
|
|
141
|
+
report_context = FlattenTattlingContext.new(
|
|
142
|
+
report_class: 'SyncSpecsTask', report_options: { include_all: true }
|
|
143
|
+
)
|
|
144
|
+
other_context = FlattenTattlingContext.new(sync_batch_id: 42)
|
|
145
|
+
|
|
146
|
+
[report_context, other_context].each do |context|
|
|
147
|
+
stub_batch_context({ canvas_term_id: 1 })
|
|
148
|
+
allow(CanvasSync::JobBatches::Batch.current).to receive(:context).and_return(context)
|
|
149
|
+
|
|
150
|
+
CanvasSync::Jobs::ReportSyncTask.from_context
|
|
151
|
+
|
|
152
|
+
expect(context.flatten_count).to eq(0)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
99
155
|
end
|
|
100
156
|
|
|
101
157
|
describe described_class::StarterJob do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: canvas_sync
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.27.
|
|
4
|
+
version: 0.27.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Instructure CustomDev
|
|
@@ -413,14 +413,14 @@ dependencies:
|
|
|
413
413
|
requirements:
|
|
414
414
|
- - "~>"
|
|
415
415
|
- !ruby/object:Gem::Version
|
|
416
|
-
version: 0.2.
|
|
416
|
+
version: 0.2.1
|
|
417
417
|
type: :runtime
|
|
418
418
|
prerelease: false
|
|
419
419
|
version_requirements: !ruby/object:Gem::Requirement
|
|
420
420
|
requirements:
|
|
421
421
|
- - "~>"
|
|
422
422
|
- !ruby/object:Gem::Version
|
|
423
|
-
version: 0.2.
|
|
423
|
+
version: 0.2.1
|
|
424
424
|
email:
|
|
425
425
|
- pseng@instructure.com
|
|
426
426
|
executables: []
|