From 3e9d32e21dae37f244356980502dabc018161909 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 6 Feb 2017 12:29:24 +1100 Subject: [PATCH 01/17] ignore byebug --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e47225f..836dac5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .DS_Store gems +log +.byebug_history From 8d7b50a7aebbc8785fcaa38b623918ee5bb220c8 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 7 Feb 2017 13:56:22 +1100 Subject: [PATCH 02/17] inital empty page --- README.md | 6 ++++++ app/controllers/choice/choice_controller.rb | 6 +++++- .../discourse/choice-discourse-route-map.js.es6 | 5 +++++ .../discourse/routes/choice-discourse-index.js.es6 | 7 +++++++ assets/javascripts/discourse/templates/choice/form.hbs | 1 + config/routes.rb | 1 + plugin.rb | 6 ++---- test/javascripts/acceptance/choice-discourse-test.es6 | 10 ++++++++++ 8 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 assets/javascripts/discourse/choice-discourse-route-map.js.es6 create mode 100644 assets/javascripts/discourse/routes/choice-discourse-index.js.es6 create mode 100644 assets/javascripts/discourse/templates/choice/form.hbs create mode 100644 test/javascripts/acceptance/choice-discourse-test.es6 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'); + }); +}); From 02d15d486a1bf99eae785e81c9b050417fe0c138 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 7 Feb 2017 14:23:38 +1100 Subject: [PATCH 03/17] initial form --- .../javascripts/discourse/templates/choice/form.hbs | 13 +++++++++++++ .../acceptance/choice-discourse-test.es6 | 1 + 2 files changed, 14 insertions(+) diff --git a/assets/javascripts/discourse/templates/choice/form.hbs b/assets/javascripts/discourse/templates/choice/form.hbs index 25be4e8..5ef4961 100644 --- a/assets/javascripts/discourse/templates/choice/form.hbs +++ b/assets/javascripts/discourse/templates/choice/form.hbs @@ -1 +1,14 @@

Choice

+ +
+ +
+
+ {{text-field}} +
+
+ +
+
+ +
diff --git a/test/javascripts/acceptance/choice-discourse-test.es6 b/test/javascripts/acceptance/choice-discourse-test.es6 index 86fe17d..f84736b 100644 --- a/test/javascripts/acceptance/choice-discourse-test.es6 +++ b/test/javascripts/acceptance/choice-discourse-test.es6 @@ -6,5 +6,6 @@ test('Choice Page Exists', () => { andThen(() => { ok(exists('h1'), 'Choice'); + ok(exists('form'), 'Something'); }); }); From 6d3ad0268ed32f490827f05e652ed72c47f69911 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 7 Feb 2017 16:03:00 +1100 Subject: [PATCH 04/17] an action happens when the button is clicked yo --- .../javascripts/discourse/controllers/choice-form.js.es6 | 8 ++++++++ assets/javascripts/discourse/templates/choice/form.hbs | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 assets/javascripts/discourse/controllers/choice-form.js.es6 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/templates/choice/form.hbs b/assets/javascripts/discourse/templates/choice/form.hbs index 5ef4961..18294ba 100644 --- a/assets/javascripts/discourse/templates/choice/form.hbs +++ b/assets/javascripts/discourse/templates/choice/form.hbs @@ -3,11 +3,11 @@
-
+
{{text-field}}
-
- +
+
From b2321ba965d5ad3aae5e2660304d665ff9ec97a2 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 9 Feb 2017 12:17:25 +1100 Subject: [PATCH 05/17] move payment button into choice page and make a link --- .../discourse/templates/choice/form.hbs | 21 ++++++++++++++++--- .../user-profile-primary/stripe.hbs | 17 +-------------- lib/choice-discourse/engine.rb | 6 ++++++ plugin.rb | 9 ++------ 4 files changed, 27 insertions(+), 26 deletions(-) create mode 100644 lib/choice-discourse/engine.rb diff --git a/assets/javascripts/discourse/templates/choice/form.hbs b/assets/javascripts/discourse/templates/choice/form.hbs index 18294ba..8066f03 100644 --- a/assets/javascripts/discourse/templates/choice/form.hbs +++ b/assets/javascripts/discourse/templates/choice/form.hbs @@ -3,12 +3,27 @@
-
- {{text-field}} -
+ +

Stripe Payments

+ +
+ +
diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs index b71e57c..0482ca9 100644 --- a/assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs +++ b/assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs @@ -1,17 +1,2 @@ - -
- -
+Choice page 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 75b8e76..00594b5 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: choice-plugin # about: Integrating Discourse with Stripe -# version: 0.0.3 +# version: 0.1.0 # authors: Rimian Perkins gem 'stripe', '1.58.0' @@ -12,12 +12,7 @@ Rails.configuration.stripe = { Stripe.api_key = Rails.configuration.stripe[:secret_key] -module ::Choice - class Engine < ::Rails::Engine - engine_name 'choice' - isolate_namespace Choice - end -end +load File.expand_path('../lib/choice-discourse/engine.rb', __FILE__) Discourse::Application.routes.prepend do mount ::Choice::Engine, at: '/choice' From 90ed0e03dfe48b2d88539533570434ecb27eb47d Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 10 Feb 2017 12:11:59 +1100 Subject: [PATCH 06/17] rename the component --- .../connectors/user-profile-primary/{stripe.hbs => link.hbs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename assets/javascripts/discourse/templates/connectors/user-profile-primary/{stripe.hbs => link.hbs} (100%) diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs similarity index 100% rename from assets/javascripts/discourse/templates/connectors/user-profile-primary/stripe.hbs rename to assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs From c0529c5bdb16857b819db431a0505b0bf255f67d Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 10 Feb 2017 15:10:47 +1100 Subject: [PATCH 07/17] a child page at user/:username/choice --- app/controllers/choice/choice_controller.rb | 4 ++++ .../discourse/choice-discourse-route-map.js.es6 | 11 ++++++----- .../discourse/controllers/user-choice.js.es6 | 5 +++++ .../connectors/user-profile-primary/link.hbs | 2 +- .../discourse/templates/user/choice.hbs | 1 + config/routes.rb | 3 ++- plugin.rb | 2 +- .../acceptance/choice-discourse-test.es6 | 16 ++++++++-------- 8 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 assets/javascripts/discourse/controllers/user-choice.js.es6 create mode 100644 assets/javascripts/discourse/templates/user/choice.hbs diff --git a/app/controllers/choice/choice_controller.rb b/app/controllers/choice/choice_controller.rb index 3a18470..235b0f1 100644 --- a/app/controllers/choice/choice_controller.rb +++ b/app/controllers/choice/choice_controller.rb @@ -4,6 +4,10 @@ module Choice render json: {} end + def show + 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 index 70ce90a..874ea87 100644 --- a/assets/javascripts/discourse/choice-discourse-route-map.js.es6 +++ b/assets/javascripts/discourse/choice-discourse-route-map.js.es6 @@ -1,5 +1,6 @@ -export default function() { - this.route('choice', function() { - this.route('form'); - }); -} +export default { + resource: 'user', + map() { + this.route('choice'); + } +}; diff --git a/assets/javascripts/discourse/controllers/user-choice.js.es6 b/assets/javascripts/discourse/controllers/user-choice.js.es6 new file mode 100644 index 0000000..e2a30bf --- /dev/null +++ b/assets/javascripts/discourse/controllers/user-choice.js.es6 @@ -0,0 +1,5 @@ +export default Ember.Controller.extend({ + user: Ember.inject.controller(), + username: Ember.computed.alias('user.model.username_lower'), + email: Ember.computed.alias('user.model.email'), +}); diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs index 0482ca9..c9fc1d1 100644 --- a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs +++ b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs @@ -1,2 +1,2 @@ -Choice page +Choice payments page diff --git a/assets/javascripts/discourse/templates/user/choice.hbs b/assets/javascripts/discourse/templates/user/choice.hbs new file mode 100644 index 0000000..8c6893e --- /dev/null +++ b/assets/javascripts/discourse/templates/user/choice.hbs @@ -0,0 +1 @@ +{{email}} diff --git a/config/routes.rb b/config/routes.rb index 38fba08..6acee15 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Choice::Engine.routes.draw do get 'stripe' => 'choice#create' - get 'form' => 'choice#index' + get 'choice-form' => 'choice#index' + get 'users/:username/choice' => 'choice#show' end diff --git a/plugin.rb b/plugin.rb index 00594b5..18bef27 100644 --- a/plugin.rb +++ b/plugin.rb @@ -15,5 +15,5 @@ Stripe.api_key = Rails.configuration.stripe[:secret_key] load File.expand_path('../lib/choice-discourse/engine.rb', __FILE__) Discourse::Application.routes.prepend do - mount ::Choice::Engine, at: '/choice' + mount ::Choice::Engine, at: '/' end diff --git a/test/javascripts/acceptance/choice-discourse-test.es6 b/test/javascripts/acceptance/choice-discourse-test.es6 index f84736b..cb270d1 100644 --- a/test/javascripts/acceptance/choice-discourse-test.es6 +++ b/test/javascripts/acceptance/choice-discourse-test.es6 @@ -1,11 +1,11 @@ import { acceptance } from 'helpers/qunit-helpers'; acceptance('Choice Discourse', { loggedIn: true }); -test('Choice Page Exists', () => { - visit('/choice/form'); - - andThen(() => { - ok(exists('h1'), 'Choice'); - ok(exists('form'), 'Something'); - }); -}); +// test('Choice Page Exists', () => { +// visit('/user'); +// +// andThen(() => { +// ok(exists('h1'), 'Choice'); +// ok(exists('form'), 'Something'); +// }); +// }); From f5cf206bce2e9860071a94ff18152351f9c02fd5 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 10 Feb 2017 15:13:51 +1100 Subject: [PATCH 08/17] bump yo --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 18bef27..e188430 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: choice-plugin # about: Integrating Discourse with Stripe -# version: 0.1.0 +# version: 0.2.0 # authors: Rimian Perkins gem 'stripe', '1.58.0' From 800aef7b3f8b8f62e5848354a30f76ce33397b88 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 13 Feb 2017 11:35:59 +1100 Subject: [PATCH 09/17] acceptacnce test verifies page renders --- .../discourse/templates/user/choice.hbs | 4 +++- jsapp | 1 + .../acceptance/choice-discourse-test.es6 | 16 ++++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) create mode 120000 jsapp diff --git a/assets/javascripts/discourse/templates/user/choice.hbs b/assets/javascripts/discourse/templates/user/choice.hbs index 8c6893e..e8862bf 100644 --- a/assets/javascripts/discourse/templates/user/choice.hbs +++ b/assets/javascripts/discourse/templates/user/choice.hbs @@ -1 +1,3 @@ -{{email}} +
+ {{username}} +
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/test/javascripts/acceptance/choice-discourse-test.es6 b/test/javascripts/acceptance/choice-discourse-test.es6 index cb270d1..20ec173 100644 --- a/test/javascripts/acceptance/choice-discourse-test.es6 +++ b/test/javascripts/acceptance/choice-discourse-test.es6 @@ -1,11 +1,11 @@ import { acceptance } from 'helpers/qunit-helpers'; acceptance('Choice Discourse', { loggedIn: true }); -// test('Choice Page Exists', () => { -// visit('/user'); -// -// andThen(() => { -// ok(exists('h1'), 'Choice'); -// ok(exists('form'), 'Something'); -// }); -// }); +test('Choice Page Exists', () => { + visit('/users/eviltrout/choice'); + + andThen(() => { + ok(exists('h1'), 'Choice'); + ok(exists('.payments'), 'eviltrout'); + }); +}); From ac2d772843305a0650b708095a1b319e9610f2d2 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 13 Feb 2017 11:58:52 +1100 Subject: [PATCH 10/17] bump with user page changes --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index e188430..37a50b0 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: choice-plugin # about: Integrating Discourse with Stripe -# version: 0.2.0 +# version: 0.3.0 # authors: Rimian Perkins gem 'stripe', '1.58.0' From e32e7b9def7a603c2ebb6227ea3a3f4ebc306a0c Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 13 Feb 2017 13:50:48 +1100 Subject: [PATCH 11/17] fix assertion --- plugin.rb | 2 +- test/javascripts/acceptance/choice-discourse-test.es6 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin.rb b/plugin.rb index 37a50b0..6ec932d 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: choice-plugin # about: Integrating Discourse with Stripe -# version: 0.3.0 +# version: 0.3.1 # authors: Rimian Perkins gem 'stripe', '1.58.0' diff --git a/test/javascripts/acceptance/choice-discourse-test.es6 b/test/javascripts/acceptance/choice-discourse-test.es6 index 20ec173..f0bf4ee 100644 --- a/test/javascripts/acceptance/choice-discourse-test.es6 +++ b/test/javascripts/acceptance/choice-discourse-test.es6 @@ -5,7 +5,7 @@ test('Choice Page Exists', () => { visit('/users/eviltrout/choice'); andThen(() => { - ok(exists('h1'), 'Choice'); - ok(exists('.payments'), 'eviltrout'); + ok(exists('h1'), 'Heading exists'); + ok($.trim($('.payments').text()) == 'eviltrout', 'eviltrout'); }); }); From adeeea3fbb0de397fcd28bcf4b465169e16b4d72 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 13 Feb 2017 13:55:00 +1100 Subject: [PATCH 12/17] add url yo --- plugin.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 6ec932d..7288600 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,8 @@ # name: choice-plugin # about: Integrating Discourse with Stripe -# version: 0.3.1 +# version: 0.3.2 # authors: Rimian Perkins +# url: https://github.com/choiceaustralia/choice-discourse gem 'stripe', '1.58.0' From ed828a228bd3c8366a232fad04852b8374d7f1ab Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Mon, 13 Feb 2017 15:31:31 +1100 Subject: [PATCH 13/17] a response happened and there is a test --- .../discourse/controllers/user-choice.js.es6 | 6 ++++++ .../javascripts/discourse/templates/user/choice.hbs | 8 ++++++++ .../javascripts/acceptance/choice-discourse-test.es6 | 12 +++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/discourse/controllers/user-choice.js.es6 b/assets/javascripts/discourse/controllers/user-choice.js.es6 index e2a30bf..2c83645 100644 --- a/assets/javascripts/discourse/controllers/user-choice.js.es6 +++ b/assets/javascripts/discourse/controllers/user-choice.js.es6 @@ -2,4 +2,10 @@ 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/templates/user/choice.hbs b/assets/javascripts/discourse/templates/user/choice.hbs index e8862bf..05ab7e8 100644 --- a/assets/javascripts/discourse/templates/user/choice.hbs +++ b/assets/javascripts/discourse/templates/user/choice.hbs @@ -1,3 +1,11 @@
{{username}}
+ + + +{{#if saved}} +
Response happens
+{{/if}} diff --git a/test/javascripts/acceptance/choice-discourse-test.es6 b/test/javascripts/acceptance/choice-discourse-test.es6 index f0bf4ee..a4c15d9 100644 --- a/test/javascripts/acceptance/choice-discourse-test.es6 +++ b/test/javascripts/acceptance/choice-discourse-test.es6 @@ -6,6 +6,16 @@ test('Choice Page Exists', () => { andThen(() => { ok(exists('h1'), 'Heading exists'); - ok($.trim($('.payments').text()) == 'eviltrout', 'eviltrout'); + ok($.trim($('.payments').text()) == 'eviltrout', 'username is present on page'); + }); +}); + +test('Choice Page response happens', () => { + visit('/users/eviltrout/choice'); + + click('.choice-btn'); + + andThen(() => { + ok(exists('.choice-response'), 'Response happens'); }); }); From 3f32c212d87ebf5705222f4067ed8b6af7455b5f Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 14 Feb 2017 10:11:10 +1100 Subject: [PATCH 14/17] rename to "payments" --- .../javascripts/discourse/choice-discourse-route-map.js.es6 | 2 +- .../{user-choice.js.es6 => user-payments.js.es6} | 0 .../templates/connectors/user-profile-primary/link.hbs | 2 +- .../discourse/templates/user/{choice.hbs => payments.hbs} | 0 plugin.rb | 2 +- test/javascripts/acceptance/choice-discourse-test.es6 | 6 +++--- 6 files changed, 6 insertions(+), 6 deletions(-) rename assets/javascripts/discourse/controllers/{user-choice.js.es6 => user-payments.js.es6} (100%) rename assets/javascripts/discourse/templates/user/{choice.hbs => payments.hbs} (100%) diff --git a/assets/javascripts/discourse/choice-discourse-route-map.js.es6 b/assets/javascripts/discourse/choice-discourse-route-map.js.es6 index 874ea87..168646c 100644 --- a/assets/javascripts/discourse/choice-discourse-route-map.js.es6 +++ b/assets/javascripts/discourse/choice-discourse-route-map.js.es6 @@ -1,6 +1,6 @@ export default { resource: 'user', map() { - this.route('choice'); + this.route('payments'); } }; diff --git a/assets/javascripts/discourse/controllers/user-choice.js.es6 b/assets/javascripts/discourse/controllers/user-payments.js.es6 similarity index 100% rename from assets/javascripts/discourse/controllers/user-choice.js.es6 rename to assets/javascripts/discourse/controllers/user-payments.js.es6 diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs index c9fc1d1..beb8bb9 100644 --- a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs +++ b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs @@ -1,2 +1,2 @@ -Choice payments page +Payments page diff --git a/assets/javascripts/discourse/templates/user/choice.hbs b/assets/javascripts/discourse/templates/user/payments.hbs similarity index 100% rename from assets/javascripts/discourse/templates/user/choice.hbs rename to assets/javascripts/discourse/templates/user/payments.hbs diff --git a/plugin.rb b/plugin.rb index 7288600..194ef47 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: choice-plugin # about: Integrating Discourse with Stripe -# version: 0.3.2 +# version: 1.0.0 # authors: Rimian Perkins # url: https://github.com/choiceaustralia/choice-discourse diff --git a/test/javascripts/acceptance/choice-discourse-test.es6 b/test/javascripts/acceptance/choice-discourse-test.es6 index a4c15d9..31c37f7 100644 --- a/test/javascripts/acceptance/choice-discourse-test.es6 +++ b/test/javascripts/acceptance/choice-discourse-test.es6 @@ -1,8 +1,8 @@ import { acceptance } from 'helpers/qunit-helpers'; -acceptance('Choice Discourse', { loggedIn: true }); +acceptance('Discourse Payments', { loggedIn: true }); test('Choice Page Exists', () => { - visit('/users/eviltrout/choice'); + visit('/users/eviltrout/payments'); andThen(() => { ok(exists('h1'), 'Heading exists'); @@ -11,7 +11,7 @@ test('Choice Page Exists', () => { }); test('Choice Page response happens', () => { - visit('/users/eviltrout/choice'); + visit('/users/eviltrout/payments'); click('.choice-btn'); From 4eef7131edf0ba22878b3795b2ed6b5ff91224bb Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 14 Feb 2017 10:19:59 +1100 Subject: [PATCH 15/17] check payment link exists --- .../connectors/user-profile-primary/link.hbs | 4 +++- .../javascripts/acceptance/choice-discourse-test.es6 | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs index beb8bb9..6c4e8b2 100644 --- a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs +++ b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs @@ -1,2 +1,4 @@ -Payments page + diff --git a/test/javascripts/acceptance/choice-discourse-test.es6 b/test/javascripts/acceptance/choice-discourse-test.es6 index 31c37f7..2bc6a93 100644 --- a/test/javascripts/acceptance/choice-discourse-test.es6 +++ b/test/javascripts/acceptance/choice-discourse-test.es6 @@ -1,7 +1,15 @@ import { acceptance } from 'helpers/qunit-helpers'; acceptance('Discourse Payments', { loggedIn: true }); -test('Choice Page Exists', () => { +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(() => { @@ -10,7 +18,7 @@ test('Choice Page Exists', () => { }); }); -test('Choice Page response happens', () => { +test('Payments Page response happens', () => { visit('/users/eviltrout/payments'); click('.choice-btn'); From 99758dcaa90375be921da37b7b1a8f44e30bc42d Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 14 Feb 2017 10:28:07 +1100 Subject: [PATCH 16/17] change routes --- config/routes.rb | 2 +- config/stripe.rb | 6 ++++++ plugin.rb | 9 +-------- 3 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 config/stripe.rb diff --git a/config/routes.rb b/config/routes.rb index 6acee15..ca9e6c6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Choice::Engine.routes.draw do get 'stripe' => 'choice#create' get 'choice-form' => 'choice#index' - get 'users/:username/choice' => 'choice#show' + 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/plugin.rb b/plugin.rb index 194ef47..0609c17 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,18 +1,11 @@ # name: choice-plugin # about: Integrating Discourse with Stripe -# version: 1.0.0 +# version: 1.0.1 # authors: Rimian Perkins # 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'] -} - -Stripe.api_key = Rails.configuration.stripe[:secret_key] - load File.expand_path('../lib/choice-discourse/engine.rb', __FILE__) Discourse::Application.routes.prepend do From 12d606d1152c085f6f95971743c27a953f8deec7 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 14 Feb 2017 10:45:01 +1100 Subject: [PATCH 17/17] refactor route map --- ...s6 => discourse-payments-route-map.js.es6} | 0 .../discourse/templates/choice/form.hbs | 29 ------------------- 2 files changed, 29 deletions(-) rename assets/javascripts/discourse/{choice-discourse-route-map.js.es6 => discourse-payments-route-map.js.es6} (100%) delete mode 100644 assets/javascripts/discourse/templates/choice/form.hbs diff --git a/assets/javascripts/discourse/choice-discourse-route-map.js.es6 b/assets/javascripts/discourse/discourse-payments-route-map.js.es6 similarity index 100% rename from assets/javascripts/discourse/choice-discourse-route-map.js.es6 rename to assets/javascripts/discourse/discourse-payments-route-map.js.es6 diff --git a/assets/javascripts/discourse/templates/choice/form.hbs b/assets/javascripts/discourse/templates/choice/form.hbs deleted file mode 100644 index 8066f03..0000000 --- a/assets/javascripts/discourse/templates/choice/form.hbs +++ /dev/null @@ -1,29 +0,0 @@ -

Choice

- -
- -
-
- -
-
- -
- -

Stripe Payments

- -
- -