Skip to content

Commit

Permalink
Make additional fixture to test added attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
rlew421 committed Jul 13, 2023
1 parent 7edd5ba commit 7051f31
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<subscription><account><account_code>1</account_code><billing_info><month>1</month><number>4111-1111-1111-1111</number><year>2014</year></billing_info><dunning_campaign_id>1234abcd</dunning_campaign_id><email>[email protected]</email><first_name>Verena</first_name><last_name>Example</last_name></account><currency>EUR</currency><customer_notes>Some Customer Notes</customer_notes><imported_trial>true</imported_trial><plan_code>gold</plan_code><ramp_intervals><ramp_interval><ending_on>2022-10-23 16:16:34.000000</ending_on><starting_billing_cycle>1</starting_billing_cycle><starting_on>2022-09-23 16:16:34.000000</starting_on><unit_amount_in_cents>1000</unit_amount_in_cents></ramp_interval><ramp_interval><starting_billing_cycle>2</starting_billing_cycle><starting_on>2022-10-23 16:16:34.000000</starting_on><unit_amount_in_cents>2000</unit_amount_in_cents></ramp_interval></ramp_intervals><shipping_address_id>1234</shipping_address_id><shipping_amount_in_cents>899</shipping_amount_in_cents><shipping_method_code>ups_ground</shipping_method_code><terms_and_conditions>Some Terms and Conditions</terms_and_conditions></subscription>
2 changes: 1 addition & 1 deletion spec/fixtures/subscriptions/serialize-with-ramps.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<subscription><account><account_code>1</account_code><billing_info><month>1</month><number>4111-1111-1111-1111</number><year>2014</year></billing_info><dunning_campaign_id>1234abcd</dunning_campaign_id><email>[email protected]</email><first_name>Verena</first_name><last_name>Example</last_name></account><currency>EUR</currency><customer_notes>Some Customer Notes</customer_notes><imported_trial>true</imported_trial><plan_code>gold</plan_code><ramp_intervals><ramp_interval><ending_on>2022-10-23 16:16:34.000000</ending_on><starting_billing_cycle>1</starting_billing_cycle><starting_on>2022-09-23 16:16:34.000000</starting_on><unit_amount_in_cents>1000</unit_amount_in_cents></ramp_interval><ramp_interval><starting_billing_cycle>2</starting_billing_cycle><starting_on>2022-10-23 16:16:34.000000</starting_on><unit_amount_in_cents>2000</unit_amount_in_cents></ramp_interval></ramp_intervals><shipping_address_id>1234</shipping_address_id><shipping_amount_in_cents>899</shipping_amount_in_cents><shipping_method_code>ups_ground</shipping_method_code><terms_and_conditions>Some Terms and Conditions</terms_and_conditions></subscription>
<subscription><account><account_code>1</account_code><billing_info><month>1</month><number>4111-1111-1111-1111</number><year>2014</year></billing_info><dunning_campaign_id>1234abcd</dunning_campaign_id><email>[email protected]</email><first_name>Verena</first_name><last_name>Example</last_name></account><currency>EUR</currency><customer_notes>Some Customer Notes</customer_notes><imported_trial>true</imported_trial><plan_code>gold</plan_code><ramp_intervals><ramp_interval><starting_billing_cycle>1</starting_billing_cycle><unit_amount_in_cents>1000</unit_amount_in_cents></ramp_interval><ramp_interval><starting_billing_cycle>2</starting_billing_cycle><unit_amount_in_cents>2000</unit_amount_in_cents></ramp_interval></ramp_intervals><shipping_address_id>1234</shipping_address_id><shipping_amount_in_cents>899</shipping_amount_in_cents><shipping_method_code>ups_ground</shipping_method_code><terms_and_conditions>Some Terms and Conditions</terms_and_conditions></subscription>
43 changes: 31 additions & 12 deletions spec/recurly/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,11 @@
ramp_intervals: [
SubscriptionRampInterval.new(
starting_billing_cycle: 1,
unit_amount_in_cents: 1000,
starting_on: '2022-09-23 16:16:34.000000',
ending_on: '2022-10-23 16:16:34.000000'
unit_amount_in_cents: 1000
),
SubscriptionRampInterval.new(
starting_billing_cycle: 2,
unit_amount_in_cents: 2000,
starting_on: '2022-10-23 16:16:34.000000',
ending_on: nil
unit_amount_in_cents: 2000
)
]
)
Expand All @@ -95,12 +91,35 @@
subscription.to_xml.must_equal get_raw_xml('subscriptions/serialize-with-ramps.xml')
end

it 'contains the expected attributes' do
subscription = Subscription.new attributes
expect(subscription.ramp_intervals[0].starting_on).must_equal('2022-09-23 16:16:34.000000')
expect(subscription.ramp_intervals[0].ending_on).must_equal('2022-10-23 16:16:34.000000')
expect(subscription.ramp_intervals[1].starting_on).must_equal('2022-10-23 16:16:34.000000')
expect(subscription.ramp_intervals[1].ending_on).must_equal(nil)
describe 'with starting_on and ending_on' do
before do
attributes.merge!(
ramp_intervals: [
SubscriptionRampInterval.new(
starting_billing_cycle: 1,
unit_amount_in_cents: 1000,
starting_on: '2022-09-23 16:16:34.000000',
ending_on: '2022-10-23 16:16:34.000000'
),
SubscriptionRampInterval.new(
starting_billing_cycle: 2,
unit_amount_in_cents: 2000,
starting_on: '2022-10-23 16:16:34.000000',
ending_on: nil
)
]
)
end

it 'contains the expected attributes' do
sub = Subscription.from_xml(get_raw_xml 'subscriptions/serialize-with-ramps-starting-on-ending-on.xml')

expect(sub.ramp_intervals[0].starting_on).must_equal('2022-09-23 16:16:34.000000')
expect(sub.ramp_intervals[0].ending_on).must_equal('2022-10-23 16:16:34.000000')

expect(sub.ramp_intervals[1].starting_on).must_equal('2022-10-23 16:16:34.000000')
expect(sub.ramp_intervals[1].ending_on).must_equal(nil)
end
end
end
end
Expand Down

0 comments on commit 7051f31

Please sign in to comment.