rspreedly 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rspreedly/subscriber.rb +19 -1
- data/rspreedly.gemspec +1 -1
- data/spec/subscriber_spec.rb +40 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/rspreedly/subscriber.rb
CHANGED
@@ -154,6 +154,24 @@ module RSpreedly
|
|
154
154
|
self.attributes = result["subscriber"]
|
155
155
|
true
|
156
156
|
end
|
157
|
-
|
157
|
+
|
158
|
+
def to_xml(opts={})
|
159
|
+
|
160
|
+
# the api doesn't let us send these things
|
161
|
+
# so let's strip them out of the XML
|
162
|
+
exclude = [
|
163
|
+
:active, :active_until, :card_expires_before_next_auto_renew,
|
164
|
+
:created_at, :eligible_for_free_trial, :feature_level,
|
165
|
+
:grace_until, :in_grace_period, :lifetime_subscription,
|
166
|
+
:on_trial, :ready_to_renew, :recurring,
|
167
|
+
:store_credit, :store_credit_currency_code, :subscription_plan_name,
|
168
|
+
:token, :updated_at
|
169
|
+
]
|
170
|
+
|
171
|
+
opts[:exclude] ||= []
|
172
|
+
opts[:exclude] |= exclude
|
173
|
+
|
174
|
+
super(opts)
|
175
|
+
end
|
158
176
|
end
|
159
177
|
end
|
data/rspreedly.gemspec
CHANGED
data/spec/subscriber_spec.rb
CHANGED
@@ -39,7 +39,46 @@ describe RSpreedly::Subscriber do
|
|
39
39
|
RSpreedly::Subscriber.destroy_all.should be_true
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
|
+
describe "#to_xml" do
|
44
|
+
|
45
|
+
before(:each) do
|
46
|
+
# use the XML to build a subscriber
|
47
|
+
stub_http_with_fixture("subscriber.xml", 200)
|
48
|
+
@subscriber = RSpreedly::Subscriber.find(42)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should strip fields the API can't handle" do
|
52
|
+
fields = [
|
53
|
+
:active, :active_until, :card_expires_before_next_auto_renew,
|
54
|
+
:created_at, :eligible_for_free_trial, :feature_level,
|
55
|
+
:grace_until, :in_grace_period, :lifetime_subscription,
|
56
|
+
:on_trial, :ready_to_renew, :recurring,
|
57
|
+
:store_credit, :store_credit_currency_code, :subscription_plan_name,
|
58
|
+
:token, :updated_at
|
59
|
+
]
|
60
|
+
|
61
|
+
xml = @subscriber.to_xml
|
62
|
+
fields.each do |field|
|
63
|
+
xml.should_not =~ /<#{field}>/
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should not strip fields the API can handle" do
|
68
|
+
fields = [
|
69
|
+
:billing_first_name,
|
70
|
+
:billing_last_name,
|
71
|
+
:customer_id, :email,
|
72
|
+
:screen_name
|
73
|
+
]
|
74
|
+
|
75
|
+
xml = @subscriber.to_xml
|
76
|
+
fields.each do |field|
|
77
|
+
xml.should =~ /<#{field}>/
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
43
82
|
describe "#new_record?" do
|
44
83
|
before(:each) do
|
45
84
|
@subscriber = RSpreedly::Subscriber.new
|