diff --git a/README.md b/README.md index dd4d351..0cdb751 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Accept donations from visitors to your [Discourse](https://www.discourse.org/) f ## TODO * Handle custom fields -* Acceptance test in RSpec not qunit. ## Tested Credit Card Numbers diff --git a/spec/controllers/discourse_donations/charges_controller_spec.rb b/spec/controllers/discourse_donations/charges_controller_spec.rb index de46675..1d8c97c 100644 --- a/spec/controllers/discourse_donations/charges_controller_spec.rb +++ b/spec/controllers/discourse_donations/charges_controller_spec.rb @@ -35,56 +35,7 @@ module DiscourseDonations it 'responds ok for anonymous users' do controller.expects(:current_user).at_least(1).returns(user) - customer = { - "id": "cus_FhHJDzf0OxYtb8", - "object": "customer", - "account_balance": 0, - "address": "null", - "balance": 0, - "created": 1566866533, - "currency": "usd", - "default_source": "null", - "delinquent": false, - "description": "null", - "discount": "null", - "email": "null", - "invoice_prefix": "0BBF354", - "invoice_settings": { - "custom_fields": "null", - "default_payment_method": "null", - "footer": "null" - }, - "livemode": false, - "metadata": {}, - "name": "null", - "phone": "null", - "preferred_locales": [], - "shipping": "null", - "sources": { - "object": "list", - "data": [], - "has_more": false, - "total_count": 0, - "url": "/v1/customers/cus_FhHJDzf0OxYtb8/sources" - }, - "subscriptions": { - "object": "list", - "data": [], - "has_more": false, - "total_count": 0, - "url": "/v1/customers/cus_FhHJDzf0OxYtb8/subscriptions" - }, - "tax_exempt": "none", - "tax_ids": { - "object": "list", - "data": [], - "has_more": false, - "total_count": 0, - "url": "/v1/customers/cus_FhHJDzf0OxYtb8/tax_ids" - }, - "tax_info": "null", - "tax_info_verification": "null" - } + customer = Fabricate(:customer) stub_request(:get, /v1\/customers/).to_return(status: 200, body: customer.to_json) diff --git a/spec/fabricators/customer_fabricator.rb b/spec/fabricators/customer_fabricator.rb new file mode 100644 index 0000000..65c28e8 --- /dev/null +++ b/spec/fabricators/customer_fabricator.rb @@ -0,0 +1,60 @@ + + +class Customer + attr_accessor :to_json +end + +Fabricator(:customer) do + response = { + "id": "cus_FhHJDzf0OxYtb8", + "object": "customer", + "account_balance": 0, + "address": "null", + "balance": 0, + "created": 1566866533, + "currency": "usd", + "default_source": "null", + "delinquent": false, + "description": "null", + "discount": "null", + "email": "null", + "invoice_prefix": "0BBF354", + "invoice_settings": { + "custom_fields": "null", + "default_payment_method": "null", + "footer": "null" + }, + "livemode": false, + "metadata": {}, + "name": "null", + "phone": "null", + "preferred_locales": [], + "shipping": "null", + "sources": { + "object": "list", + "data": [], + "has_more": false, + "total_count": 0, + "url": "/v1/customers/cus_FhHJDzf0OxYtb8/sources" + }, + "subscriptions": { + "object": "list", + "data": [], + "has_more": false, + "total_count": 0, + "url": "/v1/customers/cus_FhHJDzf0OxYtb8/subscriptions" + }, + "tax_exempt": "none", + "tax_ids": { + "object": "list", + "data": [], + "has_more": false, + "total_count": 0, + "url": "/v1/customers/cus_FhHJDzf0OxYtb8/tax_ids" + }, + "tax_info": "null", + "tax_info_verification": "null" + }.to_json + + to_json response +end diff --git a/spec/plugin_helper.rb b/spec/plugin_helper.rb new file mode 100644 index 0000000..e3ed7b0 --- /dev/null +++ b/spec/plugin_helper.rb @@ -0,0 +1,2 @@ + +require_relative './fabricators/customer_fabricator.rb'