active_force 0.19.0 → 0.20.1

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: 38ef881c292f8ecb12be07a0471f759a06b9155af5e3a49c26dbb69e024db87f
4
- data.tar.gz: 6a209feb04dc0c6a192c084a95c2e55c64696bbb54636496fc98dc8c56c7b653
3
+ metadata.gz: f1fbcc63ac7ef2ec3ac8efdadd055a61ae8e98fe721473a054d9207d95bc495e
4
+ data.tar.gz: 838eebde842f1edcc4b2b2a879b1697aec7439852af0f563b9f6687760b57434
5
5
  SHA512:
6
- metadata.gz: 814f0f4844f94acea113a4eabf1e3afd366b2b00255fe5bcca5ccfccb0f5d862651548302373d078a7c070422d6db6c8cf971f33112c360f0d43f133d500c98a
7
- data.tar.gz: 48f595e34749ec49adeaeb8320c407911f8841d83fcd433cdd5e7e9bc5b6b8f37d01a0f30f6a96610d91949ab8e30e2cb4b0c3f9aa18692447fc31ed6d4b75fb
6
+ metadata.gz: ec076a1ffc49293809ebb2c66445ca70b1e016c82be03f4bf6803a6482b18d014711caca4112f7875f8a76cf85b27d1381cb8ffd2a749f7c49b21f801f298af6
7
+ data.tar.gz: 24378ad367f6ff96edaa88a902c946d5d2f38f71e69d1745cc7d769b0cb1d70dec4752e5825774506985c47202ed15835268b3ad08b1d5d255f6dbfb34b24e44
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Not released
4
4
 
5
+ ## 0.20.1
6
+ - Revert "ActiveForce .first performance enhancement (#73)" (https://github.com/Beyond-Finance/active_force/pull/76)
7
+
8
+ ## 0.20.0
9
+
10
+ - Change `.first` to not query the API if records have already been retrieved (https://github.com/Beyond-Finance/active_force/pull/73)
11
+ - Bugfix: Transform NULL values for SF Bulk API, which expects "#N/A" (https://github.com/Beyond-Finance/active_force/pull/74)
12
+
5
13
  ## 0.19.0
6
14
 
7
15
  - Bulk API methods. (https://github.com/Beyond-Finance/active_force/pull/65)
@@ -3,6 +3,8 @@ require 'csv'
3
3
  module ActiveForce
4
4
  module Bulk
5
5
  class Records
6
+ NULL_VALUE = '#N/A'.freeze
7
+
6
8
  attr_reader :headers, :data
7
9
  def initialize(headers:, data:)
8
10
  @headers = headers
@@ -16,10 +18,25 @@ module ActiveForce
16
18
  end
17
19
 
18
20
  def self.parse_from_attributes(records)
21
+ # Sorting ensures that the headers line up with the values for the CSV
19
22
  headers = records.first.keys.sort.map(&:to_s)
20
- data = records.map { |r| r.sort.pluck(-1) }
23
+ data = records.map do |r|
24
+ r.transform_values { |v| transform_value_for_sf(v) }.sort.pluck(-1)
25
+ end
21
26
  new(headers: headers, data: data)
22
27
  end
28
+
29
+ # SF expects a special value for setting a column to be NULL.
30
+ def self.transform_value_for_sf(value)
31
+ case value
32
+ when NilClass
33
+ NULL_VALUE
34
+ when Time
35
+ value.iso8601
36
+ else
37
+ value.to_s
38
+ end
39
+ end
23
40
  end
24
41
  end
25
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveForce
4
- VERSION = '0.19.0'
4
+ VERSION = '0.20.1'
5
5
  end
@@ -9,11 +9,13 @@ describe ActiveForce::Bulk::Records do
9
9
  %w[value3 value4],
10
10
  ]
11
11
  end
12
+
12
13
  describe '#to_csv' do
13
14
  it 'returns CSV with headers' do
14
15
  expect(subject.to_csv).to eq "header1,header2\nvalue1,value2\nvalue3,value4\n"
15
16
  end
16
17
  end
18
+
17
19
  describe '::parse_from_attributes' do
18
20
  subject { described_class.parse_from_attributes(attributes) }
19
21
  let(:attributes) do
@@ -28,5 +30,25 @@ describe ActiveForce::Bulk::Records do
28
30
  expect(records.headers).to eq headers
29
31
  expect(records.data).to eq data
30
32
  end
33
+
34
+ context 'when there are NULL values' do
35
+ let(:attributes) do
36
+ [
37
+ { header1: nil, header2: 'value2'},
38
+ { header1: 'value3', header2: nil},
39
+ ]
40
+ end
41
+ let(:data) do
42
+ [
43
+ %w[#N/A value2],
44
+ %w[value3 #N/A],
45
+ ]
46
+ end
47
+
48
+ it 'substitutes the expected SF value for NULL' do
49
+ records = subject
50
+ expect(records.data).to eq data
51
+ end
52
+ end
31
53
  end
32
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_force
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Espinaco
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2023-11-15 00:00:00.000000000 Z
14
+ date: 2023-11-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activemodel