Skip to content

Product test may fail #83

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions rails6/en/chapter06-improve-json.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -698,18 +698,21 @@ one:
price: 9999.99
published: false
user: one

updated_at: <%= 5.day.ago.to_s :db %>

two:
title: Azos Zeenbok
price: 499.99
published: false
user: two

updated_at: <%= 4.day.ago.to_s :db %>

another_tv:
title: Cheap TV
price: 99.99
published: false
user: two
updated_at: <%= 3.day.ago.to_s :db %>
----

And now we can build some tests:
Expand Down Expand Up @@ -842,7 +845,7 @@ class ProductTest < ActiveSupport::TestCase
test 'should sort product by most recent' do
# we will touch some products to update them
products(:two).touch
assert_equal [products(:another_tv), products(:one), products(:two)], Product.recent.to_a
assert_equal [products(:one), products(:another_tv), products(:two)], Product.recent.to_a
end
end
----
Expand Down