solidus_product_assembly 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +48 -10
  3. data/.github/stale.yml +4 -4
  4. data/.github_changelog_generator +2 -0
  5. data/.gitignore +4 -0
  6. data/.rspec +0 -1
  7. data/.rubocop.yml +4 -1
  8. data/.rubocop_todo.yml +153 -29
  9. data/CHANGELOG.md +2 -18
  10. data/Gemfile +28 -8
  11. data/OLD_CHANGELOG.md +116 -0
  12. data/README.md +64 -73
  13. data/Rakefile +1 -0
  14. data/app/decorators/models/solidus_product_assembly/spree/product_decorator.rb +19 -6
  15. data/app/decorators/models/solidus_product_assembly/spree/stock/differentiator_decorator.rb +17 -0
  16. data/app/views/spree/admin/parts/_parts_table.html.erb +1 -1
  17. data/app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb +3 -3
  18. data/bin/rails +4 -12
  19. data/bin/rails-engine +13 -0
  20. data/bin/rails-sandbox +16 -0
  21. data/bin/rake +7 -0
  22. data/bin/sandbox +102 -0
  23. data/bin/setup +1 -1
  24. data/lib/generators/solidus_product_assembly/install/install_generator.rb +15 -9
  25. data/lib/generators/solidus_product_assembly/install/templates/initializer.rb +6 -0
  26. data/lib/solidus_product_assembly/configuration.rb +21 -0
  27. data/lib/solidus_product_assembly/engine.rb +3 -1
  28. data/lib/solidus_product_assembly/version.rb +1 -1
  29. data/lib/solidus_product_assembly.rb +1 -3
  30. data/solidus_product_assembly.gemspec +34 -37
  31. data/spec/features/admin/orders_spec.rb +0 -1
  32. data/spec/features/admin/parts_spec.rb +7 -6
  33. data/spec/features/admin/return_items_spec.rb +18 -9
  34. data/spec/models/spree/inventory_unit_spec.rb +0 -1
  35. data/spec/models/spree/line_item_spec.rb +0 -1
  36. data/spec/models/spree/order_inventory_assembly_spec.rb +6 -3
  37. data/spec/models/spree/product_spec.rb +18 -0
  38. data/spec/spec_helper.rb +13 -10
  39. metadata +41 -65
  40. data/app/assets/javascripts/spree/frontend/solidus_product_assembly.js +0 -1
  41. data/app/assets/stylesheets/spree/frontend/solidus_product_assembly.css +0 -3
  42. data/app/decorators/controllers/solidus_product_assembly/spree/checkout_controller_decorator.rb +0 -13
@@ -23,7 +23,7 @@ describe "Return Items", type: :feature, js: true do
23
23
  3.times { order.next }
24
24
  create :payment, order: order, amount: order.amount
25
25
  order.next
26
- order.complete
26
+ order.complete!
27
27
  order.payments.each(&:capture!)
28
28
  order.shipments.each { |s| s.update state: :ready }
29
29
  order.shipments.each(&:ship!)
@@ -51,7 +51,9 @@ describe "Return Items", type: :feature, js: true do
51
51
  click_link 'Customer Returns'
52
52
  click_link 'New Customer Return'
53
53
  find('#select-all').click
54
- page.execute_script %{$('option[value="receive"]').attr('selected', 'selected')}
54
+ page.execute_script <<~JS
55
+ $('option[value="receive"]').attr('selected', 'selected');
56
+ JS
55
57
  select Spree::StockLocation.first.name, from: 'Stock Location'
56
58
  click_button 'Create'
57
59
 
@@ -88,7 +90,9 @@ describe "Return Items", type: :feature, js: true do
88
90
  click_link 'Customer Returns'
89
91
  click_link 'New Customer Return'
90
92
  find('#select-all').click
91
- page.execute_script %{$('option[value="receive"]').attr('selected', 'selected')}
93
+ page.execute_script <<~JS
94
+ $('option[value="receive"]').attr('selected', 'selected');
95
+ JS
92
96
  select Spree::StockLocation.first.name, from: 'Stock Location'
93
97
  click_button 'Create'
94
98
 
@@ -106,10 +110,15 @@ describe "Return Items", type: :feature, js: true do
106
110
 
107
111
  context 'when the product is not a bundle' do
108
112
  before do
109
- order.reload.create_proposed_shipments
110
- order.finalize!
111
- order.update state: :complete
112
- order.shipments.update_all state: :shipped
113
+ create :refund_reason, name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false
114
+ order.line_items.each { |li| li.variant.stock_items.first.set_count_on_hand 4 }
115
+ 3.times { order.next }
116
+ create :payment, order: order, amount: order.amount
117
+ order.next
118
+ order.complete!
119
+ order.payments.each(&:capture!)
120
+ order.shipments.each { |s| s.update state: :ready }
121
+ order.shipments.each(&:ship!)
113
122
  end
114
123
 
115
124
  context 'with a single item cart' do
@@ -125,7 +134,7 @@ describe "Return Items", type: :feature, js: true do
125
134
 
126
135
  within '.return-items-table tbody' do
127
136
  expect(page).to have_selector 'tr', count: 1
128
- expect(page).to have_selector '.return-item-pre-tax-refund-amount', text: '$10.00', count: 1
137
+ expect(page).to have_selector :field, class: 'refund-amount-input', with: '10.0', count: 1
129
138
  end
130
139
  end
131
140
  end
@@ -143,7 +152,7 @@ describe "Return Items", type: :feature, js: true do
143
152
 
144
153
  within '.return-items-table tbody' do
145
154
  expect(page).to have_selector 'tr', count: 2
146
- expect(page).to have_selector '.return-item-pre-tax-refund-amount', text: '$10.00', count: 2
155
+ expect(page).to have_selector :field, class: 'refund-amount-input', with: '10.0', count: 2
147
156
  end
148
157
  end
149
158
  end
@@ -29,7 +29,6 @@ module Spree
29
29
  before do
30
30
  product.parts << parts
31
31
  order.create_proposed_shipments
32
- order.finalize!
33
32
  end
34
33
 
35
34
  it 'will return the percentage of a line item' do
@@ -51,7 +51,6 @@ module Spree
51
51
  before do
52
52
  product.parts << parts
53
53
  order.create_proposed_shipments
54
- order.finalize!
55
54
  end
56
55
 
57
56
  it "verifies inventory units via OrderInventoryAssembly" do
@@ -17,7 +17,7 @@ module Spree
17
17
 
18
18
  line_item.update!(quantity: 3)
19
19
  order.reload.create_proposed_shipments
20
- order.finalize!
20
+ allow(order).to receive(:completed?).and_return(true)
21
21
  end
22
22
 
23
23
  context "inventory units count" do
@@ -36,7 +36,10 @@ module Spree
36
36
  it "inserts new inventory units for every bundle part" do
37
37
  expected_units_count = original_units_count + bundle.assemblies_parts.to_a.sum(&:count)
38
38
  subject.verify
39
- expect(described_class.new(line_item.reload).inventory_units.count).to eql(expected_units_count)
39
+
40
+ # needs to reload so that inventory units are fetched from the updated order.shipments
41
+ updated_units_count = described_class.new(line_item.reload).inventory_units.count
42
+ expect(updated_units_count).to eql(expected_units_count)
40
43
  end
41
44
  end
42
45
 
@@ -47,7 +50,7 @@ module Spree
47
50
  expected_units_count = original_units_count - bundle.assemblies_parts.to_a.sum(&:count)
48
51
  subject.verify
49
52
 
50
- # needs to reload so that inventory units are fetched from updates order.shipments
53
+ # needs to reload so that inventory units are fetched from the updated order.shipments
51
54
  updated_units_count = described_class.new(line_item.reload).inventory_units.count
52
55
  expect(updated_units_count).to eql(expected_units_count)
53
56
  end
@@ -8,6 +8,24 @@ describe Spree::Product do
8
8
  @master_variant = Spree::Variant.where(is_master: true).find_by(product_id: @product.id)
9
9
  end
10
10
 
11
+ describe ".search_can_be_part" do
12
+ subject { described_class.search_can_be_part("matching") }
13
+
14
+ let!(:name_matching_product) { create :product, can_be_part: true, name: "matching" }
15
+ let!(:sku_matching_product) { create :product, can_be_part: true, master: variant }
16
+ let(:variant) { create :master_variant, sku: "matching" }
17
+
18
+ before do
19
+ create :product, can_be_part: false, name: "matching"
20
+ create :product, deleted_at: 1.day.ago, can_be_part: true, name: "matching"
21
+ create :product, can_be_part: true, name: "Something else"
22
+ end
23
+
24
+ it "returns non-deleted products matching the search that can be parts" do
25
+ expect(subject).to contain_exactly(name_matching_product, sku_matching_product)
26
+ end
27
+ end
28
+
11
29
  describe "Spree::Product Assembly" do
12
30
  before do
13
31
  @product = create(:product)
data/spec/spec_helper.rb CHANGED
@@ -1,28 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Configure Rails Environment
4
- ENV['RAILS_ENV'] ||= 'test'
4
+ ENV['RAILS_ENV'] = 'test'
5
5
 
6
6
  # Run Coverage report
7
7
  require 'solidus_dev_support/rspec/coverage'
8
8
 
9
- require File.expand_path('dummy/config/environment.rb', __dir__)
9
+ # Create the dummy app if it's still missing.
10
+ dummy_env = "#{__dir__}/dummy/config/environment.rb"
11
+ system 'bin/rake extension:test_app' unless File.exist? dummy_env
12
+ require dummy_env
10
13
 
11
14
  # Requires factories and other useful helpers defined in spree_core.
12
15
  require 'solidus_dev_support/rspec/feature_helper'
13
16
 
14
- # This will load Solidus Core factories right before the ones defined in
15
- # lib/extension_name/testing_support/factories/*_factory.rb or
16
- # lib/extension_name/testing_support/factories.rb
17
- SolidusDevSupport::TestingSupport::Factories.load_for(SolidusProductAssembly::Engine)
18
-
19
17
  # Requires supporting ruby files with custom matchers and macros, etc,
20
18
  # in spec/support/ and its subdirectories.
21
- Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
19
+ Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
20
+
21
+ # Requires factories defined in lib/solidus_product_assembly/testing_support/factories.rb
22
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusProductAssembly::Engine)
22
23
 
23
24
  RSpec.configure do |config|
24
25
  config.infer_spec_type_from_file_location!
25
26
  config.use_transactional_fixtures = false
26
- end
27
27
 
28
- Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_headless).to_sym
28
+ if Spree.solidus_gem_version < Gem::Version.new('2.11')
29
+ config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
30
+ end
31
+ end
metadata CHANGED
@@ -1,49 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_product_assembly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Smirnov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-19 00:00:00.000000000 Z
11
+ date: 2023-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: deface
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: solidus_core
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '1.0'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '4'
19
+ version: '3.2'
37
20
  type: :runtime
38
21
  prerelease: false
39
22
  version_requirements: !ruby/object:Gem::Requirement
40
23
  requirements:
41
24
  - - ">="
42
25
  - !ruby/object:Gem::Version
43
- version: '1.0'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '4'
26
+ version: '3.2'
47
27
  - !ruby/object:Gem::Dependency
48
28
  name: solidus_support
49
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,27 +39,13 @@ dependencies:
59
39
  - !ruby/object:Gem::Version
60
40
  version: '0.8'
61
41
  - !ruby/object:Gem::Dependency
62
- name: github_changelog_generator
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: selenium-webdriver
42
+ name: deface
77
43
  requirement: !ruby/object:Gem::Requirement
78
44
  requirements:
79
45
  - - ">="
80
46
  - !ruby/object:Gem::Version
81
47
  version: '0'
82
- type: :development
48
+ type: :runtime
83
49
  prerelease: false
84
50
  version_requirements: !ruby/object:Gem::Requirement
85
51
  requirements:
@@ -90,17 +56,17 @@ dependencies:
90
56
  name: solidus_dev_support
91
57
  requirement: !ruby/object:Gem::Requirement
92
58
  requirements:
93
- - - ">="
59
+ - - "~>"
94
60
  - !ruby/object:Gem::Version
95
- version: '0'
61
+ version: '2.5'
96
62
  type: :development
97
63
  prerelease: false
98
64
  version_requirements: !ruby/object:Gem::Requirement
99
65
  requirements:
100
- - - ">="
66
+ - - "~>"
101
67
  - !ruby/object:Gem::Version
102
- version: '0'
103
- description: Adds oportunity to make bundle of products to your Spree store
68
+ version: '2.5'
69
+ description: Make bundle of products to your Solidus store
104
70
  email: roman@railsdog.com
105
71
  executables: []
106
72
  extensions: []
@@ -110,6 +76,7 @@ files:
110
76
  - ".gem_release.yml"
111
77
  - ".github/dependabot.yml"
112
78
  - ".github/stale.yml"
79
+ - ".github_changelog_generator"
113
80
  - ".gitignore"
114
81
  - ".rspec"
115
82
  - ".rubocop.yml"
@@ -117,15 +84,13 @@ files:
117
84
  - CHANGELOG.md
118
85
  - Gemfile
119
86
  - LICENSE
87
+ - OLD_CHANGELOG.md
120
88
  - README.md
121
89
  - Rakefile
122
90
  - app/assets/images/spinner.gif
123
91
  - app/assets/javascripts/spree/backend/solidus_product_assembly.js
124
- - app/assets/javascripts/spree/frontend/solidus_product_assembly.js
125
92
  - app/assets/stylesheets/spree/backend/solidus_product_assembly.css
126
- - app/assets/stylesheets/spree/frontend/solidus_product_assembly.css
127
93
  - app/controllers/spree/admin/parts_controller.rb
128
- - app/decorators/controllers/solidus_product_assembly/spree/checkout_controller_decorator.rb
129
94
  - app/decorators/helpers/solidus_product_assembly/spree/admin/orders_helper_decorator.rb
130
95
  - app/decorators/models/solidus_product_assembly/spree/inventory_unit_decorator.rb
131
96
  - app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb
@@ -133,6 +98,7 @@ files:
133
98
  - app/decorators/models/solidus_product_assembly/spree/return_item_decorator.rb
134
99
  - app/decorators/models/solidus_product_assembly/spree/shipment_decorator.rb
135
100
  - app/decorators/models/solidus_product_assembly/spree/stock/availability_validator_decorator.rb
101
+ - app/decorators/models/solidus_product_assembly/spree/stock/differentiator_decorator.rb
136
102
  - app/decorators/models/solidus_product_assembly/spree/stock/inventory_unit_builder_decorator.rb
137
103
  - app/decorators/models/solidus_product_assembly/spree/stock/inventory_units_finalizer_decorator.rb
138
104
  - app/decorators/models/solidus_product_assembly/spree/stock/inventory_validator_decorator.rb
@@ -169,6 +135,10 @@ files:
169
135
  - app/views/spree/orders/_cart_description.html.erb
170
136
  - bin/console
171
137
  - bin/rails
138
+ - bin/rails-engine
139
+ - bin/rails-sandbox
140
+ - bin/rake
141
+ - bin/sandbox
172
142
  - bin/setup
173
143
  - config/locales/en.yml
174
144
  - config/locales/fr.yml
@@ -180,7 +150,9 @@ files:
180
150
  - db/migrate/20120316141830_namespace_product_assembly_for_spree_one.rb
181
151
  - db/migrate/20140620223938_add_id_to_spree_assemblies_parts.rb
182
152
  - lib/generators/solidus_product_assembly/install/install_generator.rb
153
+ - lib/generators/solidus_product_assembly/install/templates/initializer.rb
183
154
  - lib/solidus_product_assembly.rb
155
+ - lib/solidus_product_assembly/configuration.rb
184
156
  - lib/solidus_product_assembly/engine.rb
185
157
  - lib/solidus_product_assembly/testing_support/factories.rb
186
158
  - lib/solidus_product_assembly/version.rb
@@ -204,12 +176,13 @@ files:
204
176
  - spec/models/spree/variant_spec.rb
205
177
  - spec/spec_helper.rb
206
178
  - spec/support/shared_contexts/order_with_bundle.rb
207
- homepage: https://solidus.io
179
+ homepage: https://github.com/solidusio-contrib/solidus_product_assembly
208
180
  licenses:
209
181
  - BSD-3-Clause
210
182
  metadata:
211
- homepage_uri: https://solidus.io
183
+ homepage_uri: https://github.com/solidusio-contrib/solidus_product_assembly
212
184
  source_code_uri: https://github.com/solidusio-contrib/solidus_product_assembly
185
+ changelog_uri: https://github.com/solidusio-contrib/solidus_product_assembly/releases
213
186
  post_install_message:
214
187
  rdoc_options: []
215
188
  require_paths:
@@ -218,33 +191,36 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
191
  requirements:
219
192
  - - ">="
220
193
  - !ruby/object:Gem::Version
221
- version: '2.4'
194
+ version: '2.5'
195
+ - - "<"
196
+ - !ruby/object:Gem::Version
197
+ version: '4'
222
198
  required_rubygems_version: !ruby/object:Gem::Requirement
223
199
  requirements:
224
200
  - - ">="
225
201
  - !ruby/object:Gem::Version
226
202
  version: '0'
227
203
  requirements: []
228
- rubygems_version: 3.2.20
204
+ rubygems_version: 3.3.7
229
205
  signing_key:
230
206
  specification_version: 4
231
- summary: Adds oportunity to make bundle of products to your Spree store
207
+ summary: Make bundle of products to your Solidus store
232
208
  test_files:
233
- - spec/spec_helper.rb
234
- - spec/features/admin/return_items_spec.rb
235
- - spec/features/admin/parts_spec.rb
236
209
  - spec/features/admin/orders_spec.rb
210
+ - spec/features/admin/parts_spec.rb
211
+ - spec/features/admin/return_items_spec.rb
237
212
  - spec/features/checkout_spec.rb
238
- - spec/models/spree/shipment_spec.rb
239
- - spec/models/spree/product_spec.rb
240
- - spec/models/spree/variant_spec.rb
241
- - spec/models/spree/order_inventory_assembly_spec.rb
242
- - spec/models/spree/order_contents_spec.rb
243
- - spec/models/spree/line_item_spec.rb
213
+ - spec/models/spree/assemblies_part_spec.rb
244
214
  - spec/models/spree/inventory_unit_spec.rb
245
- - spec/models/spree/stock/coordinator_spec.rb
215
+ - spec/models/spree/line_item_spec.rb
216
+ - spec/models/spree/order_contents_spec.rb
217
+ - spec/models/spree/order_inventory_assembly_spec.rb
218
+ - spec/models/spree/order_inventory_spec.rb
219
+ - spec/models/spree/product_spec.rb
220
+ - spec/models/spree/shipment_spec.rb
246
221
  - spec/models/spree/stock/availability_validator_spec.rb
222
+ - spec/models/spree/stock/coordinator_spec.rb
247
223
  - spec/models/spree/stock/inventory_unit_builder_spec.rb
248
- - spec/models/spree/order_inventory_spec.rb
249
- - spec/models/spree/assemblies_part_spec.rb
224
+ - spec/models/spree/variant_spec.rb
225
+ - spec/spec_helper.rb
250
226
  - spec/support/shared_contexts/order_with_bundle.rb
@@ -1 +0,0 @@
1
- //= require spree/frontend
@@ -1,3 +0,0 @@
1
- /*
2
- *= require spree/frontend
3
- */
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SolidusProductAssembly
4
- module Spree
5
- module CheckoutControllerDecorator
6
- def before_payment; end
7
-
8
- if defined?(::Spree::CheckoutController)
9
- ::Spree::CheckoutController.prepend self
10
- end
11
- end
12
- end
13
- end