strongmind-platform-sdk 3.19.30 → 3.19.31

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: 99cb6793a19a83ca3efad9083a259ccf17b15fe1d64f3ac4a824964ac5e0bcc1
4
- data.tar.gz: 9765e4699c62939e57e328bebd72316a0eb26102cd3a994f92af7d1ebef253bc
3
+ metadata.gz: 743bf8f25edcef7c341af1d9598f40ac368e986cb93392f84f03b6424543c256
4
+ data.tar.gz: 502e70faec7680e7dcb701c1db36e1d5f9be1327b3c672adb7d517538074ce09
5
5
  SHA512:
6
- metadata.gz: a6490fd12ee607dcad600c9e5098da6561c757a50b9d0ab83be81d112c6d8865d638d8ea32faea512a5bd924b192efa1cdd87a66702acce4e3d8d86275dc9c9f
7
- data.tar.gz: 969ac7c437f12e2d91a8e4c5bdbae2a9dc01f2e15f40177d69110c8214cb574edf6dd1992750e955d44affc8aba0f37dee73907d1091720ca9ce14586e42b4d2
6
+ metadata.gz: a78544838ee3e0f0af687a97c39e200fe931e54199fa338bdaa0fbebbf3893e0caf64f21fa37c39b7b27473eb6a17dd2eedf3a69fd43658485ad6c97bc328f75
7
+ data.tar.gz: 6342ec70213b1416ed58134d5c6049064e58f6780dfc7cffeb5b8c6d3cdf0479e66e07caba4d630a3569baae6e8f71d9a920a3ce70628ba491292494b88db6ae
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strongmind-platform-sdk (3.19.30)
4
+ strongmind-platform-sdk (3.19.31)
5
5
  activesupport (~> 7.1)
6
6
  asset_sync
7
7
  aws-sdk-secretsmanager (~> 1.66)
@@ -103,14 +103,14 @@ GEM
103
103
  unf
104
104
  ast (2.4.2)
105
105
  aws-eventstream (1.3.0)
106
- aws-partitions (1.962.0)
106
+ aws-partitions (1.968.0)
107
107
  aws-sdk-cloudwatch (1.97.0)
108
108
  aws-sdk-core (~> 3, >= 3.201.0)
109
109
  aws-sigv4 (~> 1.5)
110
- aws-sdk-core (3.201.3)
110
+ aws-sdk-core (3.201.5)
111
111
  aws-eventstream (~> 1, >= 1.3.0)
112
112
  aws-partitions (~> 1, >= 1.651.0)
113
- aws-sigv4 (~> 1.8)
113
+ aws-sigv4 (~> 1.9)
114
114
  jmespath (~> 1, >= 1.6.1)
115
115
  aws-sdk-secretsmanager (1.102.0)
116
116
  aws-sdk-core (~> 3, >= 3.201.0)
@@ -192,7 +192,7 @@ GEM
192
192
  method_source (1.1.0)
193
193
  mime-types (3.5.2)
194
194
  mime-types-data (~> 3.2015)
195
- mime-types-data (3.2024.0806)
195
+ mime-types-data (3.2024.0820)
196
196
  mini_mime (1.1.5)
197
197
  mini_portile2 (2.8.7)
198
198
  minitest (5.24.1)
@@ -314,7 +314,7 @@ GEM
314
314
  sentry-ruby (5.18.2)
315
315
  bigdecimal
316
316
  concurrent-ruby (~> 1.0, >= 1.0.2)
317
- sidekiq (7.3.0)
317
+ sidekiq (7.3.1)
318
318
  concurrent-ruby (< 2)
319
319
  connection_pool (>= 2.3.0)
320
320
  logger
@@ -341,9 +341,7 @@ GEM
341
341
  ethon (>= 0.9.0)
342
342
  tzinfo (2.0.6)
343
343
  concurrent-ruby (~> 1.0)
