group specs into one it block, added fullname with comma reversed ransacker

This commit is contained in:
Dung Bui
2023-12-04 08:45:19 +07:00
parent 6206164c30
commit 8a3aababa1
4 changed files with 57 additions and 11 deletions

View File

@@ -233,4 +233,19 @@ describe Spree::Address do
expect(result2).not_to include(address1)
end
end
describe "ransacker :full_name_with_comma_reversed" do
it "searches for records with matching reversed full names" do
address1 = create(:address, firstname: 'John', lastname: 'Doe')
address2 = create(:address, firstname: 'Jane', lastname: 'Smith')
result1 = described_class.ransack(full_name_with_comma_reversed_cont: 'Doe, John').result
expect(result1).to include(address1)
expect(result1).not_to include(address2)
result2 = described_class.ransack(full_name_with_comma_reversed_cont: 'Smith, Jane').result
expect(result2).to include(address2)
expect(result2).not_to include(address1)
end
end
end

View File

@@ -230,19 +230,43 @@ describe '
end
it "by customer name" do
# by firstname
fill_in "quick_filter", with: o1.bill_address.firstname
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li1], [li2, li3]
# by lastname
fill_in "quick_filter", with: o1.bill_address.lastname
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li1], [li2, li3]
end
it "by customer fullname with comma" do
# by fullname
fill_in "quick_filter", with: "#{o1.bill_address.firstname} #{o1.bill_address.lastname}"
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li1], [li2, li3]
fill_in "quick_filter", with: "#{o2.bill_address.firstname} #{o2.bill_address.lastname}"
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li2, li3], [li1]
# by fullname reversed
fill_in "quick_filter", with: "#{o1.bill_address.lastname} #{o1.bill_address.firstname}"
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li1], [li2, li3]
fill_in "quick_filter", with: "#{o2.bill_address.lastname} #{o2.bill_address.firstname}"
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li2, li3], [li1]
# by fullname with comma
fill_in "quick_filter", with: "#{o1.bill_address.firstname}, #{o1.bill_address.lastname}"
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li1], [li2, li3]
@@ -251,15 +275,15 @@ describe '
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li2, li3], [li1]
end
it "by customer fullname reversed" do
fill_in "quick_filter", with: "#{o1.bill_address.lastname} #{o1.bill_address.firstname}"
# by fullname with comma reversed
fill_in "quick_filter", with: "#{o1.bill_address.lastname}, #{o1.bill_address.firstname}"
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li1], [li2, li3]
fill_in "quick_filter", with: "#{o2.bill_address.lastname} #{o2.bill_address.firstname}"
fill_in "quick_filter", with: "#{o2.bill_address.lastname}, #{o2.bill_address.firstname}"
page.find('.filter-actions .button.icon-search').click
expect_line_items_results [li2, li3], [li1]