active_zuora 2.3.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +2 -0
- data/lib/active_zuora/fields.rb +8 -6
- data/lib/active_zuora/fields/date_field.rb +18 -0
- data/lib/active_zuora/generator.rb +3 -0
- data/lib/active_zuora/version.rb +1 -1
- data/spec/fields/date_field_spec.rb +35 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 206546ae23f9e0790c2787774d79b40e36d03d38
|
4
|
+
data.tar.gz: 1ab0f42868f388ecbf82cc2bbd4aabe73ecbbb05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f82c93e82964fa5e5bd9c0a327911f38298c0d7040bdf2637c2c3d15ddde8161d8ae033f518df1d72b92511ac10a019f1be2422664d48df00f7ebacd64cf37d7
|
7
|
+
data.tar.gz: 701ce736106c7618647ad43920dc584f9522cc167572b1f18ed233df84d63a8c2ad830890bda3499f2496cb3df6b0a4a868929c3d28e6774cf70791ed3ee78f9
|
data/CHANGELOG.markdown
CHANGED
data/lib/active_zuora/fields.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_zuora/fields/field'
|
2
2
|
require 'active_zuora/fields/boolean_field'
|
3
|
+
require 'active_zuora/fields/date_field'
|
3
4
|
require 'active_zuora/fields/date_time_field'
|
4
5
|
require 'active_zuora/fields/decimal_field'
|
5
6
|
require 'active_zuora/fields/integer_field'
|
@@ -14,7 +15,7 @@ module ActiveZuora
|
|
14
15
|
|
15
16
|
included do
|
16
17
|
include ActiveModel::Dirty
|
17
|
-
delegate :fields, :field_names, :field?, :get_field, :get_field!,
|
18
|
+
delegate :fields, :field_names, :field?, :get_field, :get_field!,
|
18
19
|
:default_attributes, :to => 'self.class'
|
19
20
|
end
|
20
21
|
|
@@ -96,10 +97,11 @@ module ActiveZuora
|
|
96
97
|
field_is_array = options.delete(:array) || false
|
97
98
|
# Create and register the field.
|
98
99
|
field = case type
|
99
|
-
when :string
|
100
|
-
when :boolean
|
101
|
-
when :integer
|
102
|
-
when :decimal
|
100
|
+
when :string then StringField.new(name, namespace, options)
|
101
|
+
when :boolean then BooleanField.new(name, namespace, options)
|
102
|
+
when :integer then IntegerField.new(name, namespace, options)
|
103
|
+
when :decimal then DecimalField.new(name, namespace, options)
|
104
|
+
when :date then DateField.new(name, namespace, options)
|
103
105
|
when :datetime then DateTimeField.new(name, namespace, options)
|
104
106
|
when :object
|
105
107
|
class_name = options[:class_name] || nested_class_name(name.to_s.camelize)
|
@@ -119,4 +121,4 @@ module ActiveZuora
|
|
119
121
|
|
120
122
|
end
|
121
123
|
end
|
122
|
-
end
|
124
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveZuora
|
2
|
+
class DateField < Field
|
3
|
+
|
4
|
+
def type_cast(value)
|
5
|
+
return value if value.nil?
|
6
|
+
return value.to_date if value.is_a?(Date)
|
7
|
+
return value.to_date if value.is_a?(DateTime)
|
8
|
+
value.to_date rescue default
|
9
|
+
end
|
10
|
+
|
11
|
+
def build_xml(xml, soap, value, options={})
|
12
|
+
value = value ? value.strftime("%Y-%m-%d") : ''
|
13
|
+
super(xml, soap, value, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -65,6 +65,9 @@ module ActiveZuora
|
|
65
65
|
when "decimal"
|
66
66
|
zuora_class.field field_name, :decimal,
|
67
67
|
:zuora_name => zuora_name, :array => is_array
|
68
|
+
when "date"
|
69
|
+
zuora_class.field field_name, :date,
|
70
|
+
:zuora_name => zuora_name, :array => is_array
|
68
71
|
when "dateTime"
|
69
72
|
zuora_class.field field_name, :datetime,
|
70
73
|
:zuora_name => zuora_name, :array => is_array
|
data/lib/active_zuora/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveZuora::DateField do
|
4
|
+
subject { described_class.new("date", described_class, {:zuora_name => "date"}) }
|
5
|
+
|
6
|
+
describe "#type_cast" do
|
7
|
+
it "returns nil if provided nil" do
|
8
|
+
expect(subject.type_cast(nil)).to eq(nil)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns a date when given a datetime object" do
|
12
|
+
datetime = DateTime.now
|
13
|
+
expect(subject.type_cast(datetime)).to be_a(Date)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns a date when given a date object" do
|
17
|
+
date = Date.today
|
18
|
+
expect(subject.type_cast(date)).to be_a(Date)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#build_xml" do
|
23
|
+
let(:xml) { double(:xml, :tag! => nil) }
|
24
|
+
let(:soap) { double(:soap, :namespace_by_uri => nil) }
|
25
|
+
let(:options) { {} }
|
26
|
+
|
27
|
+
it "handles a nil value" do
|
28
|
+
expect { subject.build_xml(xml, soap, nil, options) }.to_not raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it "handles a date value" do
|
32
|
+
expect { subject.build_xml(xml, soap, Date.today, options) }.to_not raise_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
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.
|
4
|
+
version: 2.4.0
|
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:
|
12
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/active_zuora/fields.rb
|
126
126
|
- lib/active_zuora/fields/array_field_decorator.rb
|
127
127
|
- lib/active_zuora/fields/boolean_field.rb
|
128
|
+
- lib/active_zuora/fields/date_field.rb
|
128
129
|
- lib/active_zuora/fields/date_time_field.rb
|
129
130
|
- lib/active_zuora/fields/decimal_field.rb
|
130
131
|
- lib/active_zuora/fields/field.rb
|
@@ -147,6 +148,7 @@ files:
|
|
147
148
|
- spec/belongs_to_associations_spec.rb
|
148
149
|
- spec/collection_proxy_spec.rb
|
149
150
|
- spec/connection_spec.rb
|
151
|
+
- spec/fields/date_field_spec.rb
|
150
152
|
- spec/has_many_integration_spec.rb
|
151
153
|
- spec/lazy_attr_spec.rb
|
152
154
|
- spec/spec_helper.rb
|
@@ -173,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
175
|
version: '0'
|
174
176
|
requirements: []
|
175
177
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.4.8
|
177
179
|
signing_key:
|
178
180
|
specification_version: 4
|
179
181
|
summary: ActiveZuora - Zuora API that looks and feels like ActiveRecord.
|
@@ -183,6 +185,7 @@ test_files:
|
|
183
185
|
- spec/belongs_to_associations_spec.rb
|
184
186
|
- spec/collection_proxy_spec.rb
|
185
187
|
- spec/connection_spec.rb
|
188
|
+
- spec/fields/date_field_spec.rb
|
186
189
|
- spec/has_many_integration_spec.rb
|
187
190
|
- spec/lazy_attr_spec.rb
|
188
191
|
- spec/spec_helper.rb
|