-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Promo code batch join chars #2662
Promo code batch join chars #2662
Conversation
@@ -0,0 +1,9 @@ | |||
class AddJoinCharactersToPromotionCodeBatch < ActiveRecord::Migration[5.1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing magic comment # frozen_string_literal: true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved.
2c56732
to
393adcf
Compare
@@ -0,0 +1,10 @@ | |||
# frozen_string_literal: true | |||
class AddJoinCharactersToPromotionCodeBatch < ActiveRecord::Migration[5.1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line after magic comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved.
@@ -0,0 +1,10 @@ | |||
# frozen_string_literal: true | |||
class AddJoinCharactersToPromotionCodeBatch < ActiveRecord::Migration[5.1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line after magic comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved.
393adcf
to
c673353
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just left a possible improvement
@@ -6,7 +6,8 @@ class PromotionCodeBatchJob < ActiveJob::Base | |||
|
|||
def perform(promotion_code_batch) | |||
PromotionCode::BatchBuilder.new( | |||
promotion_code_batch | |||
promotion_code_batch, | |||
join_characters: promotion_code_batch.join_characters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the join_characters
is included into the promotion_code_batch
we are initializing the BatchBuilder
with, what's the purpose of also passing it as a keyword argument? I think it could be better to keep the .new
identical and work inside the BatchBuilder
class to make the join_characters
an instance attribute instead of a class level one
This commit adds a new string field to the PromotionCodeBatch model, join_characters, in order to allow customizing which characters should be used in promotion batch creation. Default has been set to an underscore ('_') to keep in line with current behavior.
Now that Spree::PromotionCodeBatch has a join_characters field, the job which creates the batch of promotions should use this field.
c673353
to
7e51e78
Compare
Suggested changes have been made, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
This PR aims to resolve #1946, allowing customization of promotion separator characters (currently always
'_'
) via the admin. It stores the characters to use on thePromotionCodeBatch
model, and has a default set to'_'
, so that users who do not wish to make use of this functionality do not need to change their workflows.