Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4.4] Fix(promotions): Validate benefits on save #6023

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
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
else
render :new, layout: false
render :new, layout: false, status: :unprocessable_entity

Check warning on line 22 in promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb

View check run for this annotation

Codecov / codecov/patch

promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb#L22

Added line #L22 was not covered by tests
end
end

Expand All @@ -28,7 +28,7 @@
if params.dig(:benefit, :calculator_type)
@benefit.calculator_type = params[:benefit][:calculator_type]
end
render layout: false
render layout: false, status: :unprocessable_entity

Check warning on line 31 in promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb

View check run for this annotation

Codecov / codecov/patch

promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb#L31

Added line #L31 was not covered by tests
end

def update
Expand All @@ -39,7 +39,7 @@
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

Check warning on line 42 in promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb

View check run for this annotation

Codecov / codecov/patch

promotions/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb#L42

Added line #L42 was not covered by tests
end
end

Expand Down
Loading