strongmind-platform-sdk 3.26.17 → 3.26.19
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/lib/platform_sdk/canvas_api/client.rb +52 -0
- data/lib/platform_sdk/spec_support/shared_examples/data_pipelineable_examples.rb +0 -1
- data/lib/platform_sdk/spec_support/shared_examples/data_pipelineable_examples_without_callbacks.rb +125 -0
- data/lib/platform_sdk/spec_support.rb +1 -0
- data/lib/platform_sdk/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a5f98f47523575eb0e450bc04688676977448114a7d59abfb110f4a8f2d5a11
|
|
4
|
+
data.tar.gz: 114beae04bc91739a562f527680458ec0930bb6cbf272e7c2f84ec95517fa86d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4a35a64ae9f49f12c555f2bcbd918ebcdf03630a2b02eafd6c8c65c809283d00c2b9988de202cbef54bc0fa139a4894f6f9af8b8642fb832c50849436c2bb90
|
|
7
|
+
data.tar.gz: 2ca5b0723281e9a84a8135baca5a8fe4f8549a1075731953cf9e8138c00f6719082f8c6509564b9c8c807f5fffcc312fbeb6775e8e891b2640153c3dd06ee6e3
|
|
@@ -471,6 +471,58 @@ module PlatformSdk
|
|
|
471
471
|
end
|
|
472
472
|
end
|
|
473
473
|
|
|
474
|
+
# @param course_id [Integer]
|
|
475
|
+
# @param body [Hash]
|
|
476
|
+
# @option body [String] 'module[name]' The name of the module
|
|
477
|
+
# @option body [Integer] 'module[position]' The position of this module in the course (1-based)
|
|
478
|
+
# @return [Hash]
|
|
479
|
+
def create_module(course_id:, body:)
|
|
480
|
+
uri = "/api/v1/courses/#{course_id}/modules"
|
|
481
|
+
response = @connection.post(uri) do |req|
|
|
482
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
483
|
+
req.body = body
|
|
484
|
+
end
|
|
485
|
+
handle_rate_limiting response
|
|
486
|
+
result = MultiJson.load response.body, symbolize_keys: true
|
|
487
|
+
if success?(response.status)
|
|
488
|
+
result
|
|
489
|
+
else
|
|
490
|
+
error_messages = String.new
|
|
491
|
+
result[:errors]&.each do |error|
|
|
492
|
+
error_messages << "#{error[:message]} "
|
|
493
|
+
end
|
|
494
|
+
raise "Error creating module: #{error_messages}"
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# @param course_id [Integer]
|
|
499
|
+
# @param module_id [Integer]
|
|
500
|
+
# @param body [Hash]
|
|
501
|
+
# @option body [String] 'module[name]' The name of the module
|
|
502
|
+
# @option body [Boolean] 'module[published]' Whether the module is published
|
|
503
|
+
# @option body [String] 'module[unlock_at]' When to unlock the module
|
|
504
|
+
# @option body [Boolean] 'module[require_sequential_progress]' Require sequential progress
|
|
505
|
+
# @option body [Boolean] 'module[publish_final_grade]' Publish final grade
|
|
506
|
+
# @return [Hash]
|
|
507
|
+
def update_module(course_id:, module_id:, body:)
|
|
508
|
+
uri = "/api/v1/courses/#{course_id}/modules/#{module_id}"
|
|
509
|
+
response = @connection.put(uri) do |req|
|
|
510
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
511
|
+
req.body = body
|
|
512
|
+
end
|
|
513
|
+
handle_rate_limiting response
|
|
514
|
+
result = MultiJson.load response.body, symbolize_keys: true
|
|
515
|
+
if success?(response.status)
|
|
516
|
+
result
|
|
517
|
+
else
|
|
518
|
+
error_messages = String.new
|
|
519
|
+
result[:errors]&.each do |error|
|
|
520
|
+
error_messages << "#{error[:message]} "
|
|
521
|
+
end
|
|
522
|
+
raise "Error updating module: #{error_messages}"
|
|
523
|
+
end
|
|
524
|
+
end
|
|
525
|
+
|
|
474
526
|
# @param course_id [Integer]
|
|
475
527
|
# @param module_id [Integer]
|
|
476
528
|
# @param body [Hash]
|
data/lib/platform_sdk/spec_support/shared_examples/data_pipelineable_examples_without_callbacks.rb
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
module PlatformSdk
|
|
2
|
+
module SpecSupport
|
|
3
|
+
RSpec.shared_examples 'DataPipelineableWithoutCallbacks' do |params = {}|
|
|
4
|
+
let(:shared_params) { params }
|
|
5
|
+
let(:frozen_time) { Time.zone.parse('2024-06-09 04:20:00') }
|
|
6
|
+
|
|
7
|
+
# Create a lightweight test record that skips database
|
|
8
|
+
let(:record) do
|
|
9
|
+
rec = described_class.new
|
|
10
|
+
allow(rec).to receive(:save!).and_return(true)
|
|
11
|
+
allow(rec).to receive(:update!).and_return(true)
|
|
12
|
+
allow(rec).to receive(:destroy).and_return(true)
|
|
13
|
+
allow(rec).to receive(:id).and_return(123)
|
|
14
|
+
rec
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
before do
|
|
18
|
+
# Mock job execution
|
|
19
|
+
allow(PlatformSdk::Jobs::SendNounToPipelineJob).to receive(:perform_later)
|
|
20
|
+
|
|
21
|
+
# Mock time
|
|
22
|
+
allow(Time).to receive(:current).and_return(frozen_time)
|
|
23
|
+
|
|
24
|
+
# Default to test environment
|
|
25
|
+
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('test'))
|
|
26
|
+
|
|
27
|
+
# Skip actual database operations
|
|
28
|
+
allow(described_class).to receive(:create!).and_return(record)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context 'create' do
|
|
32
|
+
it 'posts a copy of our data to the data pipeline' do
|
|
33
|
+
record.send_pipeline_create
|
|
34
|
+
|
|
35
|
+
expect(PlatformSdk::Jobs::SendNounToPipelineJob).to have_received(:perform_later).once.with(
|
|
36
|
+
record.pipeline_payload('created'),
|
|
37
|
+
record.one_roster_pipeline_payload
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context 'destroy' do
|
|
43
|
+
it 'posts a copy of our data to the data pipeline' do
|
|
44
|
+
record.send_pipeline_destroy
|
|
45
|
+
|
|
46
|
+
expect(PlatformSdk::Jobs::SendNounToPipelineJob).to have_received(:perform_later).once.with(
|
|
47
|
+
record.pipeline_payload('destroyed'),
|
|
48
|
+
record.one_roster_pipeline_payload(deleted: true)
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'does not post to the data pipeline if in development environment' do
|
|
53
|
+
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
|
|
54
|
+
|
|
55
|
+
record.send_pipeline_destroy
|
|
56
|
+
|
|
57
|
+
expect(PlatformSdk::Jobs::SendNounToPipelineJob).not_to have_received(:perform_later)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context 'update' do
|
|
62
|
+
context 'after an update' do
|
|
63
|
+
it 'posts a copy of our data to the data pipeline' do
|
|
64
|
+
record.send_pipeline_update
|
|
65
|
+
|
|
66
|
+
expect(PlatformSdk::Jobs::SendNounToPipelineJob).to have_received(:perform_later).once.with(
|
|
67
|
+
record.pipeline_payload('modified'),
|
|
68
|
+
record.one_roster_pipeline_payload
|
|
69
|
+
)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'does not post to the data pipeline if in development environment' do
|
|
73
|
+
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
|
|
74
|
+
|
|
75
|
+
record.send_pipeline_update
|
|
76
|
+
|
|
77
|
+
expect(PlatformSdk::Jobs::SendNounToPipelineJob).not_to have_received(:perform_later)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context 'after an update that does not change data' do
|
|
82
|
+
it 'does not call send_pipeline_update when saved_changes? is false' do
|
|
83
|
+
# The callback condition `if: -> { saved_changes? }` prevents the method from being called
|
|
84
|
+
allow(record).to receive(:saved_changes?).and_return(false)
|
|
85
|
+
|
|
86
|
+
# This test verifies the callback logic - when there are no changes,
|
|
87
|
+
# the update callback should not trigger send_pipeline_update
|
|
88
|
+
expect(record).not_to receive(:send_pipeline_update)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe '#pipeline_payload' do
|
|
94
|
+
let(:test_attributes) { { 'id' => 123, 'name' => 'Test Name', 'created_at' => frozen_time, 'updated_at' => frozen_time } }
|
|
95
|
+
|
|
96
|
+
before do
|
|
97
|
+
allow(record).to receive(:attributes).and_return(test_attributes)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
%w[created modified destroyed].each do |action|
|
|
101
|
+
context "when action is #{action}" do
|
|
102
|
+
it 'returns the expected payload structure' do
|
|
103
|
+
payload = record.pipeline_payload(action)
|
|
104
|
+
|
|
105
|
+
expect(payload).to include(
|
|
106
|
+
:noun,
|
|
107
|
+
:identifiers,
|
|
108
|
+
:meta,
|
|
109
|
+
:data,
|
|
110
|
+
:envelope_version,
|
|
111
|
+
:message_timestamp
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
expect(payload[:envelope_version]).to eq('1.0.0')
|
|
115
|
+
expect(payload[:message_timestamp]).to eq(frozen_time.utc.iso8601)
|
|
116
|
+
expect(payload[:identifiers]).to eq(id: 123)
|
|
117
|
+
expect(payload[:data][:action]).to eq(action)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rspec/core'
|
|
4
4
|
require 'platform_sdk/spec_support/shared_examples/data_pipelineable_examples'
|
|
5
|
+
require 'platform_sdk/spec_support/shared_examples/data_pipelineable_examples_without_callbacks'
|
|
5
6
|
require 'platform_sdk/spec_support/shared_examples/one_roster_data_pipelineable_examples'
|
|
6
7
|
|
|
7
8
|
module PlatformSdk
|
data/lib/platform_sdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strongmind-platform-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.26.
|
|
4
|
+
version: 3.26.19
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Platform Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -299,6 +299,7 @@ files:
|
|
|
299
299
|
- lib/platform_sdk/sidekiq/ecs_task_protection_middleware.rb
|
|
300
300
|
- lib/platform_sdk/spec_support.rb
|
|
301
301
|
- lib/platform_sdk/spec_support/shared_examples/data_pipelineable_examples.rb
|
|
302
|
+
- lib/platform_sdk/spec_support/shared_examples/data_pipelineable_examples_without_callbacks.rb
|
|
302
303
|
- lib/platform_sdk/spec_support/shared_examples/one_roster_data_pipelineable_examples.rb
|
|
303
304
|
- lib/platform_sdk/version.rb
|
|
304
305
|
- sig/platform_sdk/identity/auth_client.rbs
|