344
- unf (0.1.4)
345
- unf_ext
346
- unf_ext (0.0.9.1)
344
+ unf (0.2.0)
347
345
  unicode-display_width (2.5.0)
348
346
  uri (0.13.0)
349
347
  webmock (3.23.1)
@@ -9,7 +9,7 @@ module PlatformSdk
9
9
  included do
10
10
  after_create :send_pipeline_create
11
11
  before_destroy :send_pipeline_destroy
12
- after_update :send_pipeline_update
12
+ after_update :send_pipeline_update, if: -> { saved_changes? }
13
13
  end
14
14
 
15
15
  def send_pipeline_create
@@ -55,9 +55,9 @@ module PlatformSdk
55
55
 
56
56
  def pipeline_data(action)
57
57
  attributes.symbolize_keys
58
- .merge(pipeline_additional_attributes)
59
- .except(*pipeline_excluded_attributes)
60
- .merge(action:)
58
+ .merge(pipeline_additional_attributes)
59
+ .except(*pipeline_excluded_attributes)
60
+ .merge(action:)
61
61
  end
62
62
 
63
63
  def pipeline_additional_attributes
@@ -1,6 +1,7 @@
1
1
  module PlatformSdk
2
2
  module SpecSupport
3
- RSpec.shared_examples "DataPipelineable" do
3
+ RSpec.shared_examples 'DataPipelineable' do |params = {}|
4
+ let(:shared_params) { params }
4
5
  let(:record) { build(described_class.to_s.underscore.to_sym) }
5
6
  let(:data_pipeline_client) { double(PlatformSdk::DataPipeline::Client) }
6
7
 
@@ -12,41 +13,76 @@ module PlatformSdk
12
13
 
13
14
  after { Timecop.return }
14
15
 
15
- context 'after_create callbacks' do
16
- before { allow(record).to receive(:send_pipeline_create) }
16
+ context 'create' do
17
17
 
18
- it "defines an after_create callback" do
18
+ it 'posts a copy of our data to the data pipeline' do
19
19
  record.save!
20
- expect(record).to have_received(:send_pipeline_create)
20
+ expect(data_pipeline_client).to have_received(:post).once.with(hash_including(
21
+ noun: described_class.pipeline_noun,
22
+ data: record.pipeline_data('created'),
23
+ meta: described_class.pipeline_meta,
24
+ envelope_version: '1.0.0',
25
+ message_timestamp: Time.current.utc.iso8601,
26
+ identifiers: { id: record.id },
27
+ ))
21
28
  end
22
29
  end
23
30
 
24
- context 'before_destroy callbacks' do
25
- before do
26
- allow(record).to receive(:send_pipeline_create)
27
- allow(record).to receive(:send_pipeline_destroy)
28
- end
31
+ context 'destroy' do
29
32
 
30
- it "defines an after_destroy callback" do
33
+ it 'posts a copy of our data to the data pipeline' do
31
34
  record.save!
32
35
  record.destroy
33
36
 
34
- expect(record).to have_received(:send_pipeline_create)
35
- expect(record).to have_received(:send_pipeline_destroy)
37
+ expect(data_pipeline_client).to have_received(:post).once.with(hash_including(
38
+ noun: described_class.pipeline_noun,
39
+ data: record.pipeline_data('destroyed'),
40
+ meta: described_class.pipeline_meta,
41
+ envelope_version: '1.0.0',
42
+ message_timestamp: Time.current.utc.iso8601,
43
+ identifiers: { id: record.id }
44
+ ))
36
45
  end
37
46
  end
38
47
 
39
- context 'after_update callbacks' do
48
+ context 'update' do
40
49
  before do
41
- allow(record).to receive(:send_pipeline_update)
42
50
  record.save!
43
51
  end
44
52
 
