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:
Vinoth Kannan 2021-09-21 18:12:17 +05:30 committed by GitHub
parent 6052366472
commit 3ce422ffbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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