controller tests create response
This commit is contained in:
parent
35f9e4ffb2
commit
46a13af63a
|
@ -1,7 +0,0 @@
|
|||
require_dependency 'discourse'
|
||||
|
||||
module Choice
|
||||
class ApplicationController < ActionController::Base
|
||||
include CurrentUser
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
import { ajax } from 'discourse/lib/ajax';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
model() {
|
||||
return ajax('/choice/form.json');
|
||||
}
|
||||
});
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue