From 2e3cdb0dcf427ab604dbf084248c4f4ae89d4130 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Wed, 11 Sep 2019 19:11:02 +1000 Subject: [PATCH] fix routes. get specs passing --- app/controllers/patrons_controller.rb | 14 ++++++++++++-- config/routes.rb | 8 +++++--- plugin.rb | 3 +++ .../discourse_patrons/patrons_controller_spec.rb | 12 +++++++++--- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/controllers/patrons_controller.rb b/app/controllers/patrons_controller.rb index af41140..5bd56e7 100644 --- a/app/controllers/patrons_controller.rb +++ b/app/controllers/patrons_controller.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 65ce857..d8eb7b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/plugin.rb b/plugin.rb index aa6f2a8..4bead69 100644 --- a/plugin.rb +++ b/plugin.rb @@ -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 diff --git a/spec/controllers/discourse_patrons/patrons_controller_spec.rb b/spec/controllers/discourse_patrons/patrons_controller_spec.rb index ade147e..ec182ee 100644 --- a/spec/controllers/discourse_patrons/patrons_controller_spec.rb +++ b/spec/controllers/discourse_patrons/patrons_controller_spec.rb @@ -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