mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-13 01:23:28 +00:00
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
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
badge = Badge.find_by_name('Consumer Defender')
|
# badge = Badge.find_by_name('Consumer Defender')
|
||||||
|
#
|
||||||
if badge.nil?
|
# if badge.nil?
|
||||||
head 422 and return
|
# head 422 and return
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
customer = Stripe::Customer.create(
|
# customer = Stripe::Customer.create(
|
||||||
:email => params[:stripeEmail],
|
# :email => params[:stripeEmail],
|
||||||
:source => params[:stripeToken]
|
# :source => params[:stripeToken]
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
charge = Stripe::Charge.create(
|
# charge = Stripe::Charge.create(
|
||||||
:customer => customer.id,
|
# :customer => customer.id,
|
||||||
:amount => 1000,
|
# :amount => 1000,
|
||||||
:description => 'Consumer Defender',
|
# :description => 'Consumer Defender',
|
||||||
:currency => 'aud'
|
# :currency => 'aud'
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
BadgeGranter.grant(badge, current_user)
|
# BadgeGranter.grant(badge, current_user)
|
||||||
|
|
||||||
render :json => { status: 'OK' }
|
render :json => { status: 'OK' }
|
||||||
end
|
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
|
Choice::Engine.routes.draw do
|
||||||
get 'stripe' => 'choice#create'
|
resources :choice, only: [:create]
|
||||||
get 'choice-form' => 'choice#index'
|
|
||||||
get 'users/:username/payments' => 'choice#show'
|
get 'users/:username/payments' => 'choice#show'
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
module Choice
|
module Choice
|
||||||
RSpec.describe 'ChoiceController', type: :controller do
|
RSpec.describe ChoiceController, type: :controller do
|
||||||
it do
|
routes { Choice::Engine.routes }
|
||||||
expect(Choice::ChoiceController).to be_truthy
|
|
||||||
|
it 'responds with ok' do
|
||||||
|
post :create
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user