2019-10-09 22:52:55 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
module DiscoursePatrons
|
|
|
|
RSpec.describe PlansController do
|
|
|
|
describe "index" do
|
2019-10-23 19:39:10 -04:00
|
|
|
it "lists the active plans" do
|
|
|
|
::Stripe::Plan.expects(:list).with(active: true)
|
2019-10-09 22:52:55 -04:00
|
|
|
get "/patrons/plans.json"
|
|
|
|
end
|
2019-10-31 19:18:57 -04:00
|
|
|
|
|
|
|
it "orders and serialises the plans" do
|
2019-10-31 21:30:19 -04:00
|
|
|
::Stripe::Plan.expects(:list).returns(
|
2019-10-31 19:18:57 -04:00
|
|
|
data: [
|
|
|
|
{ id: 'plan_id123', amount: 1220, currency: 'aud', interval: 'year', metadata: {} },
|
|
|
|
{ id: 'plan_id234', amount: 1399, currency: 'usd', interval: 'year', metadata: {} },
|
|
|
|
{ id: 'plan_id678', amount: 1000, currency: 'aud', interval: 'week', metadata: {} }
|
|
|
|
]
|
2019-10-31 21:30:19 -04:00
|
|
|
)
|
2019-10-31 19:18:57 -04:00
|
|
|
|
|
|
|
get "/patrons/plans.json"
|
|
|
|
|
|
|
|
expect(JSON.parse(response.body)).to eq([
|
2019-10-31 19:50:34 -04:00
|
|
|
{ "amount" => 1000, "currency" => "aud", "id" => "plan_id678", "interval" => "week" },
|
|
|
|
{ "amount" => 1220, "currency" => "aud", "id" => "plan_id123", "interval" => "year" },
|
|
|
|
{ "amount" => 1399, "currency" => "usd", "id" => "plan_id234", "interval" => "year" }
|
2019-10-31 19:18:57 -04:00
|
|
|
])
|
|
|
|
end
|
2019-10-09 22:52:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|