[openstreetmap/openstreetmap-website] Don't update deactivates_at if block was already viewed (PR #5312)
Tom Hughes
notifications at github.com
Tue Nov 12 18:51:02 UTC 2024
@tomhughes requested changes on this pull request.
> + get user_block_path(block)
+ assert_response :success
+ block.reload
+ assert_not block.needs_view
+ assert_equal Time.now.utc - 1.hour, block.deactivates_at
+ end
+ end
+
+ ##
+ # test clearing needs_view by showing a timed block to the blocked user
+ def test_show_sets_deactivates_at_for_timed_block
+ user = create(:user)
+ session_for(user)
+
+ freeze_time do
+ block = create(:user_block, :needs_view, :created_at => Time.now.utc, :ends_at => Time.now.utc + 1.day, :user => user)
I recently got rid of all the `.day` uses in this file because they cause confusion when running the tests just before a DST change when a day may not be 24 hours so this should probably be `24.hours` instead.
> +
+ get user_block_path(block)
+ assert_response :success
+ block.reload
+ assert_not block.needs_view
+ assert_equal Time.now.utc + 23.hours, block.deactivates_at
+
+ travel 1.hour
+
+ get user_block_path(block)
+ assert_response :success
+ block.reload
+ assert_not block.needs_view
+ assert_equal Time.now.utc + 22.hours, block.deactivates_at
+
+ travel 1.day
Same here...
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5312#pullrequestreview-2430432973
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5312/review/2430432973 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20241112/00703bcb/attachment.htm>
More information about the rails-dev
mailing list