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 <[email protected]>
This commit is contained in:
Vinoth Kannan
2021-09-21 18:12:17 +05:30
committed by GitHub
co-authored by Jarek Radosz
parent 6052366472
commit 3ce422ffbe
2 changed files with 8 additions and 3 deletions
@@ -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
+5 -2
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