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

Clean up Ransack query for promotion code #8

Merged
merged 1 commit into from
Dec 8, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/orders/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<div class="field">
<%= label_tag nil, Spree.t(:promotion) %>
<%= f.text_field :promotions_codes_value_cont, :size => 25 %>
<%= f.text_field :order_promotions_promotion_code_value_cont, :size => 25 %>
</div>

<div class="field">
Expand Down
2 changes: 1 addition & 1 deletion backend/spec/features/admin/orders/listing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

it "only shows the orders with the selected promotion" do
click_on 'Filter'
fill_in "q_promotions_codes_value_cont", with: promotion.codes.first.value
fill_in "q_order_promotions_promotion_code_value_cont", with: promotion.codes.first.value
click_on 'Filter Results'
within_row(1) { expect(page).to have_content("R100") }
within("table#listing_orders") { expect(page).not_to have_content("R200") }
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CannotRebuildShipments < StandardError; end
go_to_state :confirm
end

self.whitelisted_ransackable_associations = %w[shipments user promotions bill_address ship_address line_items]
self.whitelisted_ransackable_associations = %w[shipments user order_promotions promotions bill_address ship_address line_items]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep promotions here? I guess for the separate Promo page's search?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The promotions association may still be useful in some contexts - I don't believe it's used in our application or in Solidus, but I'm hesitant to remove it unless it's also removed upstream first.

self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total]

attr_reader :coupon_code
Expand Down
2 changes: 2 additions & 0 deletions core/app/models/spree/order_promotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class OrderPromotion < Spree::Base
validates :promotion, presence: true
validates :promotion_code, presence: true, if: :require_promotion_code?

self.whitelisted_ransackable_associations = %w[promotion_code]

private

def require_promotion_code?
Expand Down