45
- it "defines an after_update callback" do
46
- column = column_to_update(record)
47
- unless column.nil?
53
+ context 'after an update' do
54
+ it 'posts a copy of our data to the data pipeline' do
55
+ column = column_to_update(record)
56
+ unless column.nil?
57
+ update_record(record, column)
58
+ expect(data_pipeline_client).to have_received(:post).once.with(hash_including(
59
+ noun: described_class.pipeline_noun,
60
+ data: record.pipeline_data('modified'),
61
+ meta: described_class.pipeline_meta,
62
+ envelope_version: '1.0.0',
63
+ message_timestamp: Time.current.utc.iso8601,
64
+ identifiers: { id: record.id },
65
+ ))
66
+ end
67
+ end
68
+ end
69
+
70
+ context 'after an update that does not change data' do
71
+ let(:action) { 'modified' }
72
+
73
+ it 'does not post to the data pipeline' do
74
+ record.save!
75
+ column = column_to_update(record)
48
76
  update_record(record, column)
49
- expect(record).to have_received(:send_pipeline_update)
77
+ record.save!
78
+ expect(data_pipeline_client).to have_received(:post).once.with(hash_including(
79
+ noun: described_class.pipeline_noun,
80
+ data: record.pipeline_data('modified'),
81
+ meta: described_class.pipeline_meta,
82
+ envelope_version: '1.0.0',
83
+ message_timestamp: Time.current.utc.iso8601,
84
+ identifiers: { id: record.id }
85
+ ))
50
86
  end
51
87
  end
52
88
  end
@@ -60,13 +96,18 @@ module PlatformSdk
60
96
  end
61
97
 
62
98
  def update_record(record, column)
99
+ if shared_params[:update_method]
100
+ send(shared_params[:update_method], record)
101
+ return
102
+ end
63
103
  new_record = build(described_class.to_s.underscore.to_sym)
64
104
 
65
- column_class = record[column]
66
- case column_class
67
- when Integer
105
+ column_value = record[column]
106
+ column_class = column_value.class
107
+ case column_class.to_s
108
+ when 'Integer'
68
109
  record.update!(column => 69)
69
- when [true, false].include?(column_class)
110
+ when 'TrueClass', 'FalseClass'
70
111
  record.update!(column => !record[column])
71
112
  else
72
113
  record.update!(column => new_record[column])
@@ -90,9 +131,9 @@ module PlatformSdk
90
131
 
91
132
  let(:data) do
92
133
  record.attributes.symbolize_keys
93
- .merge(record.pipeline_additional_attributes)
94
- .except(*record.pipeline_excluded_attributes)
95
- .merge(action:)
134
+ .merge(record.pipeline_additional_attributes)
135
+ .except(*record.pipeline_excluded_attributes)
136
+ .merge(action:)
96
137
  end
97
138
 
98
139
  it 'returns the expected payload' do
@@ -2,10 +2,10 @@
2
2
 
3
3
  module PlatformSdk
4
4
  module SpecSupport
5
- RSpec.shared_examples "OneRosterDataPipelineable" do |record_keys|
5
+ RSpec.shared_examples 'OneRosterDataPipelineable' do |record_keys|
6
6
  let(:data) do
7
7
  record_keys.each_with_object({}) do |key, hash|
8
- if key == "_type"
8
+ if key == '_type'
9
9
  hash[:type] = record.try(key)
10
10
  next
11
11
  end
@@ -17,11 +17,11 @@ module PlatformSdk
17
17
  "noun": "StrongMind.Platform.OneRoster.#{record.one_roster_data_type.capitalize}",
18
18
  "identifiers": { "sourcedId": record.roster_id },
19
19
  "meta": {
20
- "version": "3",
21
- "source": "Central OneRoster API"
20
+ "version": '3',
21
+ "source": 'Central OneRoster API'
22
22
  },
23
23
  "data": one_roster_common_data.merge!(data),
24
- "envelope_version": "1.0.0",
24
+ "envelope_version": '1.0.0',
25
25
  "message_timestamp": Time.current.utc.iso8601
