solidus_paypal_commerce_platform 0.6.0 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +23 -9
  3. data/.gitignore +1 -0
  4. data/.rspec +0 -1
  5. data/.rubocop.yml +3 -2
  6. data/CHANGELOG.md +25 -8
  7. data/Gemfile +0 -41
  8. data/README.md +9 -12
  9. data/Rakefile +6 -1
  10. data/bin/dummy-app +37 -0
  11. data/bin/rails-dummy-app +17 -0
  12. data/bin/rspec +11 -0
  13. data/bin/sandbox +3 -8
  14. data/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb +37 -20
  15. data/lib/generators/solidus_paypal_commerce_platform/install/templates/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +272 -0
  16. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/buttons.js +0 -0
  17. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/namespace.js +0 -0
  18. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform.js +7 -0
  19. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/stylesheets/spree/frontend/solidus_paypal_commerce_platform.css +0 -0
  20. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/orders_controller.rb +0 -0
  21. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/payments_controller.rb +0 -0
  22. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/paypal_orders_controller.rb +0 -0
  23. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/shipping_rates_controller.rb +0 -0
  24. data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/wizard_controller.rb +0 -0
  25. data/lib/{views/frontend/spree/checkout → generators/solidus_paypal_commerce_platform/install/templates/app/views/checkouts}/payment/_paypal_commerce_platform.html.erb +5 -4
  26. data/lib/{views/frontend/spree → generators/solidus_paypal_commerce_platform/install/templates/app/views}/orders/payment/_paypal_commerce_platform.html.erb +4 -3
  27. data/lib/{views/frontend/spree → generators/solidus_paypal_commerce_platform/install/templates/app/views}/products/payment/_paypal_commerce_platform.html.erb +1 -1
  28. data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/cart/_cart_buttons.html.erb +0 -0
  29. data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/payments/_payment.html.erb +0 -0
  30. data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/product/_product_buttons.html.erb +0 -0
  31. data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/shared/_javascript_sdk_tag.html.erb +4 -2
  32. data/lib/generators/solidus_paypal_commerce_platform/install/templates/{initializer.rb → config/initializers/solidus_paypal_commerce_platform.rb} +0 -0
  33. data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
  34. data/solidus_paypal_commerce_platform.gemspec +1 -2
  35. data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.COMPLETED.v2.json +121 -0
  36. data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.PROCESSED.v2.json +121 -0
  37. data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v1.json +50 -0
  38. data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v2.json +72 -0
  39. data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v1.json +50 -0
  40. data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v2.json +68 -0
  41. data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v1.json +51 -0
  42. data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v2.json +63 -0
  43. data/spec/jobs/solidus_paypal_commerce_platform/webhook_job_spec.rb +44 -0
  44. data/spec/lib/solidus_paypal_commerce_platform/client_spec.rb +21 -0
  45. data/spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb +91 -0
  46. data/spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb +200 -0
  47. data/spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb +119 -0
  48. data/spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb +67 -0
  49. data/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +80 -0
  50. data/spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb +38 -0
  51. data/spec/models/solidus_paypal_commerce_platform/wizard_spec.rb +9 -0
  52. data/spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb +36 -0
  53. data/spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb +44 -0
  54. data/spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb +59 -0
  55. data/spec/solidus_paypal_commerce_platform_spec_helper.rb +5 -0
  56. data/spec/support/solidus_paypal_commerce_platform/factories.rb +5 -0
  57. data/spec/support/solidus_paypal_commerce_platform/paypal_sdk_script_tag_helper.rb +13 -0
  58. data/spec/system/backend/new_payment_method_spec.rb +40 -0
  59. data/spec/system/frontend/cart_spec.rb +53 -0
  60. data/spec/system/frontend/checkout_spec.rb +104 -0
  61. data/spec/system/frontend/product_spec.rb +98 -0
  62. metadata +52 -36
  63. data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +0 -206
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64ecb1bbe9f5e77a70613976318354d6b0e3011c529e95d410229e31c55c3fb1
4
- data.tar.gz: 7d6aae5716b1c2a9aa88a2c843755c0312b7025f5dde7cdd539c5ea7cb059974
3
+ metadata.gz: 1ca5d1fd0c7ccd99dc39a66a53f0c9ddf902b8114bb420c9f1a070c13cb96ffa
4
+ data.tar.gz: 9a16b551e567947e0e6b743626de2793113e7e12e51cc08dddaf7a00ea60d97c
5
5
  SHA512:
6
- metadata.gz: 532b61e156f5a3cd0ff0eca30e65fcdf7f9e70fdfb0c69f299b2528cf3ed96bd9c08540007bafc19f26e17a1e317067270506f1da986f5e52e38dd757ef62605
7
- data.tar.gz: 9e79910413c373e01efd301789b1b3dce257976102c7de3ce61383a1aa3e8f32ac13f1ff54e514263ce0dfdad971e49ef2eddb8d7c59deb360e8b98f3a4c06d6
6
+ metadata.gz: d6b54f9d01a843a63645844b65626aaefc85cad5885aaca64c2d72050e3b02502f0e00510b9a9ec1bcbd611025957fe2b008b4db85c1fed7558f2c1ccd4f056f
7
+ data.tar.gz: 2bdd87d6c92d31282eb4cf566dfb59a247d759583553b670e7326ec806b6b1a1ea7c5a82f6eb49e9155b671f2933eb977d1bf02004b56dce37b00e4559a79bcf
data/.circleci/config.yml CHANGED
@@ -9,33 +9,47 @@ orbs:
9
9
  # or goes EOL.
10
10
  solidusio_extensions: solidusio/extensions@volatile
11
11
 
12
+ commands:
13
+ test-with-starter-frontend:
14
+ steps:
15
+ - checkout
16
+ - browser-tools/install-chrome
17
+ - run:
18
+ name: Install libvips
19
+ command: |
20
+ sudo apt-get update
21
+ sudo apt-get install -yq libvips-dev
22
+ - solidusio_extensions/test-branch:
23
+ branch: master
24
+ command: |
25
+ export FRONTEND=starter
26
+ sudo gem update --system
27
+ gem install bundler
28
+ bin/dummy-app
29
+ bin/rspec
30
+ - solidusio_extensions/store-test-results
31
+
12
32
  jobs:
13
33
  run-specs-with-postgres:
14
34
  executor:
15
35
  name: solidusio_extensions/postgres
16
36
  ruby_version: '3.1'
17
37
  steps:
18
- - checkout
19
- - browser-tools/install-chrome
20
- - solidusio_extensions/run-tests
38
+ - test-with-starter-frontend
21
39
 
22
40
  run-specs-with-mysql:
23
41
  executor:
24
42
  name: solidusio_extensions/mysql
25
43
  ruby_version: '3.0'
26
44
  steps:
27
- - checkout
28
- - browser-tools/install-chrome
29
- - solidusio_extensions/run-tests
45
+ - test-with-starter-frontend
30
46
 
31
47
  run-specs-with-sqlite:
32
48
  executor:
33
49
  name: solidusio_extensions/sqlite
34
50
  ruby_version: '2.7'
35
51
  steps:
36
- - checkout
37
- - browser-tools/install-chrome
38
- - solidusio_extensions/run-tests
52
+ - test-with-starter-frontend
39
53
 
40
54
  lint-code:
41
55
  executor: solidusio_extensions/sqlite-memory
data/.gitignore CHANGED
@@ -15,6 +15,7 @@ pkg
15
15
  spec/dummy
16
16
  spec/examples.txt
17
17
  /sandbox
18
+ /dummy-app
18
19
  .rvmrc
19
20
  .ruby-version
20
21
  .ruby-gemset
data/.rspec CHANGED
@@ -1,2 +1 @@
1
1
  --color
2
- --require spec_helper
data/.rubocop.yml CHANGED
@@ -6,6 +6,7 @@ AllCops:
6
6
  TargetRubyVersion: '2.7'
7
7
  Exclude:
8
8
  - sandbox/**/*
9
+ - dummy-app/**/*
9
10
  - spec/dummy/**/*
10
11
  - vendor/bundle/**/*
11
12
 
@@ -23,10 +24,10 @@ Naming/VariableNumber:
23
24
  RSpec/AnyInstance:
24
25
  Enabled: false
25
26
 
26
- # Feature specs are not describing any class or module.
27
+ # System specs are not describing any class or module.
27
28
  RSpec/DescribeClass:
28
29
  Exclude:
29
- - spec/features/**/*
30
+ - spec/system/**/*
30
31
 
31
32
  # No need to make the code more complex for no real gain.
32
33
  RSpec/MessageSpies:
data/CHANGELOG.md CHANGED
@@ -1,22 +1,39 @@
1
1
  # Changelog
2
2
 
3
- ## [v0.6.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.6.0) (2022-11-25)
3
+ ## [v1.0.0.beta2](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v1.0.0.beta2) (2022-12-12)
4
+
5
+ [Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v1.0.0.beta1...v1.0.0.beta2)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - wizard doesn't create payment method in v1.0.0.beta1 and no partial. [\#174](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/174)
10
+ - Solidus 3.2 doesn't install SPCP's checkout page when PayPal is chosen as the payment method [\#172](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/172)
11
+
12
+ **Closed issues:**
4
13
 
5
- [Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.6.0...v0.6.0)
14
+ - Hide the installer option for copying specs [\#175](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/175)
15
+ - Decide about the testing approach for extensions that involve SSF code [\#171](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/171)
16
+ - Release 1.0.0.beta1 compatible with the new starter frontend [\#170](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/170)
6
17
 
7
18
  **Merged pull requests:**
8
19
 
9
- - More fixes and improvements extracted from SSF support [\#168](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/168) ([elia](https://github.com/elia))
10
- * inline the load_order before action
11
- * require the payment_method_id param when loading the payment method
12
- * mark the javascript_sdk_url as HTML safe
13
- * ensure amounts are presented with 2 decimals for the PayPal API
14
- * fixed the sign in requests
20
+ - Hide the installer `--specs=…` option [\#176](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/176) ([elia](https://github.com/elia))
21
+ - Remove solidus prefix from component names [\#173](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/173) ([gsmendoza](https://github.com/gsmendoza))
22
+ - Bugfixes and improvements \(extracted from the SSF support branch\) [\#168](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/168) ([elia](https://github.com/elia))
15
23
  - Reorganize the install generator and deprecate `--skip-migrations` [\#167](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/167) ([elia](https://github.com/elia))
24
+ - Setup compatibility with the starter frontend [\#166](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/166) ([elia](https://github.com/elia))
16
25
  - Move 'shipping\_preference' preference under PaypalOrder\#to\_json [\#152](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/152) ([retsef](https://github.com/retsef))
17
26
  - Truncate the product name to 127 characters [\#139](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/139) ([DanielePalombo](https://github.com/DanielePalombo))
18
27
  - Fix issue on international transactions [\#129](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/129) ([jtapia](https://github.com/jtapia))
19
28
 
29
+ ## [v1.0.0.beta1](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v1.0.0.beta1) (2022-12-05)
30
+
31
+ [Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.6.0...v1.0.0.beta1)
32
+
33
+ **Closed issues:**
34
+
35
+ - Release 0.6 and attach that version to a different branch [\#169](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/169)
36
+
20
37
  ## [v0.6.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.6.0) (2022-11-25)
21
38
 
22
39
  [Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.5.0...v0.6.0)
data/Gemfile CHANGED
@@ -1,46 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
-
6
- branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
- solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
8
- %w[solidusio/solidus solidusio/solidus_frontend]
9
- else
10
- %w[solidusio/solidus] * 2
11
- end
12
- gem 'solidus', github: solidus_git, branch: branch
13
- gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
14
-
15
- # Needed to help Bundler figure out how to resolve dependencies,
16
- # otherwise it takes forever to resolve them.
17
- # See https://github.com/bundler/bundler/issues/6677
18
- gem 'rails', ENV.fetch('RAILS_VERSION', '>0.a')
19
-
20
- # Provides basic authentication functionality for testing parts of your engine
21
- gem 'solidus_auth_devise'
22
-
23
- case ENV.fetch('DB', nil)
24
- when 'mysql'
25
- gem 'mysql2'
26
- when 'postgresql'
27
- gem 'pg'
28
- else
29
- gem 'sqlite3'
30
- end
31
-
32
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3')
33
- # 'net/smtp' is required by 'mail', see:
34
- # - https://github.com/ruby/net-protocol/issues/10
35
- # - https://stackoverflow.com/a/72474475
36
- gem 'net-smtp', require: false
37
- end
38
4
 
39
5
  gemspec
40
-
41
- # Use a local Gemfile to include development dependencies that might not be
42
- # relevant for the project or for other contributors, e.g. pry-byebug.
43
- #
44
- # We use `send` instead of calling `eval_gemfile` to work around an issue with
45
- # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
46
- send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
data/README.md CHANGED
@@ -31,7 +31,7 @@ Since PayPal is being used as the checkout if the user checks out on the product
31
31
 
32
32
  A) Turn off cart and product page checkout - configurable on the admin payment method page for PayPal Commerce Platform.
33
33
  -OR-
34
- B) Collect the users phone number seperately
34
+ B) Collect the users phone number separately
35
35
 
36
36
  and then override the `Spree::Address` method `require_phone?` to return `true`.
37
37
 
@@ -93,6 +93,7 @@ end
93
93
  The instances of your wizard class should respond to `#name` and `#partial_name`, where `partial_name` will return the path to the partial you'd like to display on the wizard setup section. In our case, we just display a button to direct the user to PayPal.
94
94
 
95
95
  ## State Guesser
96
+
96
97
  PayPal users can change their shipping address directly on PayPal, which will
97
98
  update their address on Solidus as well. However, in some instances, Solidus
98
99
  uses the incorrect subregion level for states, which causes validation problems
@@ -101,7 +102,7 @@ with the addresses that PayPal sends to us.
101
102
  For instance, if your user lives in Pescara, Italy, then PayPal will return
102
103
  "Pescara" as the state. However on older version of Solidus, the region
103
104
  "Abruzzo" is used, so the address will not be able to validate. To solve this
104
- issue, we've implented a class that attempts to guess the state of the user
105
+ issue, we've implemented a class that attempts to guess the state of the user
105
106
  using Carmen subregions if the state cannot be initially found. You can, of
106
107
  course, implement your own state guesser and set it like this:
107
108
 
@@ -121,6 +122,7 @@ With product and cart page checkout, the user is directed to the checkout confir
121
122
  PayPals API does not allow for admin-side payments. Instead, backend users taking payments for customers will need to use the PayPal Virtual Terminal to take payments. [More info is available on the PayPal website.](https://www.paypal.com/merchantapps/appcenter/acceptpayments/virtualterminal?locale.x=en_US)
122
123
 
123
124
  ## Venmo
125
+
124
126
  Venmo is currently available to US merchants and buyers. There are also other [prequisites](https://developer.paypal.com/docs/business/checkout/pay-with-venmo/#eligibility).
125
127
 
126
128
  If the transaction supports Venmo and it is enabled by the following, then a button should appear for it on checkout payment page. Note, Venmo cannot currently be rendered on the product or cart pages.
@@ -135,6 +137,7 @@ See more about preferences([Configuration](#configuration)) below.
135
137
  [_As Venmo is only available in the US, you may want to mock your location for testing_](#mocking-your-buyer-country)
136
138
 
137
139
  ## Configuration
140
+
138
141
  The easiest way to change the `Payment Method`'s preferences is through admin: `Settings > Payments > "PayPal Commerce Platform" > Edit`.
139
142
 
140
143
  See more about preferences [here](https://guides.solidus.io/developers/preferences/add-model-preferences.html#access-your-preferences)/
@@ -145,10 +148,10 @@ See more about preferences [here](https://guides.solidus.io/developers/preferenc
145
148
 
146
149
  First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
147
150
  app if it does not exist, then it will run specs. The dummy app can be regenerated by using
148
- `bin/rake extension:test_app`.
151
+ `bin/dummy-app`.
149
152
 
150
153
  ```shell
151
- bundle
154
+ bin/setup
152
155
  bin/rake
153
156
  ```
154
157
 
@@ -158,13 +161,6 @@ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
158
161
  bundle exec rubocop
159
162
  ```
160
163
 
161
- When testing your application's integration with this extension you may use its factories.
162
- Simply add this require statement to your spec_helper:
163
-
164
- ```ruby
165
- require 'solidus_paypal_commerce_platform/factories'
166
- ```
167
-
168
164
  ### Running the sandbox
169
165
 
170
166
  To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
@@ -182,6 +178,7 @@ Use Ctrl-C to stop
182
178
  ```
183
179
 
184
180
  ### Mocking your buyer country
181
+
185
182
  PayPal normally looks at your IP geolocation to see where you are located to determine what funding sources are available to you. For example, Venmo is currently only available to US buyers.
186
183
  Because of this, you may want to pretend you are from US check that that Venmo is correctly integrated for these customers. To do this, set the payment method's preference of `force_buyer_country` to "US". See more information about preferences above.
187
184
 
@@ -216,4 +213,4 @@ By using this extension, you are giving back to Solidus. PayPal will pay a fee t
216
213
 
217
214
  ## License
218
215
 
219
- Copyright (c) 2020 Nebulab srls, released under the New BSD License
216
+ Copyright (c) 2022 Nebulab srls, released under the New BSD License
data/Rakefile CHANGED
@@ -3,4 +3,9 @@
3
3
  require 'solidus_dev_support/rake_tasks'
4
4
  SolidusDevSupport::RakeTasks.install
5
5
 
6
- task default: 'extension:specs'
6
+ task :default do
7
+ require 'bundler'
8
+ Bundler.with_unbundled_env do
9
+ sh 'bin/rspec'
10
+ end
11
+ end
data/bin/dummy-app ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ extension_name="solidus_paypal_commerce_platform"
6
+
7
+ # Stay away from the bundler env of the containing extension.
8
+ function unbundled {
9
+ ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@"
10
+ }
11
+
12
+ # "sqlite" is set by the ORB extension instead of "sqlite3",
13
+ # all other options are already in the format expected by `rails new`.
14
+ test "$DB" = "sqlite" && export DB="sqlite3"
15
+
16
+ rm -rf ./dummy-app
17
+ unbundled bundle exec rails new dummy-app \
18
+ --database=${DB:-sqlite3} \
19
+ --skip-bundle \
20
+ --skip-git \
21
+ --skip-keeps \
22
+ --skip-rc \
23
+ --skip-spring \
24
+ --skip-javascript
25
+
26
+ if [ ! -d "dummy-app" ]; then
27
+ echo 'dummy-app rails application failed'
28
+ exit 1
29
+ fi
30
+
31
+ cd ./dummy-app
32
+ unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
33
+ unbundled bundle exec rake db:drop db:create
34
+ unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none --no-seed --no-sample "$@"
35
+ unbundled bundle add $extension_name --path ..
36
+ unbundled bundle exec rails generate $extension_name:install --migrate --specs=all
37
+
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ root = "#{__dir__}/.."
4
+ app_root = "#{root}/dummy-app"
5
+
6
+ unless File.exist? "#{app_root}/bin/rails"
7
+ warn 'Creating the dummy-app app...'
8
+ Dir.chdir root do
9
+ system "#{root}/bin/dummy-app" or begin
10
+ warn 'Automatic creation of the dummy-app app failed'
11
+ exit 1
12
+ end
13
+ end
14
+ end
15
+
16
+ Dir.chdir app_root
17
+ exec "#{app_root}/bin/rails", *ARGV
data/bin/rspec ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ bin/rails-dummy-app generate solidus_paypal_commerce_platform:install --force --migrate --specs=all
6
+
7
+ cd dummy-app/
8
+ rspec "$@"
9
+ exit_status=$?
10
+ cd -
11
+ exit $exit_status
data/bin/sandbox CHANGED
@@ -29,7 +29,7 @@ extension_name="solidus_paypal_commerce_platform"
29
29
 
30
30
  # Stay away from the bundler env of the containing extension.
31
31
  function unbundled {
32
- ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
32
+ ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@"
33
33
  }
34
34
 
35
35
  rm -rf ./sandbox
@@ -48,14 +48,9 @@ if [ ! -d "sandbox" ]; then
48
48
  fi
49
49
 
50
50
  cd ./sandbox
51
- cat <<RUBY >> Gemfile
52
- gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
53
- gem 'pry-byebug', platforms: :mri, groups: [:test, :development]
54
- RUBY
55
-
56
- unbundled bundle install --gemfile Gemfile
51
+ unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
57
52
  unbundled bundle exec rake db:drop db:create
58
- unbundled bundle exec rails generate solidus:install --auto-accept $@
53
+ unbundled bundle exec rails generate solidus:install --auto-accept "$@"
59
54
 
60
55
  echo
61
56
  echo "🚀 Sandbox app successfully created for $extension_name!"
@@ -3,21 +3,25 @@
3
3
  module SolidusPaypalCommercePlatform
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
- class_option :auto_run_migrations, type: :boolean, default: false
6
+ class_option :migrate, type: :boolean, default: true
7
+ class_option :backend, type: :boolean, default: true
8
+ class_option :starter_frontend, type: :boolean, default: true
7
9
 
8
- # This should only be used by the solidus installer prior to v3.3.
9
- class_option :skip_migrations, type: :boolean, default: false, hide: true
10
+ # This is only used to run all-specs during development and CI, regular installation limits
11
+ # installed specs to frontend, which are the ones related to code copied to the target application.
12
+ class_option :specs, type: :string, enum: %w[all frontend], default: 'frontend', hide: true
10
13
 
11
14
  source_root File.expand_path('templates', __dir__)
12
15
 
13
16
  def install_solidus_core_support
14
- template 'initializer.rb', 'config/initializers/solidus_paypal_commerce_platform.rb'
17
+ directory 'config/initializers', 'config/initializers'
15
18
  rake 'railties:install:migrations FROM=solidus_paypal_commerce_platform'
19
+ run 'bin/rails db:migrate' if options[:migrate]
16
20
  route "mount SolidusPaypalCommercePlatform::Engine, at: '/solidus_paypal_commerce_platform'"
17
21
  end
18
22
 
19
23
  def install_solidus_backend_support
20
- support_code_for('solidus_backend') do
24
+ support_code_for(:backend) do
21
25
  append_file(
22
26
  'vendor/assets/javascripts/spree/backend/all.js',
23
27
  "//= require spree/backend/solidus_paypal_commerce_platform\n"
@@ -31,36 +35,49 @@ module SolidusPaypalCommercePlatform
31
35
  end
32
36
  end
33
37
 
34
- def install_solidus_frontend_support
35
- support_code_for('solidus_frontend') do
38
+ def install_solidus_starter_frontend_support
39
+ support_code_for(:starter_frontend) do
40
+ directory 'app', 'app'
36
41
  append_file(
37
- 'vendor/assets/javascripts/spree/frontend/all.js',
38
- "//= require spree/frontend/solidus_paypal_commerce_platform\n",
42
+ 'app/assets/javascripts/solidus_starter_frontend.js',
43
+ "//= require spree/frontend/solidus_paypal_commerce_platform\n"
39
44
  )
40
45
  inject_into_file(
41
- 'vendor/assets/stylesheets/spree/frontend/all.css',
46
+ 'app/assets/stylesheets/solidus_starter_frontend.css',
42
47
  " *= require spree/frontend/solidus_paypal_commerce_platform\n",
43
48
  before: %r{\*/},
44
49
  verbose: true,
45
50
  )
46
- directory engine.root.join("lib/views/frontend"), 'app/views/'
47
- end
48
- end
49
51
 
50
- def run_migrations
51
- return rake 'db:migrate' if options[:auto_run_migrations] && !options[:skip_migrations]
52
+ spec_paths =
53
+ case options[:specs]
54
+ when 'all' then %w[spec]
55
+ when 'frontend'
56
+ %w[
57
+ spec/solidus_paypal_commerce_platform_spec_helper.rb
58
+ spec/system/frontend
59
+ spec/support
60
+ ]
61
+ end
52
62
 
53
- say_status :skip, 'db:migrate'
63
+ spec_paths.each do |path|
64
+ if engine.root.join(path).directory?
65
+ directory engine.root.join(path), path
66
+ else
67
+ template engine.root.join(path), path
68
+ end
69
+ end
70
+ end
54
71
  end
55
72
 
56
73
  private
57
74
 
58
- def support_code_for(gem_name, run_if: Bundler.locked_gems.specs.map(&:name).include?(gem_name), &block)
59
- if run_if
60
- say_status :install, "[#{engine.engine_name}] #{gem_name} code", :blue
75
+ def support_code_for(component_name, &block)
76
+ if options[component_name]
77
+ say_status :install, "[#{engine.engine_name}] solidus_#{component_name}", :blue
61
78
  shell.indent(&block)
62
79
  else
63
- say_status :skip, "[#{engine.engine_name}] #{gem_name} code", :blue
80
+ say_status :skip, "[#{engine.engine_name}] solidus_#{component_name}", :blue
64
81
  end
65
82
  end
66
83