{"action":"created","issue":{"url":"https://api.github.com/repos/code-corps/ember-stripe-service/issues/12","repository_url":"https://api.github.com/repos/code-corps/ember-stripe-service","labels_url":"https://api.github.com/repos/code-corps/ember-stripe-service/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/code-corps/ember-stripe-service/issues/12/comments","events_url":"https://api.github.com/repos/code-corps/ember-stripe-service/issues/12/events","html_url":"https://github.com/code-corps/ember-stripe-service/issues/12","id":69361960,"number":12,"title":"Cannot use in (offline) tests","user":{"login":"jamesarosen","id":2406,"avatar_url":"https://avatars.githubusercontent.com/u/2406?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesarosen","html_url":"https://github.com/jamesarosen","followers_url":"https://api.github.com/users/jamesarosen/followers","following_url":"https://api.github.com/users/jamesarosen/following{/other_user}","gists_url":"https://api.github.com/users/jamesarosen/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesarosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesarosen/subscriptions","organizations_url":"https://api.github.com/users/jamesarosen/orgs","repos_url":"https://api.github.com/users/jamesarosen/repos","events_url":"https://api.github.com/users/jamesarosen/events{/privacy}","received_events_url":"https://api.github.com/users/jamesarosen/received_events","type":"User","site_admin":false},"labels":[{"id":170410301,"url":"https://api.github.com/repos/code-corps/ember-stripe-service/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2015-04-18T23:56:00Z","updated_at":"2017-01-19T04:34:31Z","closed_at":null,"body":"In test mode (at least in environments without networking), the `<script>` tag that this addon injects won't run and Stripe won't be defined. That means `Stripe.setPublishableKey` won't exist and the initializer will fail.\n\nThe smallest change I can think of that would work (which I've used locally successfully) is\n\n``` js\n// app/services/stripe.js\nfunction createToken (card) {\n  Ember.assert(\"Cannot create Stripe token in test environment\", config.environment !== 'test');\n  // ...\n}\n\n// app/initializers/stripe-service.js\nexport function initialize() {\n  if (config.environment === 'test') { return; }\n  // ...\n}\n```\n\nThis isn't perfect, but it's pretty good. I end up stubbing out `stripe.createToken` whenever I need to actually run that function, with without a standard stubbing library, I can't think of a good way of doing this here.\n"},"comment":{"url":"https://api.github.com/repos/code-corps/ember-stripe-service/issues/comments/273679952","html_url":"https://github.com/code-corps/ember-stripe-service/issues/12#issuecomment-273679952","issue_url":"https://api.github.com/repos/code-corps/ember-stripe-service/issues/12","id":273679952,"user":{"login":"davewasmer","id":707213,"avatar_url":"https://avatars.githubusercontent.com/u/707213?v=3","gravatar_id":"","url":"https://api.github.com/users/davewasmer","html_url":"https://github.com/davewasmer","followers_url":"https://api.github.com/users/davewasmer/followers","following_url":"https://api.github.com/users/davewasmer/following{/other_user}","gists_url":"https://api.github.com/users/davewasmer/gists{/gist_id}","starred_url":"https://api.github.com/users/davewasmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davewasmer/subscriptions","organizations_url":"https://api.github.com/users/davewasmer/orgs","repos_url":"https://api.github.com/users/davewasmer/repos","events_url":"https://api.github.com/users/davewasmer/events{/privacy}","received_events_url":"https://api.github.com/users/davewasmer/received_events","type":"User","site_admin":false},"created_at":"2017-01-19T04:34:31Z","updated_at":"2017-01-19T04:34:31Z","body":"I'd suggest that the initializer should also be robust to Stripe.js failing to load. If Stripe's JS CDN goes down for whatever reason, that shouldn't also take my entire app with it."}}
{"actor":{"display_login":"davewasmer"}}