From 2cb9ac17f7ee012b4dd0b195e0367ec83687d8a3 Mon Sep 17 00:00:00 2001 From: Adam Mueller Date: Wed, 27 Nov 2024 15:06:56 -0800 Subject: [PATCH 1/8] Add inverse_of to Promotion#codes association This helps fix an issue when creating a new promotion with a single code. Without the inverse_of parameter, our associated codes won't correctly infer that they're associated to a new promotion and will generate undefined method for nil errors. Co-authored-by: Alistair Norman --- promotions/app/models/solidus_promotions/promotion.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promotions/app/models/solidus_promotions/promotion.rb b/promotions/app/models/solidus_promotions/promotion.rb index e36015facac..7eacbbf61af 100644 --- a/promotions/app/models/solidus_promotions/promotion.rb +++ b/promotions/app/models/solidus_promotions/promotion.rb @@ -9,7 +9,7 @@ class Promotion < Spree::Base belongs_to :original_promotion, class_name: "Spree::Promotion", optional: true has_many :benefits, class_name: "SolidusPromotions::Benefit", dependent: :destroy has_many :conditions, through: :benefits - has_many :codes, class_name: "SolidusPromotions::PromotionCode", dependent: :destroy + has_many :codes, class_name: "SolidusPromotions::PromotionCode", dependent: :destroy, inverse_of: :promotion has_many :code_batches, class_name: "SolidusPromotions::PromotionCodeBatch", dependent: :destroy has_many :order_promotions, class_name: "SolidusPromotions::OrderPromotion", dependent: :destroy From 6ea8b43348e999ca740692c88695536c740aa0c8 Mon Sep 17 00:00:00 2001 From: Adam Mueller Date: Wed, 27 Nov 2024 15:11:58 -0800 Subject: [PATCH 2/8] Fix model class for new PromotionCodesController Unfortunately, our resource controller is hardcoded to look for a `Spree::` object, which obviously doesn't work with the new promotion namespace. Co-authored-by: Alistair Norman --- .../solidus_promotions/admin/promotion_codes_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/promotions/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb b/promotions/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb index ee23a457469..0310fc54ceb 100644 --- a/promotions/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb +++ b/promotions/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb @@ -48,6 +48,10 @@ def create private + def model_class + SolidusPromotions::PromotionCode + end + def load_promotion @promotion = SolidusPromotions::Promotion .accessible_by(current_ability, :show) From e306a14b20ead63d7b13f6faedee20a28846f0c5 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Wed, 20 Nov 2024 15:52:31 +0100 Subject: [PATCH 3/8] Chore(Legacy Promotions): Rename decorators If we want to use these decorators with Zeitwerk, their naming scheme has to exchange module name and type. For example, app/decorators/solidus_legacy_promotions/models/line_item_decorator.rb becomes app/decorators/models/solidus/legacy_promotions/line_item_decorator.rb This will eventually allow us to use Zeitwerk for loading decorators. --- .../solidus_admin_adjustments_controller_decorator.rb | 0 .../spree_order_state_machine_decorator.rb | 0 .../solidus_legacy_promotions}/spree_adjustment_decorator.rb | 0 .../spree_calculator_returns_default_refund_amount_decorator.rb | 0 .../solidus_legacy_promotions}/spree_line_item_decorator.rb | 0 .../solidus_legacy_promotions}/spree_order_decorator.rb | 0 .../solidus_legacy_promotions}/spree_order_updater_decorator.rb | 0 .../solidus_legacy_promotions}/spree_product_decorator.rb | 0 .../solidus_legacy_promotions}/spree_shipment_decorator.rb | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/controllers/solidus_admin => controllers/solidus_legacy_promotions}/solidus_admin_adjustments_controller_decorator.rb (100%) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/lib => lib/solidus_legacy_promotions}/spree_order_state_machine_decorator.rb (100%) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/models => models/solidus_legacy_promotions}/spree_adjustment_decorator.rb (100%) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/models => models/solidus_legacy_promotions}/spree_calculator_returns_default_refund_amount_decorator.rb (100%) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/models => models/solidus_legacy_promotions}/spree_line_item_decorator.rb (100%) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/models => models/solidus_legacy_promotions}/spree_order_decorator.rb (100%) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/models => models/solidus_legacy_promotions}/spree_order_updater_decorator.rb (100%) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/models => models/solidus_legacy_promotions}/spree_product_decorator.rb (100%) rename legacy_promotions/app/decorators/{solidus_legacy_promotions/models => models/solidus_legacy_promotions}/spree_shipment_decorator.rb (100%) diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/controllers/solidus_admin/solidus_admin_adjustments_controller_decorator.rb b/legacy_promotions/app/decorators/controllers/solidus_legacy_promotions/solidus_admin_adjustments_controller_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/controllers/solidus_admin/solidus_admin_adjustments_controller_decorator.rb rename to legacy_promotions/app/decorators/controllers/solidus_legacy_promotions/solidus_admin_adjustments_controller_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/lib/spree_order_state_machine_decorator.rb b/legacy_promotions/app/decorators/lib/solidus_legacy_promotions/spree_order_state_machine_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/lib/spree_order_state_machine_decorator.rb rename to legacy_promotions/app/decorators/lib/solidus_legacy_promotions/spree_order_state_machine_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_adjustment_decorator.rb b/legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_adjustment_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_adjustment_decorator.rb rename to legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_adjustment_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_calculator_returns_default_refund_amount_decorator.rb b/legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_calculator_returns_default_refund_amount_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_calculator_returns_default_refund_amount_decorator.rb rename to legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_calculator_returns_default_refund_amount_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_line_item_decorator.rb b/legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_line_item_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_line_item_decorator.rb rename to legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_line_item_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb b/legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_order_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb rename to legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_order_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_order_updater_decorator.rb b/legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_order_updater_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_order_updater_decorator.rb rename to legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_order_updater_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_product_decorator.rb b/legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_product_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_product_decorator.rb rename to legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_product_decorator.rb diff --git a/legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_shipment_decorator.rb b/legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_shipment_decorator.rb similarity index 100% rename from legacy_promotions/app/decorators/solidus_legacy_promotions/models/spree_shipment_decorator.rb rename to legacy_promotions/app/decorators/models/solidus_legacy_promotions/spree_shipment_decorator.rb From 42d65fdac014b4cfe390a4ea57bf5c1fd19d6dd3 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Tue, 3 Dec 2024 11:05:59 +0100 Subject: [PATCH 4/8] Fix(promotions): Validate benefits on save On Slack, we got a report that the tiered percent calculator wasn't converting its tiers to BigDecimal when being first created. Since this conversion happens `before_validation`, we should not turn validation off in this controller. Specs still run through. --- .../backend/solidus_promotions/admin/benefits_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb b/promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb index cd0f40da056..10a24ef10b4 100644 --- a/promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb +++ b/promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb @@ -14,7 +14,7 @@ def new def create @benefit = @benefit_type.new(benefit_params) @benefit.promotion = @promotion - if @benefit.save(validate: false) + if @benefit.save flash[:success] = t("spree.successfully_created", resource: SolidusPromotions::Benefit.model_name.human) redirect_to location_after_save, format: :html From b41952fd946193d5596f807b09f9e900fb7370b4 Mon Sep 17 00:00:00 2001 From: Fab Date: Tue, 3 Dec 2024 13:41:10 +0100 Subject: [PATCH 5/8] Add show all results to en.yml --- core/config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml index 6363feef47a..02a8ca8aa07 100644 --- a/core/config/locales/en.yml +++ b/core/config/locales/en.yml @@ -2097,6 +2097,7 @@ en: scope: Scope search: Search search_results: Search results for '%{keywords}' + search_results_all: Show all results for '%{keywords}' searching: Searching secure_connection_type: Secure Connection Type security_settings: Security Settings From c67f75f2db590af875c09dc1824d46d460e37297 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 3 Dec 2024 16:58:25 +0100 Subject: [PATCH 6/8] test: Wait for modal to open before testing its content Capybara needs to be told to expect that the modal is open before we can check for content present in it. Fixes a lot of extremely flaky specs. --- admin/spec/features/adjustment_reasons_spec.rb | 8 ++++---- admin/spec/features/refund_reasons_spec.rb | 8 ++++---- admin/spec/features/return_reasons_spec.rb | 8 ++++---- admin/spec/features/roles_spec.rb | 8 ++++---- admin/spec/features/shipping_categories_spec.rb | 8 ++++---- admin/spec/features/store_credit_reasons_spec.rb | 8 ++++---- admin/spec/features/tax_categories_spec.rb | 4 ++-- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/admin/spec/features/adjustment_reasons_spec.rb b/admin/spec/features/adjustment_reasons_spec.rb index 8af9a711ea0..14499858cfd 100644 --- a/admin/spec/features/adjustment_reasons_spec.rb +++ b/admin/spec/features/adjustment_reasons_spec.rb @@ -26,12 +26,12 @@ before do visit "/admin/adjustment_reasons#{query}" click_on "Add new" + expect(page).to have_selector("dialog") expect(page).to have_content("New Adjustment Reason") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) @@ -69,12 +69,12 @@ Spree::AdjustmentReason.create(name: "Good Reason", code: 5999) visit "/admin/adjustment_reasons#{query}" find_row("Good Reason").click + expect(page).to have_selector("dialog") expect(page).to have_content("Edit Adjustment Reason") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) diff --git a/admin/spec/features/refund_reasons_spec.rb b/admin/spec/features/refund_reasons_spec.rb index ae5a52663eb..cb153264174 100644 --- a/admin/spec/features/refund_reasons_spec.rb +++ b/admin/spec/features/refund_reasons_spec.rb @@ -26,12 +26,12 @@ before do visit "/admin/refund_reasons/#{query}" click_on "Add new" + expect(page).to have_selector("dialog") expect(page).to have_content("New Refund Reason") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) @@ -66,12 +66,12 @@ Spree::RefundReason.create(name: "Return process") visit "/admin/refund_reasons#{query}" find_row("Return process").click + expect(page).to have_selector("dialog") expect(page).to have_content("Edit Refund Reason") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) diff --git a/admin/spec/features/return_reasons_spec.rb b/admin/spec/features/return_reasons_spec.rb index 5932101bf41..706d9166749 100644 --- a/admin/spec/features/return_reasons_spec.rb +++ b/admin/spec/features/return_reasons_spec.rb @@ -26,12 +26,12 @@ before do visit "/admin/return_reasons#{query}" click_on "Add new" + expect(page).to have_selector("dialog") expect(page).to have_content("New Return Reason") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) @@ -68,12 +68,12 @@ Spree::ReturnReason.create(name: "Good Reason") visit "/admin/return_reasons#{query}" find_row("Good Reason").click + expect(page).to have_selector("dialog") expect(page).to have_content("Edit Return Reason") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) diff --git a/admin/spec/features/roles_spec.rb b/admin/spec/features/roles_spec.rb index 0132e2ed205..fb09c9894e0 100644 --- a/admin/spec/features/roles_spec.rb +++ b/admin/spec/features/roles_spec.rb @@ -54,12 +54,12 @@ before do visit "/admin/roles#{query}" click_on "Add new" + expect(page).to have_selector("dialog") expect(page).to have_content("New Role") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) @@ -121,14 +121,14 @@ Spree::Role.create(name: "Reviewer", permission_sets: [settings_edit_permission]) visit "/admin/roles#{query}" find_row("Reviewer").click + expect(page).to have_selector("dialog") expect(page).to have_content("Edit Role") expect(page).to be_axe_clean expect(Spree::Role.find_by(name: "Reviewer").permission_set_ids) .to contain_exactly(settings_edit_permission.id) end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) diff --git a/admin/spec/features/shipping_categories_spec.rb b/admin/spec/features/shipping_categories_spec.rb index 674ce76a00d..703de26bd66 100644 --- a/admin/spec/features/shipping_categories_spec.rb +++ b/admin/spec/features/shipping_categories_spec.rb @@ -26,12 +26,12 @@ before do visit "/admin/shipping_categories#{query}" click_on "Add new" + expect(page).to have_selector("dialog") expect(page).to have_content("New Shipping Category") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) @@ -66,12 +66,12 @@ Spree::ShippingCategory.create(name: "Letter Mail") visit "/admin/shipping_categories#{query}" find_row("Letter Mail").click + expect(page).to have_selector("dialog") expect(page).to have_content("Edit Shipping Category") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) diff --git a/admin/spec/features/store_credit_reasons_spec.rb b/admin/spec/features/store_credit_reasons_spec.rb index b4b2c46aff4..50b2c11d023 100644 --- a/admin/spec/features/store_credit_reasons_spec.rb +++ b/admin/spec/features/store_credit_reasons_spec.rb @@ -26,12 +26,12 @@ before do visit "/admin/store_credit_reasons#{query}" click_on "Add new" + expect(page).to have_selector("dialog") expect(page).to have_content("New Store Credit Reason") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) @@ -66,12 +66,12 @@ Spree::StoreCreditReason.create(name: "New Customer Reward") visit "/admin/store_credit_reasons#{query}" find_row("New Customer Reward").click + expect(page).to have_selector("dialog") expect(page).to have_content("Edit Store Credit Reason") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) diff --git a/admin/spec/features/tax_categories_spec.rb b/admin/spec/features/tax_categories_spec.rb index b91a24256dc..417ee5e1262 100644 --- a/admin/spec/features/tax_categories_spec.rb +++ b/admin/spec/features/tax_categories_spec.rb @@ -28,12 +28,12 @@ before do visit "/admin/tax_categories#{query}" click_on "Add new" + expect(page).to have_selector("dialog") expect(page).to have_content("New Tax Category") expect(page).to be_axe_clean end - it "opens a modal" do - expect(page).to have_selector("dialog") + it "closing the modal keeps query params" do within("dialog") { click_on "Cancel" } expect(page).not_to have_selector("dialog") expect(page.current_url).to include(query) From 7112488c7e83a3137edba403e9ebc873f230ffec Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 3 Dec 2024 17:10:22 +0100 Subject: [PATCH 7/8] test: Do not wait 30 seconds for a test to fail If the modal cannot be openend after 5 seconds (Capybara default wait tiem is 3 seconds) then something is wrong. We must not waste precious resources and time for a buld to fail. --- admin/spec/features/orders/show_spec.rb | 10 +++++----- .../spec/features/solidus_admin/promotions_spec.rb | 8 ++++---- .../system/solidus_promotions/admin/promotions_spec.rb | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/admin/spec/features/orders/show_spec.rb b/admin/spec/features/orders/show_spec.rb index 7b8aebd5479..986acbac250 100644 --- a/admin/spec/features/orders/show_spec.rb +++ b/admin/spec/features/orders/show_spec.rb @@ -48,7 +48,7 @@ expect(page).to have_content("Order R123456789") open_customer_menu click_on "Edit billing address" - expect(page).to have_css("dialog", wait: 30) + expect(page).to have_css("dialog", wait: 5) within("dialog") do fill_in "Name", with: "John Doe" @@ -74,7 +74,7 @@ open_customer_menu click_on "Edit shipping address" - expect(page).to have_css("dialog", wait: 30) + expect(page).to have_css("dialog", wait: 5) within("dialog") do fill_in "Name", with: "Jane Doe" @@ -119,18 +119,18 @@ expect(Spree::Order.last.line_items.count).to eq(0) find("[aria-selected]", text: "Just another product").click - expect(page).to have_content("Variant added to cart successfully", wait: 30) + expect(page).to have_content("Variant added to cart successfully", wait: 5) expect(Spree::Order.last.line_items.count).to eq(1) expect(Spree::Order.last.line_items.last.quantity).to eq(1) fill_in "line_item[quantity]", with: 4 - expect(page).to have_content("Quantity updated successfully", wait: 30) + expect(page).to have_content("Quantity updated successfully", wait: 5) expect(Spree::Order.last.line_items.last.quantity).to eq(4) accept_confirm("Are you sure?") { click_on "Delete" } - expect(page).to have_content("Line item removed successfully", wait: 30) + expect(page).to have_content("Line item removed successfully", wait: 5) expect(Spree::Order.last.line_items.count).to eq(0) expect(page).to be_axe_clean diff --git a/legacy_promotions/spec/features/solidus_admin/promotions_spec.rb b/legacy_promotions/spec/features/solidus_admin/promotions_spec.rb index 16f1439ace7..922846e2a51 100644 --- a/legacy_promotions/spec/features/solidus_admin/promotions_spec.rb +++ b/legacy_promotions/spec/features/solidus_admin/promotions_spec.rb @@ -14,13 +14,13 @@ visit "/admin/promotions" expect(page).to have_content("My active Promotion") click_on "Draft" - expect(page).to have_content("My draft Promotion", wait: 30) + expect(page).to have_content("My draft Promotion", wait: 5) click_on "Future" - expect(page).to have_content("My future Promotion", wait: 30) + expect(page).to have_content("My future Promotion", wait: 5) click_on "Expired" - expect(page).to have_content("My expired Promotion", wait: 30) + expect(page).to have_content("My expired Promotion", wait: 5) click_on "All" - expect(page).to have_content("My active Promotion", wait: 30) + expect(page).to have_content("My active Promotion", wait: 5) expect(page).to have_content("My draft Promotion") expect(page).to have_content("My future Promotion") expect(page).to have_content("My expired Promotion") diff --git a/promotions/spec/system/solidus_promotions/admin/promotions_spec.rb b/promotions/spec/system/solidus_promotions/admin/promotions_spec.rb index ddc65c9b46f..c02a8066084 100644 --- a/promotions/spec/system/solidus_promotions/admin/promotions_spec.rb +++ b/promotions/spec/system/solidus_promotions/admin/promotions_spec.rb @@ -14,13 +14,13 @@ visit "/admin/solidus/promotions" expect(page).to have_content("My active Promotion") click_on "Draft" - expect(page).to have_content("My draft Promotion", wait: 30) + expect(page).to have_content("My draft Promotion", wait: 5) click_on "Future" - expect(page).to have_content("My future Promotion", wait: 30) + expect(page).to have_content("My future Promotion", wait: 5) click_on "Expired" - expect(page).to have_content("My expired Promotion", wait: 30) + expect(page).to have_content("My expired Promotion", wait: 5) click_on "All" - expect(page).to have_content("My active Promotion", wait: 30) + expect(page).to have_content("My active Promotion", wait: 5) expect(page).to have_content("My draft Promotion") expect(page).to have_content("My future Promotion") expect(page).to have_content("My expired Promotion") From d98ec79d4e1a433459aa6f5a1d64a6657635dc95 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Tue, 3 Dec 2024 17:38:23 +0100 Subject: [PATCH 8/8] Add status code to benefits controller action These should help Turbo interpret what's going on. --- .../backend/solidus_promotions/admin/benefits_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb b/promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb index 10a24ef10b4..354a37ac8ba 100644 --- a/promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb +++ b/promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb @@ -19,7 +19,7 @@ def create t("spree.successfully_created", resource: SolidusPromotions::Benefit.model_name.human) redirect_to location_after_save, format: :html else - render :new, layout: false + render :new, layout: false, status: :unprocessable_entity end end @@ -28,7 +28,7 @@ def edit if params.dig(:benefit, :calculator_type) @benefit.calculator_type = params[:benefit][:calculator_type] end - render layout: false + render layout: false, status: :unprocessable_entity end def update @@ -39,7 +39,7 @@ def update t("spree.successfully_updated", resource: SolidusPromotions::Benefit.model_name.human) redirect_to location_after_save, format: :html else - render :edit + render :edit, status: :unprocessable_entity end end