Sort products by name in ascending order

The order is specified above in fetch_products. I'm guessing this line was unintentional?

Original requirment doesn't say ascending but I think it's safe to assume (issue#10694).
This commit is contained in:
David Cook
2023-07-21 14:19:24 +10:00
committed by Jean-Baptiste Bellet
parent 6dbfb36e52
commit e816228959
2 changed files with 16 additions and 1 deletions

View File

@@ -96,7 +96,7 @@ class ProductsReflex < ApplicationReflex
end
def ransack_query
query = { s: "name desc" }
query = {}
query.merge!(supplier_id_in: @producer_id) if @producer_id.present?
if @search_term.present?
query.merge!(Spree::Variant::SEARCH_KEY => @search_term)

View File

@@ -23,6 +23,21 @@ describe 'As an admin, I can see the new product page' do
expect(page).to have_content "Bulk Edit Products"
end
describe "sorting" do
let!(:product_z) { create(:simple_product, name: "Zucchini") }
let!(:product_a) { create(:simple_product, name: "Apples") }
before do
visit admin_products_v3_index_url
end
it "Should sort products alphabetically by default" do
expect(page).to have_selector "table.products tbody tr td", text: "Apples"
# other products push later one to next page
expect(page).not_to have_selector "table.products tbody tr td", text: "Zucchini"
end
end
describe "pagination" do
before do
visit admin_products_v3_index_url