solidus_product_assembly 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +35 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/dependabot.yml +7 -0
  5. data/.github/stale.yml +17 -0
  6. data/.gitignore +14 -2
  7. data/.rspec +2 -2
  8. data/.rubocop.yml +4 -0
  9. data/.rubocop_todo.yml +192 -0
  10. data/CHANGELOG.md +19 -0
  11. data/Gemfile +21 -9
  12. data/LICENSE +26 -0
  13. data/README.md +52 -18
  14. data/Rakefile +4 -19
  15. data/app/controllers/spree/admin/parts_controller.rb +13 -11
  16. data/app/decorators/controllers/solidus_product_assembly/spree/checkout_controller_decorator.rb +13 -0
  17. data/app/decorators/helpers/solidus_product_assembly/spree/admin/orders_helper_decorator.rb +19 -0
  18. data/app/decorators/models/solidus_product_assembly/spree/inventory_unit_decorator.rb +19 -0
  19. data/app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb +52 -0
  20. data/app/decorators/models/solidus_product_assembly/spree/product_decorator.rb +70 -0
  21. data/app/decorators/models/solidus_product_assembly/spree/return_item_decorator.rb +15 -0
  22. data/app/decorators/models/solidus_product_assembly/spree/shipment_decorator.rb +55 -0
  23. data/app/decorators/models/solidus_product_assembly/spree/stock/availability_validator_decorator.rb +37 -0
  24. data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_unit_builder_decorator.rb +39 -0
  25. data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_units_finalizer_decorator.rb +33 -0
  26. data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_validator_decorator.rb +22 -0
  27. data/app/decorators/models/solidus_product_assembly/spree/variant_decorator.rb +26 -0
  28. data/app/models/spree/assemblies_part.rb +6 -4
  29. data/app/models/spree/calculator/returns/assemblies_default_refund_amount.rb +17 -0
  30. data/app/models/spree/order_inventory_assembly.rb +11 -2
  31. data/app/overrides/add_admin_product_form_fields.rb +7 -5
  32. data/app/overrides/add_admin_tabs.rb +7 -5
  33. data/app/overrides/add_line_item_description.rb +7 -5
  34. data/app/overrides/spree/admin/orders/_carton_manifest/_assembly_parts_price.html.erb.deface +9 -0
  35. data/app/overrides/spree/admin/orders/_carton_manifest/_assembly_parts_total_price.html.erb.deface +9 -0
  36. data/app/overrides/spree/admin/orders/_shipment/stock_contents.html.erb.deface +7 -1
  37. data/app/overrides/spree/products/show/add_links_to_parts.html.erb.deface +2 -2
  38. data/app/views/spree/admin/orders/_assemblies.html.erb +8 -17
  39. data/app/views/spree/admin/orders/_stock_contents.html.erb +2 -62
  40. data/app/views/spree/admin/orders/_stock_contents_2_3.html.erb +69 -0
  41. data/app/views/spree/admin/orders/_stock_contents_2_4.html.erb +70 -0
  42. data/app/views/spree/admin/orders/_stock_item.html.erb +13 -10
  43. data/app/views/spree/admin/parts/_parts_table.html.erb +17 -11
  44. data/app/views/spree/admin/parts/available.html.erb +10 -8
  45. data/app/views/spree/admin/parts/available.js.erb +9 -7
  46. data/app/views/spree/admin/parts/index.html.erb +1 -1
  47. data/app/views/spree/admin/products/_product_assembly_fields.html.erb +2 -2
  48. data/app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb +1 -1
  49. data/app/views/spree/api/line_items/show.v1.rabl +27 -0
  50. data/app/views/spree/checkout/_line_item_manifest.html.erb +3 -1
  51. data/bin/console +17 -0
  52. data/bin/rails +12 -4
  53. data/bin/setup +8 -0
  54. data/config/routes.rb +2 -2
  55. data/db/migrate/20091028152124_add_many_to_many_relation_to_products.rb +7 -5
  56. data/db/migrate/20091029165620_add_parts_fields_to_products.rb +18 -16
  57. data/db/migrate/20120316141830_namespace_product_assembly_for_spree_one.rb +3 -1
  58. data/db/migrate/20140620223938_add_id_to_spree_assemblies_parts.rb +4 -2
  59. data/lib/generators/solidus_product_assembly/install/install_generator.rb +13 -8
  60. data/lib/solidus_product_assembly/engine.rb +11 -8
  61. data/lib/solidus_product_assembly/testing_support/factories.rb +4 -0
  62. data/lib/solidus_product_assembly/version.rb +3 -1
  63. data/lib/solidus_product_assembly.rb +5 -1
  64. data/lib/tasks/spree2_upgrade.rake +12 -12
  65. data/solidus_product_assembly.gemspec +25 -20
  66. data/spec/features/admin/orders_spec.rb +114 -16
  67. data/spec/features/admin/parts_spec.rb +5 -3
  68. data/spec/features/admin/return_items_spec.rb +151 -0
  69. data/spec/features/checkout_spec.rb +103 -21
  70. data/spec/models/spree/assemblies_part_spec.rb +3 -1
  71. data/spec/models/spree/inventory_unit_spec.rb +15 -6
  72. data/spec/models/spree/line_item_spec.rb +6 -4
  73. data/spec/models/spree/order_contents_spec.rb +6 -5
  74. data/spec/models/spree/order_inventory_assembly_spec.rb +8 -6
  75. data/spec/models/spree/order_inventory_spec.rb +7 -3
  76. data/spec/models/spree/product_spec.rb +15 -14
  77. data/spec/models/spree/shipment_spec.rb +20 -13
  78. data/spec/models/spree/stock/availability_validator_spec.rb +22 -33
  79. data/spec/models/spree/stock/coordinator_spec.rb +11 -3
  80. data/spec/models/spree/stock/inventory_unit_builder_spec.rb +5 -7
  81. data/spec/models/spree/variant_spec.rb +3 -1
  82. data/spec/spec_helper.rb +18 -47
  83. data/spec/support/shared_contexts/order_with_bundle.rb +2 -0
  84. metadata +80 -102
  85. data/.travis.yml +0 -21
  86. data/LICENSE.md +0 -13
  87. data/app/controllers/spree/checkout_controller_decorator.rb +0 -9
  88. data/app/helpers/spree/admin/orders_helper_decorator.rb +0 -9
  89. data/app/models/spree/inventory_unit_decorator.rb +0 -13
  90. data/app/models/spree/line_item_decorator.rb +0 -44
  91. data/app/models/spree/product_decorator.rb +0 -56
  92. data/app/models/spree/shipment_decorator.rb +0 -50
  93. data/app/models/spree/stock/availability_validator.rb +0 -28
  94. data/app/models/spree/stock/inventory_unit_builder_decorator.rb +0 -30
  95. data/app/models/spree/stock/inventory_validator_decorator.rb +0 -12
  96. data/app/models/spree/variant_decorator.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 89f3f4fbf3c8638a1d3a0eb8daeec71ab2e0be2c
4
- data.tar.gz: e67518d457ee0aa60495099b41e058b917f36472
2
+ SHA256:
3
+ metadata.gz: d61612432f21d73321086ff0d33ae48e3d9f9d81aa5107ad377eb22beeddb08b
4
+ data.tar.gz: b849af2369bc531a1c6270e28f1a36827f2b1883b80984a3c5372edeab4f407e
5
5
  SHA512:
6
- metadata.gz: a4dae9aac9db62b23daca17315e84596f8da6421269ba816e8f17b6ac100e0c5916692d09e5f701c69b09972f65afe538fb231bd325bbf6e37690d48e8827c25
7
- data.tar.gz: ff2051e5a167ef6f1d4d7fce18d302baef6952e94f22df48115242ee5e9d9037170e93b99ab47e91ebd794e115dba79527db152c174ffd6f4659cdabcdb96003
6
+ metadata.gz: b02fd5570c1cdc3a8337ce5938141a8df21b25752bda01e3e157a7fdbf07503342ccc43e87607aa775c29b706181450b7c932c4931403f896e4a3053bb248e36
7
+ data.tar.gz: 8f2c61439371cd9f425fa215edf1473c1607a06da73032946c4a7677baa123d0e719f7cf76e4715e4f998474f571a223dc73474317b1550a958b6a41f531cb5d
@@ -0,0 +1,35 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ # Always take the latest version of the orb, this allows us to
5
+ # run specs against Solidus supported versions only without the need
6
+ # to change this configuration every time a Solidus version is released
7
+ # or goes EOL.
8
+ solidusio_extensions: solidusio/extensions@volatile
9
+
10
+ jobs:
11
+ run-specs-with-postgres:
12
+ executor: solidusio_extensions/postgres
13
+ steps:
14
+ - solidusio_extensions/run-tests
15
+ run-specs-with-mysql:
16
+ executor: solidusio_extensions/mysql
17
+ steps:
18
+ - solidusio_extensions/run-tests
19
+
20
+ workflows:
21
+ "Run specs on supported Solidus versions":
22
+ jobs:
23
+ - run-specs-with-postgres
24
+ - run-specs-with-mysql
25
+ "Weekly run specs against master":
26
+ triggers:
27
+ - schedule:
28
+ cron: "0 0 * * 4" # every Thursday
29
+ filters:
30
+ branches:
31
+ only:
32
+ - master
33
+ jobs:
34
+ - run-specs-with-postgres
35
+ - run-specs-with-mysql
data/.gem_release.yml ADDED
@@ -0,0 +1,5 @@
1
+ bump:
2
+ recurse: false
3
+ file: 'lib/solidus_product_assembly/version.rb'
4
+ message: Bump SolidusProductAssembly to %{version}
5
+ tag: true
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
data/.github/stale.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: wontfix
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
data/.gitignore CHANGED
@@ -1,4 +1,16 @@
1
- spec/dummy
2
- Gemfile.lock
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
3
9
  coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
4
16
  spec/examples.txt
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
1
  --color
2
- --format
3
- progress
2
+ --format progress
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ require:
2
+ - solidus_dev_support/rubocop
3
+
4
+ inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,192 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-01-22 17:16:56 +0100 using RuboCop version 0.76.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ # Cop supports --auto-correct.
11
+ Capybara/CurrentPathExpectation:
12
+ Exclude:
13
+ - 'spec/features/checkout_spec.rb'
14
+
15
+ # Offense count: 2
16
+ # Cop supports --auto-correct.
17
+ # Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
18
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
19
+ Layout/EndAlignment:
20
+ Exclude:
21
+ - 'db/migrate/20091029165620_add_parts_fields_to_products.rb'
22
+
23
+ # Offense count: 1
24
+ Lint/AmbiguousBlockAssociation:
25
+ Exclude:
26
+ - 'spec/models/spree/order_inventory_spec.rb'
27
+
28
+ # Offense count: 2
29
+ Lint/AmbiguousOperator:
30
+ Exclude:
31
+ - 'app/views/spree/api/line_items/show.v1.rabl'
32
+ - 'lib/solidus_product_assembly/engine.rb'
33
+
34
+ # Offense count: 4
35
+ Lint/ShadowingOuterLocalVariable:
36
+ Exclude:
37
+ - 'app/decorators/models/solidus_product_assembly/spree/shipment_decorator.rb'
38
+ - 'app/models/spree/order_inventory_assembly.rb'
39
+ - 'lib/tasks/spree2_upgrade.rake'
40
+
41
+ # Offense count: 3
42
+ # Cop supports --auto-correct.
43
+ # Configuration parameters: AutoCorrect.
44
+ Performance/TimesMap:
45
+ Exclude:
46
+ - 'app/decorators/models/solidus_product_assembly/spree/stock/inventory_unit_builder_decorator.rb'
47
+ - 'spec/models/spree/shipment_spec.rb'
48
+
49
+ # Offense count: 4
50
+ RSpec/AnyInstance:
51
+ Exclude:
52
+ - 'spec/features/admin/return_items_spec.rb'
53
+ - 'spec/models/spree/stock/availability_validator_spec.rb'
54
+
55
+ # Offense count: 42
56
+ # Configuration parameters: Prefixes.
57
+ # Prefixes: when, with, without
58
+ RSpec/ContextWording:
59
+ Exclude:
60
+ - 'spec/features/admin/orders_spec.rb'
61
+ - 'spec/features/checkout_spec.rb'
62
+ - 'spec/models/spree/assemblies_part_spec.rb'
63
+ - 'spec/models/spree/inventory_unit_spec.rb'
64
+ - 'spec/models/spree/line_item_spec.rb'
65
+ - 'spec/models/spree/order_contents_spec.rb'
66
+ - 'spec/models/spree/order_inventory_assembly_spec.rb'
67
+ - 'spec/models/spree/order_inventory_spec.rb'
68
+ - 'spec/models/spree/shipment_spec.rb'
69
+ - 'spec/models/spree/stock/availability_validator_spec.rb'
70
+ - 'spec/models/spree/stock/coordinator_spec.rb'
71
+ - 'spec/models/spree/stock/inventory_unit_builder_spec.rb'
72
+ - 'spec/models/spree/variant_spec.rb'
73
+ - 'spec/support/shared_contexts/order_with_bundle.rb'
74
+
75
+ # Offense count: 9
76
+ RSpec/ExpectInHook:
77
+ Exclude:
78
+ - 'spec/features/checkout_spec.rb'
79
+ - 'spec/models/spree/line_item_spec.rb'
80
+
81
+ # Offense count: 14
82
+ # Configuration parameters: AssignmentOnly.
83
+ RSpec/InstanceVariable:
84
+ Exclude:
85
+ - 'spec/models/spree/product_spec.rb'
86
+
87
+ # Offense count: 13
88
+ RSpec/LetSetup:
89
+ Exclude:
90
+ - 'spec/features/checkout_spec.rb'
91
+ - 'spec/models/spree/order_contents_spec.rb'
92
+ - 'spec/models/spree/order_inventory_spec.rb'
93
+ - 'spec/models/spree/shipment_spec.rb'
94
+ - 'spec/models/spree/stock/availability_validator_spec.rb'
95
+ - 'spec/models/spree/stock/coordinator_spec.rb'
96
+
97
+ # Offense count: 9
98
+ # Configuration parameters: .
99
+ # SupportedStyles: have_received, receive
100
+ RSpec/MessageSpies:
101
+ EnforcedStyle: receive
102
+
103
+ # Offense count: 19
104
+ # Configuration parameters: AggregateFailuresByDefault.
105
+ RSpec/MultipleExpectations:
106
+ Max: 14
107
+
108
+ # Offense count: 22
109
+ # Configuration parameters: IgnoreSharedExamples.
110
+ RSpec/NamedSubject:
111
+ Exclude:
112
+ - 'spec/models/spree/assemblies_part_spec.rb'
113
+ - 'spec/models/spree/inventory_unit_spec.rb'
114
+ - 'spec/models/spree/order_contents_spec.rb'
115
+ - 'spec/models/spree/order_inventory_assembly_spec.rb'
116
+ - 'spec/models/spree/order_inventory_spec.rb'
117
+ - 'spec/models/spree/stock/availability_validator_spec.rb'
118
+ - 'spec/models/spree/stock/coordinator_spec.rb'
119
+ - 'spec/models/spree/stock/inventory_unit_builder_spec.rb'
120
+
121
+ # Offense count: 2
122
+ RSpec/NestedGroups:
123
+ Max: 5
124
+
125
+ # Offense count: 3
126
+ RSpec/ScatteredLet:
127
+ Exclude:
128
+ - 'spec/models/spree/order_inventory_spec.rb'
129
+
130
+ # Offense count: 1
131
+ RSpec/SubjectStub:
132
+ Exclude:
133
+ - 'spec/models/spree/stock/availability_validator_spec.rb'
134
+
135
+ # Offense count: 2
136
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
137
+ RSpec/VerifiedDoubles:
138
+ Exclude:
139
+ - 'spec/models/spree/line_item_spec.rb'
140
+ - 'spec/models/spree/stock/availability_validator_spec.rb'
141
+
142
+ # Offense count: 1
143
+ # Configuration parameters: Include.
144
+ # Include: db/migrate/*.rb
145
+ Rails/CreateTableWithTimestamps:
146
+ Exclude:
147
+ - 'db/migrate/20091028152124_add_many_to_many_relation_to_products.rb'
148
+
149
+ # Offense count: 2
150
+ # Configuration parameters: Include.
151
+ # Include: app/models/**/*.rb
152
+ Rails/InverseOf:
153
+ Exclude:
154
+ - 'app/models/spree/assemblies_part.rb'
155
+
156
+ # Offense count: 8
157
+ # Configuration parameters: Blacklist, Whitelist.
158
+ # Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
159
+ Rails/SkipsModelValidations:
160
+ Exclude:
161
+ - 'lib/tasks/spree2_upgrade.rake'
162
+ - 'spec/features/admin/return_items_spec.rb'
163
+ - 'spec/features/checkout_spec.rb'
164
+ - 'spec/models/spree/line_item_spec.rb'
165
+ - 'spec/models/spree/order_contents_spec.rb'
166
+ - 'spec/models/spree/order_inventory_spec.rb'
167
+ - 'spec/models/spree/shipment_spec.rb'
168
+ - 'spec/models/spree/stock/coordinator_spec.rb'
169
+
170
+ # Offense count: 2
171
+ # Cop supports --auto-correct.
172
+ # Configuration parameters: AutoCorrect, EnforcedStyle.
173
+ # SupportedStyles: nested, compact
174
+ Style/ClassAndModuleChildren:
175
+ Exclude:
176
+ - 'app/controllers/spree/admin/parts_controller.rb'
177
+ - 'app/models/spree/calculator/returns/assemblies_default_refund_amount.rb'
178
+
179
+ # Offense count: 3
180
+ # Configuration parameters: MinBodyLength.
181
+ Style/GuardClause:
182
+ Exclude:
183
+ - 'app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb'
184
+ - 'app/decorators/models/solidus_product_assembly/spree/stock/inventory_validator_decorator.rb'
185
+ - 'app/models/spree/order_inventory_assembly.rb'
186
+
187
+ # Offense count: 26
188
+ # Cop supports --auto-correct.
189
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
190
+ # URISchemes: http, https
191
+ Metrics/LineLength:
192
+ Max: 146
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ ## [v1.0.0](https://github.com/solidusio-contrib/solidus_product_assembly/tree/v1.0.0) (2016-09-06)
2
+ **Closed issues:**
3
+
4
+ - Inventory Validation fail upon checkout, for the assembly product [\#3](https://github.com/solidusio-contrib/solidus_product_assembly/issues/3)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - Add support for Solidus 2.0 and Rails 5 [\#10](https://github.com/solidusio-contrib/solidus_product_assembly/pull/10) ([jhawthorn](https://github.com/jhawthorn))
9
+ - Fix installation instructions in README [\#9](https://github.com/solidusio-contrib/solidus_product_assembly/pull/9) ([alexblackie](https://github.com/alexblackie))
10
+ - Add missing translation for actions.delete [\#8](https://github.com/solidusio-contrib/solidus_product_assembly/pull/8) ([Sinetheta](https://github.com/Sinetheta))
11
+ - Fix a load order issue when redefining inventory validator. [\#7](https://github.com/solidusio-contrib/solidus_product_assembly/pull/7) ([Senjai](https://github.com/Senjai))
12
+ - Fix product sub\_menu display on new Solidus [\#6](https://github.com/solidusio-contrib/solidus_product_assembly/pull/6) ([Sinetheta](https://github.com/Sinetheta))
13
+ - Inventory validation [\#5](https://github.com/solidusio-contrib/solidus_product_assembly/pull/5) ([Sinetheta](https://github.com/Sinetheta))
14
+ - Rename to solidus\_product\_assembly [\#2](https://github.com/solidusio-contrib/solidus_product_assembly/pull/2) ([Sinetheta](https://github.com/Sinetheta))
15
+ - Upgrade from spree 2.4 to solidus 1.1-1.3 [\#1](https://github.com/solidusio-contrib/solidus_product_assembly/pull/1) ([Sinetheta](https://github.com/Sinetheta))
16
+
17
+
18
+
19
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile CHANGED
@@ -1,18 +1,30 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
2
5
 
3
6
  branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
4
- gem "solidus", github: "solidusio/solidus", branch: branch
7
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
8
+
9
+ # Provides basic authentication functionality for testing parts of your engine
5
10
  gem 'solidus_auth_devise'
6
11
 
7
- if branch == 'master' || branch >= "v2.0"
8
- gem "rails-controller-testing", group: :test
12
+ case ENV['DB']
13
+ when 'mysql'
14
+ gem 'mysql2'
15
+ when 'postgresql'
16
+ gem 'pg'
17
+ else
18
+ gem 'sqlite3'
9
19
  end
10
20
 
11
- gem 'pg'
12
- gem 'mysql2'
13
-
14
- group :development, :test do
15
- gem "pry-rails"
21
+ group :test do
22
+ gem 'webdrivers'
23
+ gem 'selenium-webdriver'
16
24
  end
17
25
 
18
26
  gemspec
27
+
28
+ # Use a local Gemfile to include development dependencies that might not be
29
+ # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
30
+ eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2020 Spree Commerce Inc. and other contributors.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Solidus nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -1,33 +1,23 @@
1
1
  # Product Assembly
2
2
 
3
- [![Build Status](https://travis-ci.org/solidusio-contrib/solidus_product_assembly.svg?branch=master)](https://travis-ci.org/solidusio-contrib/solidus_product_assembly)
3
+ [![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_product_assembly.svg?style=svg)](https://circleci.com/gh/solidusio-contrib/solidus_product_assembly)
4
4
 
5
5
  Create a product which is composed of other products.
6
6
 
7
7
  ## Installation
8
8
 
9
- Add the following line to your `Gemfile`
9
+ Add the following line to your `Gemfile`:
10
+
10
11
  ```ruby
11
12
  gem 'solidus_product_assembly', github: 'solidusio-contrib/solidus_product_assembly', branch: 'master'
12
13
  ```
13
14
 
14
15
  Run bundle install as well as the extension intall command to copy and run migrations and
15
- append solidus_product_assembly to your js manifest file
16
+ append solidus_product_assembly to your js manifest file:
16
17
 
17
18
  bundle install
18
19
  rails g solidus_product_assembly:install
19
20
 
20
- _master branch is compatible with spree edge and rails 4 only. Please use
21
- 2-0-stable for Spree 2.0.x or 1-3-stable branch for Spree 1.3.x compatibility_
22
-
23
- _In case you're upgrading from 1-3-stable of this extension you might want to run a
24
- rake task which assigns a line item to your previous inventory units from bundle
25
- products. That is so you have a better view on the current backend UI and avoid
26
- exceptions. No need to run this task if you're not upgrading from product assembly
27
- 1-3-stable_
28
-
29
- rake solidus_product_assembly:upgrade
30
-
31
21
  ## Use
32
22
 
33
23
  To build a bundle (assembly product) you'd need to first check the "Can be part"
@@ -40,10 +30,54 @@ That means you essentially have a product composed of other products. From a
40
30
  customer perspective it's like they are paying a single amount for a collection
41
31
  of products.
42
32
 
43
- Contributing
44
- ------------
33
+ ## Releasing a new version
34
+
35
+ #### 1. Bump gem version and push to RubyGems
36
+
37
+ We use [gem-release](https://github.com/svenfuchs/gem-release) to release this
38
+ extension with ease.
39
+
40
+ Supposing you are on the master branch and you are working on a fork of this
41
+ extension, `upstream` is the main remote and you have write access to it, you
42
+ can simply run:
43
+
44
+ ```bash
45
+ gem bump --version minor --tag --release
46
+ ```
47
+
48
+ This command will:
49
+
50
+ - bump the gem version to the next minor (changing the `version.rb` file)
51
+ - commit the change and push it to upstream master
52
+ - create a git tag
53
+ - push the tag to the upstream remote
54
+ - release the new version on RubyGems
55
+
56
+ Or you can run these commands individually:
57
+
58
+ ```bash
59
+ gem bump --version minor
60
+ gem tag
61
+ gem release
62
+ ```
63
+
64
+ #### 2. Publish the updated CHANGELOG
65
+
66
+ After the release is done we can generate the updated CHANGELOG
67
+ using
68
+ [github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator)
69
+ by running the following command:
70
+
71
+
72
+ ```bash
73
+ bundle exec github_changelog_generator solidusio/solidus_auth_devise --token YOUR_GITHUB_TOKEN
74
+ git commit -am 'Update CHANGELOG'
75
+ git push upstream master
76
+ ```
77
+
78
+ ## Contributing
45
79
 
46
- Spree is an open source project and we encourage contributions. Please see the [contributors guidelines][1] before contributing.
80
+ Spree is an open source project and we encourage contributions. Please see the [Community Guidelines][1] before contributing.
47
81
 
48
82
  In the spirit of [free software][2], **everyone** is encouraged to help improve this project.
49
83
 
@@ -72,7 +106,7 @@ Starting point:
72
106
 
73
107
  Copyright (c) 2014 [Spree Commerce Inc.][4] and [contributors][5], released under the [New BSD License][6]
74
108
 
75
- [1]: http://guides.spreecommerce.com/developer/contributing.html
109
+ [1]: https://solidus.io/community-guidelines/
76
110
  [2]: http://www.fsf.org/licensing/essays/free-sw.html
77
111
  [3]: https://github.com/spree/spree-product-assembly/issues
78
112
  [4]: https://github.com/spree
data/Rakefile CHANGED
@@ -1,21 +1,6 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
1
+ # frozen_string_literal: true
3
2
 
4
- require 'rspec/core/rake_task'
5
- require 'spree/testing_support/common_rake'
3
+ require 'solidus_dev_support/rake_tasks'
4
+ SolidusDevSupport::RakeTasks.install
6
5
 
7
- RSpec::Core::RakeTask.new
8
-
9
- task :default do
10
- if Dir["spec/dummy"].empty?
11
- Rake::Task[:test_app].invoke
12
- Dir.chdir("../../")
13
- end
14
- Rake::Task[:spec].invoke
15
- end
16
-
17
- desc 'Generates a dummy app for testing'
18
- task :test_app do
19
- ENV['LIB_NAME'] = 'solidus_product_assembly'
20
- Rake::Task['common:test_app'].invoke("Spree::User")
21
- end
6
+ task default: 'extension:specs'
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Spree::Admin::PartsController < Spree::Admin::BaseController
2
- before_filter :find_product
4
+ before_action :find_product
3
5
 
4
6
  def index
5
7
  @parts = @product.parts
@@ -22,12 +24,11 @@ class Spree::Admin::PartsController < Spree::Admin::BaseController
22
24
  @available_products = []
23
25
  else
24
26
  query = "%#{params[:q]}%"
25
- @available_products = Spree::Product.search_can_be_part(query)
26
- @available_products.uniq!
27
+ @available_products = Spree::Product.search_can_be_part(query).distinct
27
28
  end
28
29
  respond_to do |format|
29
- format.html {render :layout => false}
30
- format.js {render :layout => false}
30
+ format.html { render layout: false }
31
+ format.js { render layout: false }
31
32
  end
32
33
  end
33
34
 
@@ -39,11 +40,12 @@ class Spree::Admin::PartsController < Spree::Admin::BaseController
39
40
  end
40
41
 
41
42
  private
42
- def find_product
43
- @product = Spree::Product.find_by(slug: params[:product_id])
44
- end
45
43
 
46
- def model_class
47
- Spree::AssembliesPart
48
- end
44
+ def find_product
45
+ @product = Spree::Product.find_by(slug: params[:product_id])
46
+ end
47
+
48
+ def model_class
49
+ Spree::AssembliesPart
50
+ end
49
51
  end
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusProductAssembly
4
+ module Spree
5
+ module Admin
6
+ module OrdersHelperDecorator
7
+ def self.prepended(base)
8
+ base.module_eval do
9
+ def line_item_shipment_price(line_item, quantity)
10
+ ::Spree::Money.new(line_item.price * quantity, currency: line_item.currency)
11
+ end
12
+ end
13
+ end
14
+
15
+ ::Spree::Admin::OrdersHelper.prepend self
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusProductAssembly
4
+ module Spree
5
+ module InventoryUnitDecorator
6
+ def percentage_of_line_item
7
+ product = line_item.product
8
+ if product.assembly?
9
+ total_value = line_item.quantity_by_variant.map { |part, quantity| part.price * quantity }.sum
10
+ variant.price / total_value
11
+ else
12
+ 1 / BigDecimal(line_item.quantity)
13
+ end
14
+ end
15
+
16
+ ::Spree::InventoryUnit.prepend self
17
+ end
18
+ end
19
+ end