discourse-subscriptions/spec/requests/products_controller_spec.rb

46 lines
1.3 KiB
Ruby
Raw Normal View History

2019-10-24 17:18:16 -04:00
# frozen_string_literal: true
require 'rails_helper'
module DiscoursePatrons
RSpec.describe ProductsController do
2019-11-04 00:37:21 -05:00
let(:product) do
{
id: "prodct_23456",
name: "Very Special Product",
metadata: {
description: "Many people listened to my phone call with the Ukrainian President while it was being made"
},
otherstuff: true,
}
end
2019-10-24 17:18:16 -04:00
describe "index" do
2019-11-04 00:37:21 -05:00
it "gets products" do
::Stripe::Product.expects(:list).with(active: true).returns(data: [product])
2019-10-24 17:18:16 -04:00
get "/patrons/products.json"
2019-11-04 00:37:21 -05:00
expect(JSON.parse(response.body)).to eq([{
"id" => "prodct_23456",
"name" => "Very Special Product",
"description" => "Many people listened to my phone call with the Ukrainian President while it was being made"
}])
end
end
describe 'show' do
it 'retrieves the product' do
::Stripe::Product.expects(:retrieve).with('prod_walterwhite').returns(product)
get "/patrons/products/prod_walterwhite.json"
expect(JSON.parse(response.body)).to eq(
"id" => "prodct_23456",
"name" => "Very Special Product",
"description" => "Many people listened to my phone call with the Ukrainian President while it was being made"
)
2019-10-24 17:18:16 -04:00
end
end
end
end