active_zuora 2.1.3 → 2.1.4

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
  SHA1:
3
- metadata.gz: 39b6ca5135f93b322e6163a842ad9dc830220091
4
- data.tar.gz: 99ce7025a870017065521a1374883f2ac6a80664
3
+ metadata.gz: 3f3c48bc1e363410cf7a84fca07fed5d587ba239
4
+ data.tar.gz: cb5ef8f0177caf1b567742d5ac6ad21b56f278bb
5
5
  SHA512:
6
- metadata.gz: 73d6440dbf127d85f375ee8b1f75992d30bb238dc7594e4180498384e6700ae3290a726a85665435ecbd0dd38caada2ee7338e9a422fc4620a43aacc90e41811
7
- data.tar.gz: 1e8cad6bf28d7e6dabc8797b66cac7f08236e9a979c620864aa16eda2ced5ab951bedb15394edbc72fc868d9b4853a81c27c318187a8b9f1c13b61918c37a227
6
+ metadata.gz: 054d3ed6fd6f6a0392f7033a582ccaa5f24842438b59270c0710c69af3aa1f422552d501eb5fba854bafd421cd939a15bd7f88702b466ab145ca60a7662a99a8
7
+ data.tar.gz: 069f93a4cf88d10604174212f6b6ea947f55cede6fdca257c6772b64350b5ae90b3e266a08473b9aeb5bd066833369d23f5c4a3be6b139245b23e0fed8bb2644
@@ -1,3 +1,4 @@
1
+ #### v2.1.4
1
2
  #### v2.1.3
2
3
  #### v2.1.2
3
4
  #### v2.1.1
@@ -38,13 +38,24 @@ module ActiveZuora
38
38
  element_name = custom_element_name || zuora_object_name
39
39
  attributes = options.delete(:force_type) ?
40
40
  { "xsi:type" => "#{qualifier}:#{zuora_object_name}" } : {}
41
+
41
42
  xml.tag!(qualifier, element_name.to_sym, attributes) do
42
- xml_field_names.map { |field_name| get_field!(field_name) }.each do |field|
43
+ xml_field_names.map { |field_name| get_field!(field_name) }.sort(&method(:fields_order)).each do |field|
43
44
  field.build_xml(xml, soap, send(field.name), options)
44
45
  end
45
46
  end
46
47
  end
47
48
 
49
+ def fields_order(a, b)
50
+ if send(a.name) == nil
51
+ send(b.name) == nil ? 0 : -1
52
+ elsif a.name.to_sym == :id
53
+ send(b.name) == nil ? 1 : -1
54
+ else
55
+ (b.name.to_sym == :id || send(b.name) == nil) ? 1 : 0
56
+ end
57
+ end
58
+
48
59
  def add_zuora_errors(zuora_errors)
49
60
  return if zuora_errors.blank?
50
61
  zuora_errors = [zuora_errors] unless zuora_errors.is_a?(Array)
@@ -1,3 +1,3 @@
1
1
  module ActiveZuora
2
- VERSION = "2.1.3"
2
+ VERSION = "2.1.4"
3
3
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveZuora::Base do
4
+ class Comment
5
+ include ActiveZuora::ZObject
6
+ field :name, :string
7
+ field :null_field, :string
8
+ end
9
+
10
+ context "#fields_order" do
11
+ let(:comment) { Comment.new :id => 'blog1', :null_field => nil, :name => 'test' }
12
+ let(:field_id) { comment.get_field(:id) }
13
+ let(:field_null) { comment.get_field(:null_field) }
14
+ let(:field_name) { comment.get_field(:name) }
15
+ let(:sorted_fields) { [field_null, field_id, field_name] }
16
+
17
+ it 'When the value of a field is null, it should be the first' do
18
+ fields1 = [field_id, field_null]
19
+ expect(fields1.sort(&comment.method(:fields_order))).to eq([field_null, field_id])
20
+
21
+ fields2 = [field_name, field_null]
22
+ expect(fields2.sort(&comment.method(:fields_order))).to eq([field_null, field_name])
23
+
24
+ fields3 = [field_id, field_name, field_null]
25
+ expect(fields3.sort(&comment.method(:fields_order))).to eq(sorted_fields)
26
+ end
27
+
28
+ it 'When the field name is id, it should be after the nil value fields but before all other fields' do
29
+ fields1 = [field_name, field_id]
30
+ expect(fields1.sort(&comment.method(:fields_order))).to eq([field_id, field_name])
31
+
32
+ fields2 = [field_null, field_id]
33
+ expect(fields2.sort(&comment.method(:fields_order))).to eq([field_null, field_id])
34
+
35
+ fields3 = [field_name, field_id, field_null]
36
+ expect(fields3.sort(&comment.method(:fields_order))).to eq(sorted_fields)
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_zuora
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Lebert
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-02 00:00:00.000000000 Z
12
+ date: 2015-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -139,6 +139,7 @@ files:
139
139
  - lib/active_zuora/version.rb
140
140
  - lib/active_zuora/z_object.rb
141
141
  - spec/account_integration_spec.rb
142
+ - spec/base_spec.rb
142
143
  - spec/belongs_to_associations_spec.rb
143
144
  - spec/connection_spec.rb
144
145
  - spec/has_many_integration_spec.rb
@@ -172,6 +173,7 @@ specification_version: 4
172
173
  summary: ActiveZuora - Zuora API that looks and feels like ActiveRecord.
173
174
  test_files:
174
175
  - spec/account_integration_spec.rb
176
+ - spec/base_spec.rb
175
177
  - spec/belongs_to_associations_spec.rb
176
178
  - spec/connection_spec.rb
177
179
  - spec/has_many_integration_spec.rb