mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-17 11:33:27 +00:00
fix broken unauthenticated page
This commit is contained in:
parent
56b73139d1
commit
d8a3ae5554
@ -44,6 +44,8 @@ module DiscoursePatrons
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_user_products
|
def current_user_products
|
||||||
|
return [] if current_user.nil?
|
||||||
|
|
||||||
::DiscoursePatrons::Customer
|
::DiscoursePatrons::Customer
|
||||||
.select(:product_id)
|
.select(:product_id)
|
||||||
.where(user_id: current_user.id)
|
.where(user_id: current_user.id)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# name: discourse-subscriptions
|
# name: discourse-subscriptions
|
||||||
# about: Integrates Stripe into Discourse to allow visitors to subscribe
|
# about: Integrates Stripe into Discourse to allow visitors to subscribe
|
||||||
# version: 2.5.0
|
# version: 2.5.1
|
||||||
# url: https://github.com/rimian/discourse-subscriptions
|
# url: https://github.com/rimian/discourse-subscriptions
|
||||||
# authors: Rimian Perkins
|
# authors: Rimian Perkins
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ after_initialize do
|
|||||||
|
|
||||||
::Stripe.set_app_info(
|
::Stripe.set_app_info(
|
||||||
'Discourse Subscriptions',
|
'Discourse Subscriptions',
|
||||||
version: '2.5.0',
|
version: '2.5.1',
|
||||||
url: 'https://github.com/rimian/discourse-subscriptions'
|
url: 'https://github.com/rimian/discourse-subscriptions'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,9 +4,7 @@ require 'rails_helper'
|
|||||||
|
|
||||||
module DiscoursePatrons
|
module DiscoursePatrons
|
||||||
RSpec.describe ProductsController do
|
RSpec.describe ProductsController do
|
||||||
context "authenticated" do
|
describe "products" do
|
||||||
let(:user) { Fabricate(:user) }
|
|
||||||
|
|
||||||
let(:product) do
|
let(:product) do
|
||||||
{
|
{
|
||||||
id: "prodct_23456",
|
id: "prodct_23456",
|
||||||
@ -18,6 +16,24 @@ module DiscoursePatrons
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "unauthenticated" do
|
||||||
|
it "gets products" do
|
||||||
|
::Stripe::Product.expects(:list).with(active: true).returns(data: [product])
|
||||||
|
|
||||||
|
get "/s/products.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",
|
||||||
|
"subscribed" => false
|
||||||
|
}])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "authenticated" do
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
end
|
end
|
||||||
@ -70,4 +86,5 @@ module DiscoursePatrons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user