diff --git a/README.md b/README.md
index 9ee5567..0a345a8 100644
--- a/README.md
+++ b/README.md
@@ -9,3 +9,7 @@ Enables stripe payments from discourse.
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%20Discourse%20Payments
diff --git a/app/controllers/choice/choice_controller.rb b/app/controllers/choice/choice_controller.rb
index 174d625..235b0f1 100644
--- a/app/controllers/choice/choice_controller.rb
+++ b/app/controllers/choice/choice_controller.rb
@@ -1,5 +1,13 @@
module Choice
- class ChoiceController < Choice::ApplicationController
+ class ChoiceController < ApplicationController
+ def index
+ render json: {}
+ end
+
+ def show
+ render json: {}
+ end
+
def create
badge = Badge.find_by_name('Consumer Defender')
diff --git a/assets/javascripts/discourse/controllers/choice-form.js.es6 b/assets/javascripts/discourse/controllers/choice-form.js.es6
new file mode 100644
index 0000000..55838fc
--- /dev/null
+++ b/assets/javascripts/discourse/controllers/choice-form.js.es6
@@ -0,0 +1,8 @@
+
+export default Ember.Controller.extend({
+ actions: {
+ someThing: function() {
+ console.log('w00t! something happened!');
+ }
+ }
+});
diff --git a/assets/javascripts/discourse/controllers/user-payments.js.es6 b/assets/javascripts/discourse/controllers/user-payments.js.es6
new file mode 100644
index 0000000..2c83645
--- /dev/null
+++ b/assets/javascripts/discourse/controllers/user-payments.js.es6
@@ -0,0 +1,11 @@
+export default Ember.Controller.extend({
+ user: Ember.inject.controller(),
+ username: Ember.computed.alias('user.model.username_lower'),
+ email: Ember.computed.alias('user.model.email'),
+
+ actions: {
+ choiceTest: function() {
+ this.set('saved', true);
+ }
+ }
+});
diff --git a/assets/javascripts/discourse/discourse-payments-route-map.js.es6 b/assets/javascripts/discourse/discourse-payments-route-map.js.es6
new file mode 100644
index 0000000..168646c
--- /dev/null
+++ b/assets/javascripts/discourse/discourse-payments-route-map.js.es6
@@ -0,0 +1,6 @@
+export default {
+ resource: 'user',
+ map() {
+ this.route('payments');
+ }
+};
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/connectors/user-profile-primary/link.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs
new file mode 100644
index 0000000..6c4e8b2
--- /dev/null
+++ b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs
@@ -0,0 +1,4 @@
+
+
diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs
deleted file mode 100644
index b71e57c..0000000
--- a/assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
diff --git a/assets/javascripts/discourse/templates/user/payments.hbs b/assets/javascripts/discourse/templates/user/payments.hbs
new file mode 100644
index 0000000..05ab7e8
--- /dev/null
+++ b/assets/javascripts/discourse/templates/user/payments.hbs
@@ -0,0 +1,11 @@
+
+ {{username}}
+
+
+
+
+{{#if saved}}
+ Response happens
+{{/if}}
diff --git a/config/routes.rb b/config/routes.rb
index 2ac4f6f..ca9e6c6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,5 @@
Choice::Engine.routes.draw do
get 'stripe' => 'choice#create'
+ get 'choice-form' => 'choice#index'
+ get 'users/:username/payments' => 'choice#show'
end
diff --git a/config/stripe.rb b/config/stripe.rb
new file mode 100644
index 0000000..e46179d
--- /dev/null
+++ b/config/stripe.rb
@@ -0,0 +1,6 @@
+Rails.configuration.stripe = {
+ :publishable_key => ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.config_for(:stripe)['publishable_key'],
+ :secret_key => ENV['STRIPE_SECRET_KEY'] || Rails.application.config_for(:stripe)['secret_key']
+}
+
+Stripe.api_key = Rails.configuration.stripe[:secret_key]
diff --git a/jsapp b/jsapp
new file mode 120000
index 0000000..1096875
--- /dev/null
+++ b/jsapp
@@ -0,0 +1 @@
+assets/javascripts/discourse
\ No newline at end of file
diff --git a/lib/choice-discourse/engine.rb b/lib/choice-discourse/engine.rb
new file mode 100644
index 0000000..d5aa639
--- /dev/null
+++ b/lib/choice-discourse/engine.rb
@@ -0,0 +1,6 @@
+module ::Choice
+ class Engine < ::Rails::Engine
+ engine_name 'choice'
+ isolate_namespace Choice
+ end
+end
diff --git a/plugin.rb b/plugin.rb
index 068d382..8255345 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -1,21 +1,12 @@
# name: choice-plugin
# about: Integrating Discourse with Stripe
-# version: 0.1.0
-# authors: Rimian Perkins
+# version: 1.0.1
+# url: https://github.com/choiceaustralia/choice-discourse
gem 'stripe', '1.58.0'
-Rails.configuration.stripe = {
- :publishable_key => ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.config_for(:stripe)['publishable_key'],
- :secret_key => ENV['STRIPE_SECRET_KEY'] || Rails.application.config_for(:stripe)['secret_key']
-}
+load File.expand_path('../lib/choice-discourse/engine.rb', __FILE__)
-Stripe.api_key = Rails.configuration.stripe[:secret_key]
-
-require File.expand_path('../lib/choice/engine', __FILE__)
-
-after_initialize do
- Discourse::Application.routes.prepend do
- mount ::Choice::Engine, at: '/choice'
- end
+Discourse::Application.routes.prepend do
+ mount ::Choice::Engine, at: '/'
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..2bc6a93
--- /dev/null
+++ b/test/javascripts/acceptance/choice-discourse-test.es6
@@ -0,0 +1,29 @@
+import { acceptance } from 'helpers/qunit-helpers';
+acceptance('Discourse Payments', { loggedIn: true });
+
+test('Payments Link Exists', () => {
+ visit('/users/eviltrout');
+
+ andThen(() => {
+ ok(exists('.discourse-payments > a'), 'Link exists on profile page');
+ });
+});
+
+test('Payments Page Exists', () => {
+ visit('/users/eviltrout/payments');
+
+ andThen(() => {
+ ok(exists('h1'), 'Heading exists');
+ ok($.trim($('.payments').text()) == 'eviltrout', 'username is present on page');
+ });
+});
+
+test('Payments Page response happens', () => {
+ visit('/users/eviltrout/payments');
+
+ click('.choice-btn');
+
+ andThen(() => {
+ ok(exists('.choice-response'), 'Response happens');
+ });
+});