26
26
  }
27
27
  end
@@ -39,27 +39,27 @@ module PlatformSdk
39
39
  before do
40
40
  allow(PlatformSdk::DataPipeline::Client).to receive(:new).and_return(data_pipeline_client)
41
41
  allow(data_pipeline_client).to receive(:post)
42
- Timecop.freeze(DateTime.parse("2024-06-09 04:20:00"))
42
+ Timecop.freeze(DateTime.parse('2024-06-09 04:20:00'))
43
43
  end
44
44
 
45
45
  after do
46
46
  Timecop.return
47
47
  end
48
48
 
49
- context "after_create callbacks" do
50
- let(:action) { "created" }
49
+ context 'create' do
50
+ let(:action) { 'created' }
51
51
 
52
- it "defines an after_create callback" do
52
+ it 'posts to the data pipeline' do
53
53
  record.save!
54
54
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
55
55
  end
56
56
  end
57
57
 
58
- context "before_destroy callbacks" do
59
- let(:action) { "destroyed" }
58
+ context 'destroy' do
59
+ let(:action) { 'destroyed' }
60
60
  let(:one_roster_common_data_deleted) do
61
61
  one_roster_common_data.merge(
62
- "status": "tobedeleted"
62
+ "status": 'tobedeleted'
63
63
  )
64
64
  end
65
65
 
@@ -67,7 +67,7 @@ module PlatformSdk
67
67
  pipeline_payload.merge("data": one_roster_common_data_deleted)
68
68
  end
69
69
 
70
- it "defines an after_destroy callback" do
70
+ it 'posts to the data pipeline' do
71
71
  record.save!
72
72
  record.destroy
73
73
  expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
@@ -75,18 +75,33 @@ module PlatformSdk
75
75
  end
76
76
  end
77
77
 
78
- context "after_update callbacks" do
79
- let(:action) { "modified" }
78
+ context 'update' do
79
+ let(:action) { 'modified' }
80
80
 
81
81
  before do
82
- allow(record).to receive(:send_pipeline_create)
83
82
  record.save!
84
83
  end
85
84
 
86
- it "defines an after_update callback" do
87
- column = column_to_update(record)
88
- update_record(record, column)
89
- expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
85
+ context 'after an update' do
86
+
87
+ it 'posts a copy of our data to the data pipeline' do
88
+ column = column_to_update(record)
89
+ update_record(record, column)
90
+ expect(data_pipeline_client).to have_received(:post).with(pipeline_payload)
91
+ end
92
+
93
+ end
94
+
95
+ context 'after an update that does not change data' do
96
+ let(:action) { 'modified' }
97
+
98
+ it 'does not post to the data pipeline' do
99
+ record.save!
100
+ column = column_to_update(record)
101
+ update_record(record, column)
102
+ record.save!
103
+ expect(data_pipeline_client).to have_received(:post).once.with(pipeline_payload)
104
+ end
90
105
  end
91
106
  end
92
107
 
@@ -100,11 +115,12 @@ module PlatformSdk
100
115
  def update_record(record, column)
101
116
  new_record = build(described_class.to_s.underscore.to_sym)
102
117
 
103
- column_class = record[column]
104
- case column_class
105
- when Integer
118
+ column_value = record[column]
119
+ column_class = column_value.class
120
+ case column_class.to_s
121
+ when 'Integer'
106
122
  record.update!(column => 69)
107
- when [true, false].include?(column_class)
123
+ when 'TrueClass', 'FalseClass'
108
124
  record.update!(column => !record[column])
109
125
  else
110
126
  record.update!(column => new_record[column])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlatformSdk
4
- VERSION = '3.19.30'
4
+ VERSION = '3.19.31'
5
5
  end
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.19.30
4
+ version: 3.19.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-07 00:00:00.000000000 Z
11
+ date: 2024-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday