From 6902221939660bf96fcb34f07ba9990e51d56a75 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 09:56:11 +1100 Subject: [PATCH 1/7] proper file extension for acceptance test --- ...discourse-payments-test.es6 => discourse-payments-test.js.es6} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/javascripts/acceptance/{discourse-payments-test.es6 => discourse-payments-test.js.es6} (100%) diff --git a/test/javascripts/acceptance/discourse-payments-test.es6 b/test/javascripts/acceptance/discourse-payments-test.js.es6 similarity index 100% rename from test/javascripts/acceptance/discourse-payments-test.es6 rename to test/javascripts/acceptance/discourse-payments-test.js.es6 From a8dc1e409986c1f3ce67e617355bc8ebf45a90a1 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 10:28:29 +1100 Subject: [PATCH 2/7] document test runner --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0ec5804..c0a4414 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,11 @@ STRIPE_PUBLISHABLE_KEY: 'my_publishable_key' ## Testing -To run the specs, install the plugin and run `bundle exec rake plugin:spec[discourse-payments]` in the discourse root directory. +To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-payments]` in the discourse root directory. -If you're using a zsh shell, then you probably get this error: `zsh: no matches found ...` and you'll need to escape the square brackets with backslashes. +To run qunit tests: `MODULE='Acceptance: Discourse Payments' rake qunit:test[20000]`. -Run the local js acceptance tests here: +**Note:** -http://localhost:3000/qunit?module=Acceptance%3A%20Discourse%20Payments +* [This fix](https://github.com/discourse/discourse/pull/4719) is required to run qunit test modules. +* If you're using a zsh shell, then you probably get this error: `zsh: no matches found ...` and you'll need to escape the square brackets with backslashes. From 8cabbc7ac90196580f2b7ed8e0c1954d515ea567 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Fri, 24 Feb 2017 12:12:28 +1100 Subject: [PATCH 3/7] initital test --- .../components/stripe-card-test.js.es6 | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/javascripts/components/stripe-card-test.js.es6 diff --git a/test/javascripts/components/stripe-card-test.js.es6 b/test/javascripts/components/stripe-card-test.js.es6 new file mode 100644 index 0000000..f8bb839 --- /dev/null +++ b/test/javascripts/components/stripe-card-test.js.es6 @@ -0,0 +1,32 @@ +import componentTest from 'helpers/component-test'; + +moduleForComponent('stripe-card', { integration: true }); + +componentTest('stripe card', { + template: `{{stripe-card}}`, + + setup() { + // var spy = this.spy(); + sandbox.spy(); + }, + + test(assert) { + assert.ok(true); + } +}); + + +// componentTest("should call all subscribers when exceptions", function () { +// var myAPI = { method: function () {} }; +// +// var spy = this.spy(); +// var mock = this.mock(myAPI); +// mock.expects("method").once().throws(); +// +// PubSub.subscribe("message", myAPI.method); +// PubSub.subscribe("message", spy); +// PubSub.publishSync("message", undefined); +// +// mock.verify(); +// ok(spy.calledOnce); +// }); From f0228b9d5a6a38d73ec9636a6a69a7027ea2685c Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 28 Feb 2017 13:36:41 +1100 Subject: [PATCH 4/7] enable settings --- plugin.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 3d15dc2..bb5c5ce 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.7 +# version: 1.6.8 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins @@ -8,6 +8,8 @@ gem 'stripe', '2.0.1' load File.expand_path('../lib/discourse_donations/engine.rb', __FILE__) +enabled_site_setting :discourse_donations_enabled + after_initialize do header_script = '' From 751274244d6177e97cec90c5ba5a82ae9df784c3 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 2 Mar 2017 09:35:06 +1100 Subject: [PATCH 5/7] component test runs but does not really test anything --- .../components/stripe-card-test.js.es6 | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/test/javascripts/components/stripe-card-test.js.es6 b/test/javascripts/components/stripe-card-test.js.es6 index f8bb839..2156a1b 100644 --- a/test/javascripts/components/stripe-card-test.js.es6 +++ b/test/javascripts/components/stripe-card-test.js.es6 @@ -2,31 +2,23 @@ import componentTest from 'helpers/component-test'; moduleForComponent('stripe-card', { integration: true }); +window.Stripe = function() { + return { + elements: function() { + return { + create: function() { + return { + mount: function() {} + }; + } + }; + }, + }; +}; + componentTest('stripe card', { template: `{{stripe-card}}`, - - setup() { - // var spy = this.spy(); - sandbox.spy(); - }, - test(assert) { assert.ok(true); } }); - - -// componentTest("should call all subscribers when exceptions", function () { -// var myAPI = { method: function () {} }; -// -// var spy = this.spy(); -// var mock = this.mock(myAPI); -// mock.expects("method").once().throws(); -// -// PubSub.subscribe("message", myAPI.method); -// PubSub.subscribe("message", spy); -// PubSub.publishSync("message", undefined); -// -// mock.verify(); -// ok(spy.calledOnce); -// }); From 22bda5bf0fcdd5282e5a91b59b05fa84a488f3e7 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 2 Mar 2017 09:38:33 +1100 Subject: [PATCH 6/7] document running it in the readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb4615a..389dffd 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ Visit `/admin/plugins` and configure your private and public keys. ## Testing -To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-donations]` in the discourse root directory. - -To run qunit tests: `MODULE='Acceptance: Discourse Donations' bundle exec rake qunit:test[20000]`. +* To run the rails specs, install the plugin and run `bundle exec rake plugin:spec[discourse-donations]` in the discourse root directory. +* To run qunit tests: `MODULE='Acceptance: Discourse Donations' bundle exec rake qunit:test[20000]`. +* To run Component tests: `MODULE='component:stripe-card' bundle exec rake qunit:test[20000]`. **Note:** From 8eea4337afb782fe968319066b12e1356f735d78 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 2 Mar 2017 16:39:05 +1100 Subject: [PATCH 7/7] use jquery to render a link where there is no plugin outlet --- .../connectors/user-profile-primary/link.hbs | 5 ----- plugin.rb | 12 ++++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs diff --git a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs b/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs deleted file mode 100644 index 6fb4ef1..0000000 --- a/assets/javascripts/discourse/templates/connectors/user-profile-primary/link.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{#if siteSettings.discourse_donations_enabled}} -
- Donate -
-{{/if}} diff --git a/plugin.rb b/plugin.rb index bb5c5ce..89aa6d9 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,6 +1,6 @@ # name: discourse-donations # about: Integrating Discourse with Stripe for donations -# version: 1.6.8 +# version: 1.7.0 # url: https://github.com/choiceaustralia/discourse-donations # authors: Rimian Perkins @@ -11,7 +11,15 @@ load File.expand_path('../lib/discourse_donations/engine.rb', __FILE__) enabled_site_setting :discourse_donations_enabled after_initialize do - header_script = '' + header_script = <<-EOF.strip_heredoc.chomp + + +EOF discourse_donations_customization = SiteCustomization.find_or_create_by({ name: 'Discourse Donations Header',