add initial controllers

This commit is contained in:
Rimian Perkins 2019-09-23 17:53:05 +10:00
parent e004a18071
commit e1ed1a41b0
11 changed files with 84 additions and 14 deletions

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
module DiscoursePatrons
class SubscriptionsController < ::Admin::AdminController
def index
head 200
end
end
end

View File

@ -1,4 +1,3 @@
export default Ember.Controller.extend({ export default Ember.Controller.extend({
queryParams: ["order", "descending"], queryParams: ["order", "descending"],
order: null, order: null,

View File

@ -0,0 +1,7 @@
export default Ember.Controller.extend({
actions: {
createSubscriptionPlan() {
console.log(45);
}
}
});

View File

@ -1,3 +1 @@
export default Ember.Controller.extend({});
export default Ember.Controller.extend({
});

View File

@ -0,0 +1,13 @@
import { ajax } from "discourse/lib/ajax";
export default Discourse.Route.extend({
model(params) {
return ajax("/patrons/admin/subscriptions", {
method: "get",
data: {
order: params.order,
descending: params.descending
}
}).then(results => results);
}
});

View File

@ -1,3 +1 @@
export default Discourse.Route.extend({});
export default Discourse.Route.extend({
});

View File

@ -1,3 +1,22 @@
<h3>Subscription Plans</h3>
<h3>Subscriptions</h3> {{#d-button action="createSubscriptionPlan" class="btn btn-primary btn-payment btn-discourse-patrons"}}
New
{{/d-button}}
<table class="table discourse-patrons-admin">
<thead>
<tr>
<th>Plan Name</th>
<th>Interval</th>
<th>Product</th>
<th>Amount</th>
</tr>
</thead>
{{#each model as |payment|}}
<tr>
</tr>
{{/each}}
</table>

View File

@ -2,6 +2,7 @@
DiscoursePatrons::Engine.routes.draw do DiscoursePatrons::Engine.routes.draw do
get '/admin' => 'admin#index' get '/admin' => 'admin#index'
get '/admin/subscriptions' => 'subscriptions#index'
get '/' => 'patrons#index' get '/' => 'patrons#index'
get '/:pid' => 'patrons#show' get '/:pid' => 'patrons#show'
resources :patrons, only: [:index, :create] resources :patrons, only: [:index, :create]

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
# name: discourse-patrons # name: discourse-patrons
# about: Integrates Stripe into Discourse to allow visitors to make payments # about: Integrates Stripe into Discourse to allow visitors to make payments and Subscribe
# version: 1.2.1 # version: 1.2.1
# url: https://github.com/rimian/discourse-patrons # url: https://github.com/rimian/discourse-patrons
# authors: Rimian Perkins # authors: Rimian Perkins
@ -36,6 +36,7 @@ after_initialize do
"../lib/discourse_patrons/engine", "../lib/discourse_patrons/engine",
"../config/routes", "../config/routes",
"../app/controllers/admin_controller", "../app/controllers/admin_controller",
"../app/controllers/admin/subscriptions_controller",
"../app/controllers/patrons_controller", "../app/controllers/patrons_controller",
"../app/models/payment", "../app/models/payment",
"../app/serializers/payment_serializer", "../app/serializers/payment_serializer",

View File

@ -3,15 +3,19 @@
require 'rails_helper' require 'rails_helper'
module DiscoursePatrons module DiscoursePatrons
RSpec.describe AdminController, type: :controller do RSpec.describe AdminController do
routes { DiscoursePatrons::Engine.routes }
let(:admin) { Fabricate(:admin) }
before { sign_in(admin) }
it '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
# TODO: authenticate to test these it "is ok" do
it "is ascending" get "/patrons/admin.json"
it "is has ordered by" expect(response.status).to eq(200)
end
end end
end end

View File

@ -0,0 +1,21 @@
# 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 "is ok" do
get "/patrons/admin/subscriptions.json"
expect(response.status).to eq(200)
end
end
end