FIX: set interval field correctly in object root for recurring plans. (#91)
The interval field was missing in the Ember object since it was only available inside the nested object. Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
parent
6052366472
commit
3ce422ffbe
|
@ -55,7 +55,9 @@ module DiscourseSubscriptions
|
|||
trial_days = plan[:recurring][:trial_period_days]
|
||||
end
|
||||
|
||||
serialized = plan.to_h.merge(trial_period_days: trial_days, currency: plan[:currency].upcase)
|
||||
interval = plan.dig(:recurring, :interval)
|
||||
|
||||
serialized = plan.to_h.merge(trial_period_days: trial_days, currency: plan[:currency].upcase, interval: interval)
|
||||
|
||||
render_json_dump serialized
|
||||
|
||||
|
|
|
@ -79,9 +79,12 @@ module DiscourseSubscriptions
|
|||
end
|
||||
|
||||
it "upcases the currency" do
|
||||
::Stripe::Price.expects(:retrieve).with('plan_12345').returns(currency: 'aud')
|
||||
::Stripe::Price.expects(:retrieve).with('plan_12345').returns(currency: 'aud', recurring: { interval: 'year' })
|
||||
get "/s/admin/plans/plan_12345.json"
|
||||
expect(response.parsed_body["currency"]).to eq 'AUD'
|
||||
|
||||
plan = response.parsed_body
|
||||
expect(plan["currency"]).to eq 'AUD'
|
||||
expect(plan["interval"]).to eq 'year'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue