spree_core 6.0.1 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/jobs/spree/addresses/geocode_address_job.rb +6 -3
  4. data/app/jobs/spree/variants/remove_line_item_job.rb +5 -0
  5. data/app/models/concerns/spree/admin_user_methods.rb +23 -0
  6. data/app/models/concerns/spree/preference_schema.rb +5 -0
  7. data/app/models/concerns/spree/typed_associations.rb +53 -20
  8. data/app/models/concerns/spree/user_roles.rb +9 -4
  9. data/app/models/spree/address.rb +2 -2
  10. data/app/models/spree/collection.rb +7 -2
  11. data/app/models/spree/order.rb +4 -2
  12. data/app/models/spree/order_promotion.rb +3 -1
  13. data/app/models/spree/payment.rb +16 -1
  14. data/app/models/spree/payment_method/store_credit.rb +3 -1
  15. data/app/models/spree/payment_method.rb +14 -1
  16. data/app/models/spree/payment_source.rb +3 -1
  17. data/app/models/spree/product.rb +15 -5
  18. data/app/models/spree/promotion/actions/create_item_adjustments.rb +1 -1
  19. data/app/models/spree/promotion.rb +11 -3
  20. data/app/models/spree/promotion_handler/cart.rb +7 -1
  21. data/app/models/spree/promotion_handler/coupon.rb +1 -29
  22. data/app/models/spree/refresh_token.rb +26 -0
  23. data/app/models/spree/variant.rb +1 -1
  24. data/app/services/spree/newsletter/subscribe.rb +1 -1
  25. data/app/services/spree/orders/create_from_cart.rb +6 -2
  26. data/app/services/spree/promotions/detach_from_owner.rb +72 -0
  27. data/app/services/spree/stock_reservations/reserve.rb +6 -2
  28. data/app/tools/spree/agent_tools/create_export.rb +3 -1
  29. data/app/tools/spree/agent_tools/create_import.rb +1 -0
  30. data/app/tools/spree/agent_tools/create_media.rb +2 -1
  31. data/app/tools/spree/agent_tools/create_resource.rb +12 -4
  32. data/app/tools/spree/agent_tools/delete_resource.rb +12 -4
  33. data/app/tools/spree/agent_tools/describe_resource.rb +69 -6
  34. data/app/tools/spree/agent_tools/get_resource.rb +7 -4
  35. data/app/tools/spree/agent_tools/resource_write.rb +15 -2
  36. data/app/tools/spree/agent_tools/search_resources.rb +10 -11
  37. data/app/tools/spree/agent_tools/update_resource.rb +6 -6
  38. data/app/tools/spree/agent_tools/upload_file.rb +1 -0
  39. data/app/workflows/spree/carts/complete.rb +4 -1
  40. data/app/workflows/spree/carts/merge.rb +25 -4
  41. data/app/workflows/spree/carts/recalculate.rb +5 -1
  42. data/app/workflows/spree/orders/complete.rb +39 -14
  43. data/app/workflows/spree/products/activate.rb +7 -2
  44. data/app/workflows/spree/products/archive.rb +7 -2
  45. data/app/workflows/spree/products/draft.rb +7 -2
  46. data/app/workflows/spree/products/status_transition.rb +24 -0
  47. data/config/locales/en.yml +3 -0
  48. data/db/migrate/20260809150001_promote_shipping_categories_to_delivery_profiles.rb +15 -6
  49. data/db/migrate/20261030100001_scope_payment_sources_profile_id_uniqueness_to_payment_method.rb +38 -0
  50. data/db/migrate/20261031000001_add_last_active_at_to_spree_admin_users.rb +7 -0
  51. data/db/migrate/20261031100001_delete_orphaned_spree_option_value_variants.rb +10 -0
  52. data/lib/generators/spree/api_resource/api_resource_generator.rb +35 -3
  53. data/lib/generators/spree/api_resource/templates/admin_controller.rb.tt +9 -4
  54. data/lib/generators/spree/api_resource/templates/admin_integration_spec.rb.tt +74 -0
  55. data/lib/generators/spree/api_resource/templates/store_controller.rb.tt +11 -6
  56. data/lib/generators/spree/dummy/dummy_generator.rb +0 -1
  57. data/lib/generators/spree/dummy/templates/rails/database.yml +6 -9
  58. data/lib/generators/spree/dummy/templates/rails/test.rb +9 -5
  59. data/lib/generators/spree/dummy_model/templates/migration.rb.tt +1 -1
  60. data/lib/spree/agent_tool.rb +105 -1
  61. data/lib/spree/agent_tools/default_catalog.rb +16 -21
  62. data/lib/spree/agent_tools/legacy_tools.rb +212 -0
  63. data/lib/spree/agent_tools/operation_catalog.rb +206 -0
  64. data/lib/spree/agent_tools/operation_tool.rb +189 -0
  65. data/lib/spree/agent_tools/registry.rb +65 -31
  66. data/lib/spree/agent_tools/resource_map.rb +128 -5
  67. data/lib/spree/agent_tools.rb +3 -3
  68. data/lib/spree/core/dependencies_helper.rb +96 -40
  69. data/lib/spree/core/engine.rb +2 -1
  70. data/lib/spree/core/version.rb +1 -1
  71. data/lib/spree/core.rb +19 -5
  72. data/lib/spree/testing_support/common_rake.rb +3 -2
  73. data/lib/spree/testing_support/extension_rake.rb +12 -0
  74. data/lib/spree/testing_support/lifecycle_events.rb +1 -3
  75. data/lib/spree/upgrades/5_6_to_6_0/manifest.yml +36 -1
  76. data/lib/tasks/delivery_migration.rake +17 -1
  77. data/lib/tasks/dependencies.rake +2 -2
  78. data/lib/tasks/remove_orphan_order_promotions.rake +20 -0
  79. metadata +19 -69
  80. data/lib/generators/spree/authentication/dummy/dummy_generator.rb +0 -54
  81. data/lib/generators/spree/authentication/dummy/templates/authentication_helpers.rb.tt +0 -52
  82. data/lib/generators/spree/authentication/dummy/templates/create_spree_admin_users.rb.tt +0 -33
  83. data/lib/spree/agent_tools/workflow_endpoints.rb +0 -88
  84. data/lib/spree/agent_tools/workflow_schema.rb +0 -279
  85. data/lib/spree/agent_tools/workflow_tool.rb +0 -654
@@ -5,6 +5,8 @@ module Spree
5
5
  # after_transition, so a handler can veto the change before anything is
6
6
  # written and see the product it applies to.
7
7
  class Activate < Spree::Workflow
8
+ include StatusTransition
9
+
8
10
  hooks :validate, :after_activate
9
11
 
10
12
  # @param product [Spree::Product]
@@ -14,12 +16,15 @@ module Spree
14
16
 
15
17
  run_hooks :validate
16
18
 
17
- ApplicationRecord.transaction do
19
+ moved = ApplicationRecord.transaction do
20
+ next false if already_in?('active')
21
+
18
22
  step :mark_active
19
23
  run_hooks :after_activate
24
+ true
20
25
  end
21
26
 
22
- product.publish_event('product.activated')
27
+ product.publish_event('product.activated') if moved
23
28
  success(product)
24
29
  end
25
30
 
@@ -3,6 +3,8 @@ module Spree
3
3
  # Takes a product off sale for good. Replaces the `archive` state machine
4
4
  # event.
5
5
  class Archive < Spree::Workflow
6
+ include StatusTransition
7
+
6
8
  hooks :validate, :after_archive
7
9
 
8
10
  # @param product [Spree::Product]
@@ -12,13 +14,16 @@ module Spree
12
14
 
13
15
  run_hooks :validate
14
16
 
15
- ApplicationRecord.transaction do
17
+ moved = ApplicationRecord.transaction do
18
+ next false if already_in?('archived')
19
+
16
20
  step :mark_archived
17
21
  step :withdraw_submission
18
22
  run_hooks :after_archive
23
+ true
19
24
  end
20
25
 
21
- product.publish_event('product.archived')
26
+ product.publish_event('product.archived') if moved
22
27
  success(product)
23
28
  end
24
29
 
@@ -3,6 +3,8 @@ module Spree
3
3
  # Returns a product to draft, hiding it from the storefront while it is
4
4
  # worked on. Replaces the `draft` state machine event.
5
5
  class Draft < Spree::Workflow
6
+ include StatusTransition
7
+
6
8
  hooks :validate, :after_draft
7
9
 
8
10
  # @param product [Spree::Product]
@@ -12,17 +14,20 @@ module Spree
12
14
 
13
15
  run_hooks :validate
14
16
 
15
- ApplicationRecord.transaction do
17
+ moved = ApplicationRecord.transaction do
18
+ next false if already_in?('draft')
19
+
16
20
  step :mark_draft
17
21
  step :withdraw_submission
18
22
  run_hooks :after_draft
23
+ true
19
24
  end
20
25
 
21
26
  # Its siblings (Activate, Archive, Propose, Approve, Reject) all
22
27
  # announce themselves, and this one now carries a marketplace meaning
23
28
  # too: taking a listing back withdraws an open submission, which a
24
29
  # seller's integration has the same reason to hear about.
25
- product.publish_event('product.drafted')
30
+ product.publish_event('product.drafted') if moved
26
31
 
27
32
  success(product)
28
33
  end
@@ -0,0 +1,24 @@
1
+ module Spree
2
+ module Products
3
+ # What the status workflows share: whether the product is already in the
4
+ # status a move would put it in, read under a row lock inside the
5
+ # workflow's own transaction.
6
+ #
7
+ # Two requests for the same move otherwise both read the old status, both
8
+ # write the new one and both publish the event, so every webhook
9
+ # subscriber hears of one change twice. With the lock the second waits,
10
+ # finds the move made, and changes nothing.
11
+ #
12
+ # The status is read by query rather than by reloading the product, so a
13
+ # caller's unsaved edits on the record are kept.
14
+ module StatusTransition
15
+ private
16
+
17
+ # @param status [String]
18
+ # @return [Boolean]
19
+ def already_in?(status)
20
+ product.class.where(id: product.id).lock.pick(:status) == status
21
+ end
22
+ end
23
+ end
24
+ end
@@ -900,6 +900,7 @@ en:
900
900
  invalid_status: Invalid status
901
901
  invalid_storefront_access: is not a valid storefront access level
902
902
  items_not_a_list: items must be a list of objects
903
+ missing_row_type: 'is required (expected one of: %{types})'
903
904
  money_preference_too_many_decimals: has more than %{count} decimal places for %{currency}
904
905
  must_be_greater_than_min_amount: must be greater than or equal to the minimum
905
906
  no_pickup_point_provider: this delivery method has no pickup point provider configured
@@ -909,6 +910,7 @@ en:
909
910
  oidc_missing_code: The identity provider did not return an authorization code.
910
911
  oidc_requires_redirect: This provider requires signing in through its own login page.
911
912
  pickup_point_not_found: pickup point could not be found with this provider
913
+ product_in_review: A product awaiting review is approved or rejected, not moved to another status
912
914
  product_not_in_store: must all belong to this store
913
915
  profile_does_not_accept_provider: "%{provider} deliveries cannot join the %{profile} profile"
914
916
  promotion_discount_not_editable: promotion discounts are managed by recalculation and cannot be edited
@@ -924,6 +926,7 @@ en:
924
926
  store_is_already_set: Store is already set
925
927
  unknown_calculator_type: "%{type} is not a calculator offered here"
926
928
  unknown_custom_field_type: 'is not a known custom field type (expected one of: %{types})'
929
+ unknown_row_type: "%{type} is not a %{family} offered here (expected one of: %{types})"
927
930
  unknown_scopes: 'contains unknown scopes: %{scopes}'
928
931
  unregistered_actor: is not a registered actor class
929
932
  variant_product_mismatch: must belong to the same product as the variant
@@ -52,6 +52,7 @@ class PromoteShippingCategoriesToDeliveryProfiles < ActiveRecord::Migration[8.1]
52
52
  remove_column :spree_product_types, :fulfillment_types
53
53
 
54
54
  backfill_store_defaults
55
+ copy_first_zone_onto_methods
55
56
 
56
57
  drop_table :spree_delivery_method_zones
57
58
  end
@@ -141,13 +142,21 @@ class PromoteShippingCategoriesToDeliveryProfiles < ActiveRecord::Migration[8.1]
141
142
  # never carried a category, so they all belong to the default profile.
142
143
  MigrationProduct.where(store_id: store.id, delivery_profile_id: nil).update_all(delivery_profile_id: profile.id)
143
144
 
144
- MigrationMethod.where(store_id: store.id).find_each do |method|
145
- zone_ids = MigrationMethodZone.where(delivery_method_id: method.id).order(:id).pluck(:delivery_zone_id)
146
- if zone_ids.size > 1
147
- say "Delivery method #{method.id} was linked to #{zone_ids.size} zones; keeping the first — recreate the method for the other zones if both were intended."
148
- end
149
- method.update_columns(delivery_profile_id: profile.id, delivery_origin_group_id: origin_group.id, delivery_zone_id: zone_ids.first)
145
+ MigrationMethod.where(store_id: store.id).update_all(delivery_profile_id: profile.id, delivery_origin_group_id: origin_group.id)
146
+ end
147
+ end
148
+
149
+ # Runs for every method, including 5.x rows whose store_id is still nil: the
150
+ # link table is dropped right after, so this is the last chance to keep it.
151
+ def copy_first_zone_onto_methods
152
+ zone_ids_by_method = MigrationMethodZone.order(:id).pluck(:delivery_method_id, :delivery_zone_id).
153
+ group_by(&:first).transform_values { |pairs| pairs.map(&:last) }
154
+
155
+ zone_ids_by_method.each do |method_id, zone_ids|
156
+ if zone_ids.size > 1
157
+ say "Delivery method #{method_id} was linked to #{zone_ids.size} zones; keeping the first — recreate the method for the other zones if both were intended."
150
158
  end
159
+ MigrationMethod.where(id: method_id).update_all(delivery_zone_id: zone_ids.first)
151
160
  end
152
161
  end
153
162
  end
@@ -0,0 +1,38 @@
1
+ class ScopePaymentSourcesProfileIdUniquenessToPaymentMethod < ActiveRecord::Migration[8.1]
2
+ LEGACY_INDEX_NAME = 'index_payment_sources_on_type_and_gateway_payment_profile_id'.freeze
3
+ INDEX_NAME = 'index_payment_sources_on_type_profile_id_and_payment_method'.freeze
4
+
5
+ def up
6
+ remove_index :spree_payment_sources, name: LEGACY_INDEX_NAME
7
+ add_index :spree_payment_sources, [:type, :gateway_payment_profile_id, :payment_method_id],
8
+ unique: true, name: INDEX_NAME
9
+ end
10
+
11
+ # The legacy index cannot come back once a buyer holds the same gateway profile under two
12
+ # payment methods, which is what `up` exists to allow. Checked before anything is dropped so a
13
+ # refusal leaves both indexes intact on MySQL, which has no transactional DDL.
14
+ def down
15
+ if cross_payment_method_duplicates?
16
+ raise ActiveRecord::IrreversibleMigration,
17
+ 'Payment sources share a gateway_payment_profile_id across payment methods, which ' \
18
+ 'the globally unique index cannot represent. Reconcile those rows before rolling back.'
19
+ end
20
+
21
+ remove_index :spree_payment_sources, name: INDEX_NAME
22
+ add_index :spree_payment_sources, [:type, :gateway_payment_profile_id],
23
+ unique: true, name: LEGACY_INDEX_NAME
24
+ end
25
+
26
+ private
27
+
28
+ # NULLs are distinct in a unique index, so only fully populated pairs could ever have collided.
29
+ def cross_payment_method_duplicates?
30
+ connection.select_value(<<~SQL).present?
31
+ SELECT 1 FROM spree_payment_sources
32
+ WHERE type IS NOT NULL AND gateway_payment_profile_id IS NOT NULL
33
+ GROUP BY type, gateway_payment_profile_id
34
+ HAVING COUNT(*) > 1
35
+ LIMIT 1
36
+ SQL
37
+ end
38
+ end
@@ -0,0 +1,7 @@
1
+ # Written whenever a session starts or refreshes (see Spree::RefreshToken), so
2
+ # it outlives the sessions themselves, which signing out deletes.
3
+ class AddLastActiveAtToSpreeAdminUsers < ActiveRecord::Migration[8.1]
4
+ def change
5
+ add_column :spree_admin_users, :last_active_at, :datetime
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ class DeleteOrphanedSpreeOptionValueVariants < ActiveRecord::Migration[8.1]
2
+ # Replacing a variant's option_value_variants used to nullify the old join rows instead of
3
+ # deleting them. Rows with no variant belong to nothing and block new variants from reusing
4
+ # their option values through the uniqueness validation scoped to a NULL variant_id.
5
+ def up
6
+ execute 'DELETE FROM spree_option_value_variants WHERE variant_id IS NULL'
7
+ end
8
+
9
+ def down; end
10
+ end
@@ -169,6 +169,10 @@ module Spree
169
169
  if options[:admin]
170
170
  template 'admin_controller_spec.rb.tt',
171
171
  "spec/controllers/spree/api/v3/admin/#{plural_name}_controller_spec.rb"
172
+ # Documents the endpoints in openapi/admin.yaml (`spree task
173
+ # openapi:generate`): the SDK request types and the agent tools come
174
+ # from there.
175
+ template 'admin_integration_spec.rb.tt', "spec/integration/admin/#{plural_name}_spec.rb"
172
176
  end
173
177
  end
174
178
 
@@ -297,6 +301,9 @@ module Spree
297
301
  if options[:store] || options[:admin]
298
302
  say " #{store_scoped? ? 5 : 4}. Run the specs: pnpm exec spree test spec/controllers/spree/api/v3/"
299
303
  end
304
+ if options[:admin] && !options[:skip_specs]
305
+ say " #{store_scoped? ? 6 : 5}. Document the Admin API (agent tools, SDK types): pnpm exec spree task openapi:generate"
306
+ end
300
307
  say ''
301
308
  end
302
309
 
@@ -344,9 +351,26 @@ module Spree
344
351
  # Attributes the controller permits on write. By default, every column
345
352
  # except references (FKs come through nested), attachments, rich text.
346
353
  def permitted_attribute_names
347
- attributes
348
- .reject { |a| a.reference? || a.attachment? || a.attachments? || a.rich_text? || a.token? || a.password_digest? }
349
- .map(&:name)
354
+ writable_attributes.map(&:name)
355
+ end
356
+
357
+ # @return [Array<Array(String, Symbol, Boolean)>] each writable attribute,
358
+ # its `request_params` type, and whether creating needs it — the model
359
+ # template validates the presence of every one but booleans
360
+ def request_param_attributes
361
+ writable_attributes.map { |a| [a.name, REQUEST_PARAM_TYPES.fetch(a.type, :string), a.type != :boolean] }
362
+ end
363
+
364
+ # Decimal attributes travel as decimal strings (`'1.00'`), never JSON
365
+ # numbers; a money attribute sent as a number is refused.
366
+ #
367
+ # @return [Array<String>]
368
+ def decimal_attribute_names
369
+ writable_attributes.select { |a| a.type == :decimal }.map(&:name)
370
+ end
371
+
372
+ def writable_attributes
373
+ attributes.reject { |a| a.reference? || a.attachment? || a.attachments? || a.rich_text? || a.token? || a.password_digest? }
350
374
  end
351
375
  end
352
376
 
@@ -354,6 +378,14 @@ module Spree
354
378
 
355
379
  INITIALIZER_PATH = 'config/initializers/spree.rb'.freeze
356
380
 
381
+ # A migration column type → the `request_params` type that documents it.
382
+ REQUEST_PARAM_TYPES = {
383
+ string: :string, text: :string, citext: :string,
384
+ integer: :integer, bigint: :integer, float: :number, decimal: :decimal,
385
+ boolean: :boolean, date: :date, datetime: :datetime, timestamp: :datetime,
386
+ json: :hash, jsonb: :hash
387
+ }.freeze
388
+
357
389
  def permission_scope_block
358
390
  <<~RUBY
359
391
 
@@ -9,6 +9,15 @@ module Spree
9
9
  # existing resource name instead if this endpoint belongs under one.
10
10
  scoped_resource :<%= plural_name %>
11
11
 
12
+ # What create and update accept: the controller permits from it, and
13
+ # the integration spec documents it (`request_body_for`), which is
14
+ # where the SDK request types come from.
15
+ request_params :<%= singular_name %> do |body|
16
+ <% request_param_attributes.each do |name, type, required| -%>
17
+ body.attribute :<%= name %>, :<%= type %><%= ', required: true, on: :create' if required %>
18
+ <% end -%>
19
+ end
20
+
12
21
  protected
13
22
 
14
23
  def model_class
@@ -18,10 +27,6 @@ module Spree
18
27
  def serializer_class
19
28
  Spree::Api::V3::Admin::<%= bare_class_name %>Serializer
20
29
  end
21
-
22
- def resource_permitted_attributes
23
- [<%= permitted_attribute_names.map { |a| ":#{a}" }.join(', ') %>]
24
- end
25
30
  end
26
31
  end
27
32
  end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'swagger_helper'
4
+
5
+ # Documents the <%= plural_name.humanize(capitalize: false) %> Admin API in openapi/admin.yaml (`spree task
6
+ # openapi:generate`). The SDK request types come from these operations, and
7
+ # each action other than create, read, update and delete becomes an agent tool.
8
+ RSpec.describe '<%= plural_name.humanize %> Admin API', type: :request, swagger_doc: 'openapi/admin.yaml' do
9
+ let!(:<%= singular_name %>) { create(:<%= singular_name %>) }
10
+
11
+ path '/api/v3/admin/<%= plural_name %>' do
12
+ get 'List <%= plural_name.humanize(capitalize: false) %>' do
13
+ tags '<%= plural_name.humanize %>'
14
+ admin_operation :read, :<%= plural_name %>, description: 'Lists the <%= plural_name.humanize(capitalize: false) %>.'
15
+ parameter name: :page, in: :query, type: :integer, required: false, description: 'Page number'
16
+ parameter name: :limit, in: :query, type: :integer, required: false, description: 'Number of records per page'
17
+ filter_parameters_for
18
+
19
+ response '200', '<%= plural_name.humanize(capitalize: false) %> found' do
20
+ run_test! do |response|
21
+ expect(JSON.parse(response.body)['data'].map { |record| record['id'] }).to include(<%= singular_name %>.prefixed_id)
22
+ end
23
+ end
24
+ end
25
+
26
+ post 'Create a <%= singular_name.humanize(capitalize: false) %>' do
27
+ tags '<%= plural_name.humanize %>'
28
+ admin_operation :write, :<%= plural_name %>, description: 'Creates a <%= singular_name.humanize(capitalize: false) %>.'
29
+ request_body_for
30
+
31
+ response '201', '<%= singular_name.humanize(capitalize: false) %> created' do
32
+ let(:body) { attributes_for(:<%= singular_name %>).slice(<%= permitted_attribute_names.map { |a| ":#{a}" }.join(', ') %>)<%= decimal_attribute_names.map { |a| ".merge(#{a}: '1.00')" }.join %> }
33
+
34
+ run_test!
35
+ end
36
+ end
37
+ end
38
+
39
+ path '/api/v3/admin/<%= plural_name %>/{id}' do
40
+ parameter name: :id, in: :path, type: :string, required: true, description: '<%= singular_name.humanize %> ID'
41
+
42
+ let(:id) { <%= singular_name %>.prefixed_id }
43
+
44
+ get 'Get a <%= singular_name.humanize(capitalize: false) %>' do
45
+ tags '<%= plural_name.humanize %>'
46
+ admin_operation :read, :<%= plural_name %>, description: 'Returns a <%= singular_name.humanize(capitalize: false) %>.'
47
+
48
+ response '200', '<%= singular_name.humanize(capitalize: false) %> found' do
49
+ run_test!
50
+ end
51
+ end
52
+
53
+ patch 'Update a <%= singular_name.humanize(capitalize: false) %>' do
54
+ tags '<%= plural_name.humanize %>'
55
+ admin_operation :write, :<%= plural_name %>, description: 'Updates a <%= singular_name.humanize(capitalize: false) %>.'
56
+ request_body_for
57
+
58
+ response '200', '<%= singular_name.humanize(capitalize: false) %> updated' do
59
+ let(:body) { attributes_for(:<%= singular_name %>).slice(<%= permitted_attribute_names.map { |a| ":#{a}" }.join(', ') %>)<%= decimal_attribute_names.map { |a| ".merge(#{a}: '1.00')" }.join %> }
60
+
61
+ run_test!
62
+ end
63
+ end
64
+
65
+ delete 'Delete a <%= singular_name.humanize(capitalize: false) %>' do
66
+ tags '<%= plural_name.humanize %>'
67
+ admin_operation :write, :<%= plural_name %>, description: 'Deletes a <%= singular_name.humanize(capitalize: false) %>.'
68
+
69
+ response '204', '<%= singular_name.humanize(capitalize: false) %> deleted' do
70
+ run_test!
71
+ end
72
+ end
73
+ end
74
+ end
@@ -3,6 +3,17 @@ module Spree
3
3
  module V3
4
4
  module Store
5
5
  class <%= plural_name.camelize %>Controller < ResourceController
6
+ <% if writable? -%>
7
+ # What create and update accept: the controller permits from it, and
8
+ # the integration spec documents it (`request_body_for`), which is
9
+ # where the SDK request types come from.
10
+ request_params :<%= singular_name %> do |body|
11
+ <% request_param_attributes.each do |name, type, required| -%>
12
+ body.attribute :<%= name %>, :<%= type %><%= ', required: true, on: :create' if required %>
13
+ <% end -%>
14
+ end
15
+
16
+ <% end -%>
6
17
  protected
7
18
 
8
19
  def model_class
@@ -17,12 +28,6 @@ module Spree
17
28
  def serializer_class
18
29
  Spree::Api::V3::<%= bare_class_name %>Serializer
19
30
  end
20
- <% end -%>
21
- <% if writable? -%>
22
-
23
- def resource_permitted_attributes
24
- [<%= permitted_attribute_names.map { |a| ":#{a}" }.join(', ') %>]
25
- end
26
31
  <% end -%>
27
32
  end
28
33
  end
@@ -40,7 +40,6 @@ module Spree
40
40
  args << '--skip-git'
41
41
  args << '--skip-keeps'
42
42
  args << '--skip-rc'
43
- args << '--skip-spring'
44
43
  args << '--skip-test'
45
44
  args << '--skip-bootsnap'
46
45
  args << '--skip-docker'
@@ -1,6 +1,3 @@
1
- <% if agent_number = ENV['TC_AGENT_NUMBER']
2
- database_prefix = agent_number + '_'
3
- end %>
4
1
  <% if options[:lib_name]
5
2
  lib_name = options[:lib_name].gsub('/', '_')
6
3
  end %>
@@ -37,13 +34,13 @@ mysql: &mysql
37
34
 
38
35
  development:
39
36
  <<: *mysql
40
- database: <%= database_prefix %><%= lib_name %>_spree_development
37
+ database: <%= lib_name %>_spree_development
41
38
  test:
42
39
  <<: *mysql
43
- database: <%= database_prefix %><%= lib_name %>_spree_test<%%= ENV['TEST_ENV_NUMBER'] %>
40
+ database: <%= lib_name %>_spree_test<%%= ENV['TEST_ENV_NUMBER'] %>
44
41
  production:
45
42
  <<: *mysql
46
- database: <%= database_prefix %><%= lib_name %>_spree_production
43
+ database: <%= lib_name %>_spree_production
47
44
  <% when 'postgres' %>
48
45
  postgres: &postgres
49
46
  adapter: postgresql
@@ -61,13 +58,13 @@ postgres: &postgres
61
58
 
62
59
  development:
63
60
  <<: *postgres
64
- database: <%= database_prefix %><%= lib_name %>_spree_development
61
+ database: <%= lib_name %>_spree_development
65
62
  test:
66
63
  <<: *postgres
67
- database: <%= database_prefix %><%= lib_name %>_spree_test<%%= ENV['TEST_ENV_NUMBER'] %>
64
+ database: <%= lib_name %>_spree_test<%%= ENV['TEST_ENV_NUMBER'] %>
68
65
  production:
69
66
  <<: *postgres
70
- database: <%= database_prefix %><%= lib_name %>_spree_production
67
+ database: <%= lib_name %>_spree_production
71
68
  <% else %>
72
69
  development:
73
70
  adapter: sqlite3
@@ -1,11 +1,11 @@
1
- Dummy::Application.configure do
1
+ Rails.application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
5
  # test suite. You never need to work with it otherwise. Remember that
6
6
  # your test database is "scratch space" for the test suite and is wiped
7
7
  # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
8
+ config.enable_reloading = false
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
11
  config.public_file_server.enabled = true
@@ -17,8 +17,9 @@ Dummy::Application.configure do
17
17
 
18
18
  config.eager_load = false
19
19
 
20
- # Raise exceptions instead of rendering exception templates
21
- config.action_dispatch.show_exceptions = false
20
+ # Raise unexpected exceptions; render the ones Rails maps to a status, such
21
+ # as a 404 for an unknown route, the way production does.
22
+ config.action_dispatch.show_exceptions = :rescuable
22
23
 
23
24
  # Disable request forgery protection in test environment
24
25
  config.action_controller.allow_forgery_protection = false
@@ -138,7 +139,10 @@ Dummy::Application.configure do
138
139
  %r{/spree/orders/complete\.rb:\d+:in '[^']*#place_sibling'},
139
140
  # Each requested line is priced, stock-checked, saved and taxed as it
140
141
  # is written.
141
- %r{/spree/carts/upsert_items\.rb:\d+:in '[^']*#apply_item'}
142
+ %r{/spree/carts/upsert_items\.rb:\d+:in '[^']*#apply_item'},
143
+ # An import writes each row on its own, inside the request when the
144
+ # import is set to run inline.
145
+ %r{/spree/import_row\.rb:\d+:in '[^']*#process!'}
142
146
  ]
143
147
 
144
148
  # A purchase's billing and shipping addresses, and a transfer's two
@@ -1,4 +1,4 @@
1
- class CreateSpreeDummyModels < ActiveRecord::Migration[5.1]
1
+ class CreateSpreeDummyModels < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
2
  def change
3
3
  create_table :spree_dummy_models do |t|
4
4
  t.string :name