fix routes. get specs passing

This commit is contained in:
Rimian Perkins 2019-09-11 19:11:02 +10:00
parent 3f90518e18
commit 2e3cdb0dcf
4 changed files with 29 additions and 8 deletions

View File

@ -1,4 +1,14 @@
class PatronsController < ApplicationController
def index
# frozen_string_literal: true
module DiscoursePatrons
class PatronsController < ApplicationController
def index
result = {}
render json: result
end
def create
render json: {}
end
end
end

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true
Discourse::Application.routes.append do
get '/patrons' => 'patrons#index'
get '/patrons/:pid' => 'patrons#index'
DiscoursePatrons::Engine.routes.draw do
get '/' => 'patrons#index'
get '/:pid' => 'patrons#index'
resources :patrons, only: [:index, :create]
end

View File

@ -1,5 +1,8 @@
# name: Discourse Patrons
# about: Integrates Stripe into Discourse to allow visitors to make donations
# version: 1.0.0
# url: https://github.com/rimian/discourse-patron
# authors: Rimian Perkins
enabled_site_setting :discourse_patrons_enabled

View File

@ -6,10 +6,16 @@ module DiscoursePatrons
RSpec.describe PatronsController, type: :controller do
routes { DiscoursePatrons::Engine.routes }
it 'responds ok for anonymous users' do
post :create, params: {}, format: :json
describe 'index' do
it 'responds ok' do
get :index, format: :json
expect(response).to have_http_status(200)
end
end
aggregate_failures do
describe 'create' do
it 'responds ok' do
post :create, params: { }, format: :json
expect(response).to have_http_status(200)
end
end