diff --git a/app/controllers/choice/application_controller.rb b/app/controllers/choice/application_controller.rb deleted file mode 100644 index 9930d2d..0000000 --- a/app/controllers/choice/application_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_dependency 'discourse' - -module Choice - class ApplicationController < ActionController::Base - include CurrentUser - end -end diff --git a/app/controllers/choice/choice_controller.rb b/app/controllers/choice/choice_controller.rb index 235b0f1..6a955ee 100644 --- a/app/controllers/choice/choice_controller.rb +++ b/app/controllers/choice/choice_controller.rb @@ -9,25 +9,25 @@ module Choice end def create - badge = Badge.find_by_name('Consumer Defender') - - if badge.nil? - head 422 and return - end - - customer = Stripe::Customer.create( - :email => params[:stripeEmail], - :source => params[:stripeToken] - ) - - charge = Stripe::Charge.create( - :customer => customer.id, - :amount => 1000, - :description => 'Consumer Defender', - :currency => 'aud' - ) - - BadgeGranter.grant(badge, current_user) + # badge = Badge.find_by_name('Consumer Defender') + # + # if badge.nil? + # head 422 and return + # end + # + # customer = Stripe::Customer.create( + # :email => params[:stripeEmail], + # :source => params[:stripeToken] + # ) + # + # charge = Stripe::Charge.create( + # :customer => customer.id, + # :amount => 1000, + # :description => 'Consumer Defender', + # :currency => 'aud' + # ) + # + # BadgeGranter.grant(badge, current_user) render :json => { status: 'OK' } end diff --git a/assets/javascripts/discourse/routes/choice-discourse-index.js.es6 b/assets/javascripts/discourse/routes/choice-discourse-index.js.es6 deleted file mode 100644 index 2f0c6fa..0000000 --- a/assets/javascripts/discourse/routes/choice-discourse-index.js.es6 +++ /dev/null @@ -1,7 +0,0 @@ -import { ajax } from 'discourse/lib/ajax'; - -export default Ember.Route.extend({ - model() { - return ajax('/choice/form.json'); - } -}); diff --git a/config/routes.rb b/config/routes.rb index ca9e6c6..5aae86f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ Choice::Engine.routes.draw do - get 'stripe' => 'choice#create' - get 'choice-form' => 'choice#index' + resources :choice, only: [:create] get 'users/:username/payments' => 'choice#show' end diff --git a/spec/controllers/choice/choice_controller_spec.rb b/spec/controllers/choice/choice_controller_spec.rb index ae27a17..54f1009 100644 --- a/spec/controllers/choice/choice_controller_spec.rb +++ b/spec/controllers/choice/choice_controller_spec.rb @@ -1,9 +1,12 @@ require 'rails_helper' module Choice - RSpec.describe 'ChoiceController', type: :controller do - it do - expect(Choice::ChoiceController).to be_truthy + RSpec.describe ChoiceController, type: :controller do + routes { Choice::Engine.routes } + + it 'responds with ok' do + post :create + expect(response).to have_http_status(200) end end end