discourse-subscriptions/spec/requests/admin/subscriptions_controller_sp...

46 lines
1.2 KiB
Ruby
Raw Normal View History

2019-10-09 22:09:24 -04:00
# frozen_string_literal: true
require 'rails_helper'
module DiscoursePatrons
2019-10-09 22:52:55 -04:00
RSpec.describe Admin::SubscriptionsController do
it 'is a subclass of AdminController' do
expect(DiscoursePatrons::Admin::SubscriptionsController < ::Admin::AdminController).to eq(true)
end
2019-10-09 22:09:24 -04:00
2019-10-14 22:18:25 -04:00
context 'unauthenticated' do
it "does nothing" do
::Stripe::Subscription.expects(:list).never
get "/patrons/admin/subscriptions.json"
expect(response.status).to eq(403)
end
2019-11-13 18:51:04 -05:00
it "does not destroy a subscription" do
::Stripe::Subscription.expects(:delete).never
patch "/patrons/admin/subscriptions/sub_12345.json"
end
2019-10-14 22:18:25 -04:00
end
context 'authenticated' do
let(:admin) { Fabricate(:admin) }
before { sign_in(admin) }
2019-11-13 18:51:04 -05:00
describe "index" do
it "gets the subscriptions" do
::Stripe::Subscription.expects(:list)
get "/patrons/admin/subscriptions.json"
expect(response.status).to eq(200)
end
end
describe "destroy" do
it "deletes a subscription" do
::Stripe::Subscription.expects(:delete).with('sub_12345')
delete "/patrons/admin/subscriptions/sub_12345.json"
end
2019-10-14 22:18:25 -04:00
end
2019-10-09 22:09:24 -04:00
end
end
end