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 to find orders by promotion #1662

Merged
merged 2 commits into from
Jan 11, 2017
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* Product slugs no longer have a minimum length validation to match the Product name validation.
[#1616](https://github.com/solidusio/solidus/pull/1616)

* Changed the promotion field in the admin order search to only find orders
which used the specified promotion code, instead of any code on an applied
promotion. [#1662](https://github.com/solidusio/solidus/pull/1662)

## Solidus 2.1.0 (unreleased)

* The OrderUpdater (as used by `order.update!`) now fully updates taxes.
Expand Down
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 @@ -161,7 +161,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 @@ -43,7 +43,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]
self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total store_id]

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