spec unauthenticated plans request
This commit is contained in:
parent
8cc4f880eb
commit
321f6b8a71
|
@ -5,14 +5,53 @@ require 'rails_helper'
|
||||||
module DiscoursePatrons
|
module DiscoursePatrons
|
||||||
module Admin
|
module Admin
|
||||||
RSpec.describe PlansController do
|
RSpec.describe PlansController do
|
||||||
|
it 'is a subclass of AdminController' do
|
||||||
|
expect(DiscoursePatrons::Admin::PlansController < ::Admin::AdminController).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'not authenticated' do
|
||||||
|
describe "index" do
|
||||||
|
it "does not get the plans" do
|
||||||
|
::Stripe::Plan.expects(:list).never
|
||||||
|
get "/patrons/admin/plans.json"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "not ok" do
|
||||||
|
get "/patrons/admin/plans.json"
|
||||||
|
expect(response.status).to eq 403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "create" do
|
||||||
|
it "does not create a plan" do
|
||||||
|
::Stripe::Plan.expects(:create).never
|
||||||
|
post "/patrons/admin/plans.json", params: { name: 'Rick Astley', amount: 1, interval: 'week' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "is not ok" do
|
||||||
|
post "/patrons/admin/plans.json", params: { name: 'Rick Astley', amount: 1, interval: 'week' }
|
||||||
|
expect(response.status).to eq 403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "delete" do
|
||||||
|
it "does not delete a plan" do
|
||||||
|
::Stripe::Plan.expects(:delete).never
|
||||||
|
delete "/patrons/admin/plans/plan_12345.json"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "is not ok" do
|
||||||
|
delete "/patrons/admin/plans/plan_12345.json"
|
||||||
|
expect(response.status).to eq 403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'authenticated' do
|
||||||
let(:admin) { Fabricate(:admin) }
|
let(:admin) { Fabricate(:admin) }
|
||||||
|
|
||||||
before { sign_in(admin) }
|
before { sign_in(admin) }
|
||||||
|
|
||||||
xit 'is a subclass of AdminController' do
|
|
||||||
expect(DiscoursePatrons::Admin::PlansController < Admin::AdminController).to eq(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "index" do
|
describe "index" do
|
||||||
it "is ok" do
|
it "is ok" do
|
||||||
::Stripe::Plan.expects(:list)
|
::Stripe::Plan.expects(:list)
|
||||||
|
@ -56,4 +95,5 @@ module DiscoursePatrons
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,8 @@ module DiscoursePatrons
|
||||||
|
|
||||||
before { sign_in(admin) }
|
before { sign_in(admin) }
|
||||||
|
|
||||||
xit 'is a subclass of AdminController' do
|
it 'is a subclass of AdminController' do
|
||||||
expect(DiscoursePatrons::AdminController < Admin::AdminController).to eq(true)
|
expect(DiscoursePatrons::AdminController < ::Admin::AdminController).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is ok" do
|
it "is ok" do
|
||||||
|
|
|
@ -9,8 +9,8 @@ module DiscoursePatrons
|
||||||
|
|
||||||
before { sign_in(admin) }
|
before { sign_in(admin) }
|
||||||
|
|
||||||
xit 'is a subclass of AdminController' do
|
it 'is a subclass of AdminController' do
|
||||||
expect(DiscoursePatrons::SubscriptionsController < Admin::AdminController).to eq(true)
|
expect(DiscoursePatrons::SubscriptionsController < ::Admin::AdminController).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "gets the empty subscriptions" do
|
it "gets the empty subscriptions" do
|
||||||
|
|
Loading…
Reference in New Issue