diff --git a/README.md b/README.md index 12f8179..487cf6a 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,9 @@ Enables stripe payments from discourse. # Configuration You can either set your environment vars in docker or save them in a yaml. + +# Testing + +Run the local js acceptance tests here: + +http://localhost:3000/qunit?module=Acceptance%3A%20Choice%20Discourse diff --git a/app/controllers/choice/choice_controller.rb b/app/controllers/choice/choice_controller.rb index 174d625..3a18470 100644 --- a/app/controllers/choice/choice_controller.rb +++ b/app/controllers/choice/choice_controller.rb @@ -1,5 +1,9 @@ module Choice - class ChoiceController < Choice::ApplicationController + class ChoiceController < ApplicationController + def index + render json: {} + end + def create badge = Badge.find_by_name('Consumer Defender') diff --git a/assets/javascripts/discourse/choice-discourse-route-map.js.es6 b/assets/javascripts/discourse/choice-discourse-route-map.js.es6 new file mode 100644 index 0000000..70ce90a --- /dev/null +++ b/assets/javascripts/discourse/choice-discourse-route-map.js.es6 @@ -0,0 +1,5 @@ +export default function() { + this.route('choice', function() { + this.route('form'); + }); +} diff --git a/assets/javascripts/discourse/routes/choice-discourse-index.js.es6 b/assets/javascripts/discourse/routes/choice-discourse-index.js.es6 new file mode 100644 index 0000000..2f0c6fa --- /dev/null +++ b/assets/javascripts/discourse/routes/choice-discourse-index.js.es6 @@ -0,0 +1,7 @@ +import { ajax } from 'discourse/lib/ajax'; + +export default Ember.Route.extend({ + model() { + return ajax('/choice/form.json'); + } +}); diff --git a/assets/javascripts/discourse/templates/choice/form.hbs b/assets/javascripts/discourse/templates/choice/form.hbs new file mode 100644 index 0000000..25be4e8 --- /dev/null +++ b/assets/javascripts/discourse/templates/choice/form.hbs @@ -0,0 +1 @@ +

Choice

diff --git a/config/routes.rb b/config/routes.rb index 2ac4f6f..38fba08 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,4 @@ Choice::Engine.routes.draw do get 'stripe' => 'choice#create' + get 'form' => 'choice#index' end diff --git a/plugin.rb b/plugin.rb index 35a292d..75b8e76 100644 --- a/plugin.rb +++ b/plugin.rb @@ -19,8 +19,6 @@ module ::Choice end end -after_initialize do - Discourse::Application.routes.prepend do - mount ::Choice::Engine, at: '/choice' - end +Discourse::Application.routes.prepend do + mount ::Choice::Engine, at: '/choice' end diff --git a/test/javascripts/acceptance/choice-discourse-test.es6 b/test/javascripts/acceptance/choice-discourse-test.es6 new file mode 100644 index 0000000..86fe17d --- /dev/null +++ b/test/javascripts/acceptance/choice-discourse-test.es6 @@ -0,0 +1,10 @@ +import { acceptance } from 'helpers/qunit-helpers'; +acceptance('Choice Discourse', { loggedIn: true }); + +test('Choice Page Exists', () => { + visit('/choice/form'); + + andThen(() => { + ok(exists('h1'), 'Choice'); + }); +});