namespace subscriptions controller

This commit is contained in:
Rimian Perkins 2019-10-10 13:09:24 +11:00
parent 321f6b8a71
commit 91045583ad
6 changed files with 34 additions and 32 deletions

View File

@ -1,14 +1,16 @@
# frozen_string_literal: true
module DiscoursePatrons
class SubscriptionsController < ::Admin::AdminController
include DiscoursePatrons::Stripe
module Admin
class SubscriptionsController < ::Admin::AdminController
include DiscoursePatrons::Stripe
before_action :set_api_key
before_action :set_api_key
def index
subscriptions = ::Stripe::Subscription.list
subscriptions.to_json
def index
subscriptions = ::Stripe::Subscription.list
subscriptions.to_json
end
end
end
end

View File

@ -1,14 +1,14 @@
# frozen_string_literal: true
DiscoursePatrons::Engine.routes.draw do
# TODO: namespace this
scope 'admin' do
get '/' => 'admin#index'
resources :subscriptions, only: [:index]
end
namespace :admin do
resources :plans
resources :subscriptions, only: [:index]
end
get '/' => 'patrons#index'

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
require 'rails_helper'
module DiscoursePatrons
module Admin
RSpec.describe SubscriptionsController do
let(:admin) { Fabricate(:admin) }
before { sign_in(admin) }
it 'is a subclass of AdminController' do
expect(DiscoursePatrons::Admin::SubscriptionsController < ::Admin::AdminController).to eq(true)
end
it "gets the empty subscriptions" do
::Stripe::Subscription.expects(:list)
get "/patrons/admin/subscriptions.json"
expect(response.status).to eq(204)
end
end
end
end

View File

@ -1,22 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
module DiscoursePatrons
RSpec.describe SubscriptionsController do
let(:admin) { Fabricate(:admin) }
before { sign_in(admin) }
it 'is a subclass of AdminController' do
expect(DiscoursePatrons::SubscriptionsController < ::Admin::AdminController).to eq(true)
end
it "gets the empty subscriptions" do
::Stripe::Subscription.expects(:list)
get "/patrons/admin/subscriptions.json"
expect(response.status).to eq(204)
end
end
end

View File

@ -1,4 +1,3 @@
export default function(helpers) {
const { response } = helpers;

View File

@ -1,4 +1,3 @@
export function stubStripe() {
window.Stripe = () => {
return {