workarea-klarna 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintrc.json +36 -0
  4. data/.github/workflows/ci.yml +61 -0
  5. data/.gitignore +24 -0
  6. data/.rubocop.yml +2 -0
  7. data/.stylelintrc.json +8 -0
  8. data/.yardopts +1 -0
  9. data/CHANGELOG.md +81 -0
  10. data/Gemfile +17 -0
  11. data/LICENSE +52 -0
  12. data/README.md +79 -0
  13. data/Rakefile +56 -0
  14. data/app/assets/javascripts/workarea/storefront/klarna/modules/klarna_widget.js +99 -0
  15. data/app/controllers/workarea/storefront/checkout/addresses_controller.decorator +8 -0
  16. data/app/controllers/workarea/storefront/checkout/place_order_controller.decorator +9 -0
  17. data/app/controllers/workarea/storefront/checkouts_controller.decorator +13 -0
  18. data/app/models/workarea/checkout/steps/payment.decorator +22 -0
  19. data/app/models/workarea/order.decorator +7 -0
  20. data/app/models/workarea/payment.decorator +34 -0
  21. data/app/models/workarea/payment/authorize/klarna.rb +21 -0
  22. data/app/models/workarea/payment/capture/klarna.rb +21 -0
  23. data/app/models/workarea/payment/klarna_session.rb +18 -0
  24. data/app/models/workarea/payment/purchase/klarna.rb +21 -0
  25. data/app/models/workarea/payment/refund/klarna.rb +18 -0
  26. data/app/models/workarea/payment/tender/klarna.rb +53 -0
  27. data/app/services/workarea/setup_klarna_session.rb +24 -0
  28. data/app/view_models/workarea/storefront/checkout/payment_view_model.decorator +41 -0
  29. data/app/views/workarea/admin/orders/tenders/_klarna.html.haml +4 -0
  30. data/app/views/workarea/storefront/checkouts/_klarna_payments.html.haml +22 -0
  31. data/app/views/workarea/storefront/klarna/_sdk.html.haml +2 -0
  32. data/app/views/workarea/storefront/order_mailer/tenders/_klarna.html.haml +2 -0
  33. data/app/views/workarea/storefront/orders/tenders/_klarna.html.haml +6 -0
  34. data/bin/rails +20 -0
  35. data/config/initializers/appends.rb +14 -0
  36. data/config/initializers/configuration.rb +32 -0
  37. data/config/initializers/fields.rb +43 -0
  38. data/config/locales/en.yml +30 -0
  39. data/config/routes.rb +2 -0
  40. data/lib/workarea/klarna.rb +30 -0
  41. data/lib/workarea/klarna/bogus_gateway.rb +19 -0
  42. data/lib/workarea/klarna/engine.rb +10 -0
  43. data/lib/workarea/klarna/gateway.rb +92 -0
  44. data/lib/workarea/klarna/gateway/cancel_request.rb +16 -0
  45. data/lib/workarea/klarna/gateway/capture_request.rb +24 -0
  46. data/lib/workarea/klarna/gateway/create_session_request.rb +22 -0
  47. data/lib/workarea/klarna/gateway/order.rb +249 -0
  48. data/lib/workarea/klarna/gateway/place_order_request.rb +34 -0
  49. data/lib/workarea/klarna/gateway/refund_request.rb +24 -0
  50. data/lib/workarea/klarna/gateway/release_request.rb +16 -0
  51. data/lib/workarea/klarna/gateway/request.rb +91 -0
  52. data/lib/workarea/klarna/gateway/response.rb +38 -0
  53. data/lib/workarea/klarna/gateway/update_session_request.rb +30 -0
  54. data/lib/workarea/klarna/version.rb +5 -0
  55. data/package.json +9 -0
  56. data/test/dummy/Rakefile +6 -0
  57. data/test/dummy/app/assets/config/manifest.js +4 -0
  58. data/test/dummy/app/assets/javascripts/application.js +13 -0
  59. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  60. data/test/dummy/app/controllers/application_controller.rb +3 -0
  61. data/test/dummy/app/helpers/application_helper.rb +2 -0
  62. data/test/dummy/app/jobs/application_job.rb +2 -0
  63. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  64. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  65. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  66. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  67. data/test/dummy/bin/bundle +3 -0
  68. data/test/dummy/bin/rails +4 -0
  69. data/test/dummy/bin/rake +4 -0
  70. data/test/dummy/bin/setup +34 -0
  71. data/test/dummy/bin/update +29 -0
  72. data/test/dummy/config.ru +5 -0
  73. data/test/dummy/config/application.rb +24 -0
  74. data/test/dummy/config/boot.rb +5 -0
  75. data/test/dummy/config/cable.yml +9 -0
  76. data/test/dummy/config/environment.rb +5 -0
  77. data/test/dummy/config/environments/development.rb +54 -0
  78. data/test/dummy/config/environments/production.rb +86 -0
  79. data/test/dummy/config/environments/test.rb +43 -0
  80. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  81. data/test/dummy/config/initializers/assets.rb +11 -0
  82. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  84. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  85. data/test/dummy/config/initializers/inflections.rb +16 -0
  86. data/test/dummy/config/initializers/mime_types.rb +4 -0
  87. data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
  88. data/test/dummy/config/initializers/workarea.rb +5 -0
  89. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  90. data/test/dummy/config/locales/en.yml +23 -0
  91. data/test/dummy/config/puma.rb +47 -0
  92. data/test/dummy/config/routes.rb +5 -0
  93. data/test/dummy/config/secrets.yml +22 -0
  94. data/test/dummy/config/spring.rb +6 -0
  95. data/test/dummy/db/seeds.rb +2 -0
  96. data/test/dummy/log/.keep +0 -0
  97. data/test/factories/workarea/klarna.rb +146 -0
  98. data/test/integration/workarea/storefront/klarna_session_integration_test.rb +40 -0
  99. data/test/lib/workarea/klarna/gateway/capture_request_test.rb +26 -0
  100. data/test/lib/workarea/klarna/gateway/create_session_request_test.rb +26 -0
  101. data/test/lib/workarea/klarna/gateway/order_test.rb +135 -0
  102. data/test/lib/workarea/klarna/gateway/place_order_request_test.rb +34 -0
  103. data/test/lib/workarea/klarna/gateway/refund_request_test.rb +26 -0
  104. data/test/lib/workarea/klarna/gateway/request_test.rb +87 -0
  105. data/test/lib/workarea/klarna/gateway/response_test.rb +75 -0
  106. data/test/lib/workarea/klarna/gateway/update_session_request_test.rb +27 -0
  107. data/test/lib/workarea/klarna/gateway_test.rb +58 -0
  108. data/test/models/workarea/checkout/steps/klarna_payment_test.rb +79 -0
  109. data/test/models/workarea/klarna_payment_test.rb +45 -0
  110. data/test/models/workarea/payment/authorize/klarna_test.rb +34 -0
  111. data/test/models/workarea/payment/capture/klarna_test.rb +51 -0
  112. data/test/models/workarea/payment/tender/klarna_test.rb +81 -0
  113. data/test/services/workarea/setup_klarna_session_test.rb +42 -0
  114. data/test/teaspoon_env.rb +6 -0
  115. data/test/test_helper.rb +10 -0
  116. data/test/vcr_cassettes/klarna_authorize.yml +62 -0
  117. data/test/vcr_cassettes/klarna_capture.yml +60 -0
  118. data/test/vcr_cassettes/klarna_create_session.yml +61 -0
  119. data/test/vcr_cassettes/klarna_refund.yml +60 -0
  120. data/test/view_models/workarea/storefront/checkout/klarna_payment_view_model_test.rb +62 -0
  121. data/workarea-klarna.gemspec +20 -0
  122. metadata +177 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a35826c1d47f935b8d5ebbb1a6f2fc3337be504e7120edf742c647e8d7eb6c7f
4
+ data.tar.gz: a2648778ca85ad42996fa7f9bf5c730826358b7786b98895d34c0b526b3a5e04
5
+ SHA512:
6
+ metadata.gz: 9272c87153840555efbd07912dd17afa1128997f36b7e7d4525db7e754e95df80195a6673eac3af03469fa5ee55c0eb2263cbb75ced854bc28e50a600b8d7aa2
7
+ data.tar.gz: 21b70955ce13278c77615cddfdb6e93ad0e1c5d8eed7d857585c8395e6a29ca52ff6b720af761f5efb09ec0f07cc25070956d94bef38b735e60240a42ea9c949
@@ -0,0 +1,20 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ end_of_line = lf
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [{*.rb,*.haml,*.decorator,*.yml,*.yaml,*.jbuilder}]
12
+ indent_size = 2
13
+ indent_style = space
14
+
15
+ [{*.js,*.jst,*.ejs,*.scss}]
16
+ indent_size = 4
17
+
18
+ [*.md]
19
+ indent_size = 4
20
+ trim_trailing_whitespace = false
@@ -0,0 +1,36 @@
1
+ {
2
+ "extends": "eslint:recommended",
3
+ "rules": {
4
+ "semi": ["error", "always"],
5
+ "eqeqeq": ["error", "always"]
6
+ },
7
+ "globals": {
8
+ "window": true,
9
+ "document": true,
10
+ "WORKAREA": true,
11
+ "$": true,
12
+ "jQuery": true,
13
+ "_": true,
14
+ "feature": true,
15
+ "JST": true,
16
+ "Turbolinks": true,
17
+ "I18n": true,
18
+ "Chart": true,
19
+ "Dropzone": true,
20
+ "strftime": true,
21
+ "Waypoint": true,
22
+ "wysihtml": true,
23
+ "LocalTime": true,
24
+ "describe": true,
25
+ "after": true,
26
+ "afterEach": true,
27
+ "before": true,
28
+ "beforeEach": true,
29
+ "it": true,
30
+ "expect": true,
31
+ "sinon": true,
32
+ "fixture": true,
33
+ "chai": true,
34
+ "Klarna": true
35
+ }
36
+ }
@@ -0,0 +1,61 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ paths-ignore:
5
+ - '.github/**'
6
+ - '**.md'
7
+
8
+ jobs:
9
+ static_analysis:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+ - uses: workarea-commerce/ci/bundler-audit@v1
14
+ - uses: workarea-commerce/ci/rubocop@v1
15
+ - uses: workarea-commerce/ci/eslint@v1
16
+ with:
17
+ args: '**/*.js'
18
+
19
+ admin_tests:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v1
23
+ - uses: actions/setup-ruby@v1
24
+ with:
25
+ ruby-version: 2.6.x
26
+ - uses: workarea-commerce/ci/test@v1
27
+ with:
28
+ command: bin/rails app:workarea:test:admin
29
+
30
+ core_tests:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v1
34
+ - uses: actions/setup-ruby@v1
35
+ with:
36
+ ruby-version: 2.6.x
37
+ - uses: workarea-commerce/ci/test@v1
38
+ with:
39
+ command: bin/rails app:workarea:test:core
40
+
41
+ storefront_tests:
42
+ runs-on: ubuntu-latest
43
+ steps:
44
+ - uses: actions/checkout@v1
45
+ - uses: actions/setup-ruby@v1
46
+ with:
47
+ ruby-version: 2.6.x
48
+ - uses: workarea-commerce/ci/test@v1
49
+ with:
50
+ command: bin/rails app:workarea:test:storefront
51
+
52
+ plugins_tests:
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - uses: actions/checkout@v1
56
+ - uses: actions/setup-ruby@v1
57
+ with:
58
+ ruby-version: 2.6.x
59
+ - uses: workarea-commerce/ci/test@v1
60
+ with:
61
+ command: bin/rails app:workarea:test:plugins
@@ -0,0 +1,24 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/log/*.log
5
+ test/dummy/node_modules/
6
+ test/dummy/yarn-error.log
7
+ test/dummy/tmp/
8
+ .DS_Store
9
+ .byebug_history
10
+ .bundle/
11
+ .sass-cache/
12
+ Gemfile.lock
13
+ pkg/
14
+ test/dummy/tmp/
15
+ test/dummy/public/
16
+ log/*.log
17
+ test/dummy/log/*.log
18
+ test/dummy/db/*.sqlite3
19
+ test/dummy/db/*.sqlite3-journal
20
+ node_modules
21
+ yarn.lock
22
+ yarn-error.log
23
+ package-lock.json
24
+ .rubocop-http*
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "stylelint-config-recommended-scss",
3
+ "rules": {
4
+ "block-no-empty": null,
5
+ "no-descending-specificity": null,
6
+ "property-no-unknown": [true, { "ignoreProperties": ["mso-hide"] }]
7
+ }
8
+ }
@@ -0,0 +1 @@
1
+ --files CHANGELOG.md
@@ -0,0 +1,81 @@
1
+ Workarea Klarna 1.0.0.beta1 (2020-07-28)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Updates from PR feedback
5
+
6
+
7
+ Matt Duffy
8
+
9
+ * add readme
10
+
11
+
12
+ Matt Duffy
13
+
14
+ * add test call to api
15
+
16
+
17
+ Matt Duffy
18
+
19
+ * add tests for request classes
20
+
21
+
22
+ Matt Duffy
23
+
24
+ * add more testing
25
+
26
+
27
+ Matt Duffy
28
+
29
+ * add model testing, add config to control klarna loading
30
+
31
+
32
+ Matt Duffy
33
+
34
+ * Setup testing classes
35
+
36
+
37
+ Matt Duffy
38
+
39
+ * Support credentials for each continent
40
+
41
+
42
+ Matt Duffy
43
+
44
+ * cleanup
45
+
46
+
47
+ Matt Duffy
48
+
49
+ * Factor secondary payment in order total, setup order operation requests
50
+
51
+ Feature-complete
52
+
53
+ Matt Duffy
54
+
55
+ * Setup payment operations, get place order working
56
+
57
+
58
+ Matt Duffy
59
+
60
+ * Clean up session calls, get authorize js working
61
+
62
+
63
+ Matt Duffy
64
+
65
+ * Refine data structure for klarna, setup checkout UI.
66
+
67
+
68
+ Matt Duffy
69
+
70
+ * Setup session calls, first pass at structing order data to Klarna
71
+
72
+
73
+ Matt Duffy
74
+
75
+ * Add basic structure
76
+
77
+
78
+ Matt Duffy
79
+
80
+
81
+
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in klarna.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # To use a debugger
15
+ # gem 'byebug', group: [:development, :test]
16
+
17
+ gem 'workarea', github: 'workarea-commerce/workarea', branch: 'v3.5-stable'
data/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ WebLinc
2
+ Business Source License
3
+
4
+ Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
5
+
6
+ Licensed Work: Workarea Commerce Platform
7
+ The Licensed Work is (c) 2019 WebLinc Corporation
8
+
9
+ Additional Use Grant:
10
+ You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
11
+
12
+ A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
13
+
14
+ For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
15
+
16
+ Change Date: 2019-08-20
17
+
18
+ Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
19
+
20
+ Terms
21
+
22
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
25
+
26
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
27
+
28
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
29
+
30
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
31
+
32
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
33
+
34
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
35
+
36
+ Covenants of Licensor
37
+ In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
38
+
39
+ To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
40
+
41
+ To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
42
+
43
+ To specify a Change Date.
44
+
45
+ Not to modify this License in any other way.
46
+
47
+ Notice
48
+ The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
49
+
50
+ For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
51
+
52
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
@@ -0,0 +1,79 @@
1
+ Workarea Klarna
2
+ ================================================================================
3
+
4
+ Workarea Commerce plugin that adds [Klarna](https://www.klarna.com/) payment options for customers including pay later, pay installments, and more.
5
+
6
+ Overview
7
+ --------------------------------------------------------------------------------
8
+ * Adds Klarna tender type.
9
+ * Dynamically provides payment options in checkout based on customer's eligible payment options determined by geographic location.
10
+ * Supports authorizations, captures, cancellations, and refunds.
11
+
12
+ Getting Started
13
+ --------------------------------------------------------------------------------
14
+
15
+ This gem contains a Rails engine that must be mounted onto a host Rails application.
16
+
17
+ Then add the gem to your application's Gemfile specifying the source:
18
+
19
+ # ...
20
+ gem 'workarea-klarna'
21
+ # ...
22
+
23
+ Update your application's bundle.
24
+
25
+ cd path/to/application
26
+ bundle
27
+
28
+ Configure Klarna credentials. See below.
29
+
30
+ Support & Configuration
31
+ --------------------------------------------------------------------------------
32
+
33
+ Klarna support is based on a customer's location. Klarna currently accepts payment from customers of North America, Europe, and will soon support Oceania(Australia).
34
+
35
+ You must provide credentials for each region you would like to support. The plugin allows multiple options to provide credentials to communicate with Klarna -- environment variables, rails credentials, or admin configurable fields.
36
+
37
+ ### North America
38
+
39
+ * Test Environment: https://playground.us.portal.klarna.com/developer-sign-up
40
+ * Plugin environment variables:
41
+
42
+ `WORKAREA_KLARNA_NA_USERNAME`
43
+ `WORKAREA_KLARNA_NA_PASSWORD`
44
+ * Rails credentials:
45
+ ```
46
+ klarna:
47
+ na:
48
+ username:
49
+ password:
50
+ ```
51
+ * Or, you can log into the admin and go to Settings > Configuration, and add the North America username and password.
52
+
53
+ ### Europe
54
+
55
+ * Test Environment: https://playground.eu.portal.klarna.com/developer-sign-up
56
+ * Plugin environment variables:
57
+
58
+ `WORKAREA_KLARNA_EUR_USERNAME`
59
+ `WORKAREA_KLARNA_EUR_PASSWORD`
60
+ * Rails credentials:
61
+ ```
62
+ klarna:
63
+ eur:
64
+ username:
65
+ password:
66
+ ```
67
+ * Or, you can log into the admin and go to Settings > Configuration, and add the Europe username and password.
68
+
69
+ You can get more specific information from the [Klarna Developer](https://developers.klarna.com/) portal.
70
+
71
+ Workarea Platform Documentation
72
+ --------------------------------------------------------------------------------
73
+
74
+ See [https://developer.workarea.com](https://developer.workarea.com) for Workarea platform documentation.
75
+
76
+ License
77
+ --------------------------------------------------------------------------------
78
+
79
+ Workarea Klarna is released under the [Business Software License](LICENSE)
@@ -0,0 +1,56 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+ RDoc::Task.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = 'rdoc'
10
+ rdoc.title = 'Klarna'
11
+ rdoc.options << '--line-numbers'
12
+ rdoc.rdoc_files.include('README.md')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ load 'rails/tasks/engine.rake'
18
+ load 'rails/tasks/statistics.rake'
19
+ load 'workarea/changelog.rake'
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'lib'
24
+ t.libs << 'test'
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = false
27
+ end
28
+ task default: :test
29
+
30
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
31
+ require 'workarea/klarna/version'
32
+
33
+ desc "Release version #{Workarea::Klarna::VERSION} of the gem"
34
+ task :release do
35
+ Rake::Task['workarea:changelog'].execute
36
+ system 'git add CHANGELOG.md'
37
+ system 'git commit -m "Update CHANGELOG"'
38
+
39
+ system "git tag -a v#{Workarea::Klarna::VERSION} -m 'Tagging #{Workarea::Klarna::VERSION}'"
40
+ system 'git push origin HEAD --follow-tags'
41
+
42
+ system "gem build workarea-klarna.gemspec"
43
+ system "gem push workarea-klarna-#{Workarea::Klarna::VERSION}.gem"
44
+ system "rm workarea-klarna-#{Workarea::Klarna::VERSION}.gem"
45
+ end
46
+
47
+ desc 'Run the JavaScript tests'
48
+ ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
49
+ task teaspoon: 'app:teaspoon'
50
+
51
+ desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
52
+ task :teaspoon_server do
53
+ Dir.chdir("test/dummy")
54
+ teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
55
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
56
+ end