You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In listing 88 you're testing for a sort order but in listing 89 it's a WHERE clause without any ordering. SQL makes no guarantees in this situation, if it passes that's luck. You need some ordering or remove the test.
Listing 88. test/models/product_test.rb
classProductTest < ActiveSupport::TestCase# ...test'should filter products by name and sort them'doassert_equal[products(:another_tv),products(:one)],Product.filter_by_title('tv').sortendend
Listing 89. app/models/product.rb
classProduct < ApplicationRecord# ...scope:filter_by_title,lambda{ |keyword|
where('lower(title) LIKE ?',"%#{keyword.downcase}%")}end
The text was updated successfully, but these errors were encountered:
I'm going through the book again... :-}
In listing 88 you're testing for a sort order but in listing 89 it's a WHERE clause without any ordering. SQL makes no guarantees in this situation, if it passes that's luck. You need some ordering or remove the test.
Listing 88. test/models/product_test.rb
Listing 89. app/models/product.rb
The text was updated successfully, but these errors were encountered: