From: Anton Khorev Date: Tue, 7 Jan 2025 10:19:33 +0000 (+0300) Subject: Report deactivates_at as block read date X-Git-Tag: live~24^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3df14c5a400473a5572bfe85aa636ab4d01a6fb7 Report deactivates_at as block read date --- diff --git a/app/helpers/user_blocks_helper.rb b/app/helpers/user_blocks_helper.rb index 75bd4a46d..f18a6250c 100644 --- a/app/helpers/user_blocks_helper.rb +++ b/app/helpers/user_blocks_helper.rb @@ -35,7 +35,7 @@ module UserBlocksHelper else if block.revoker_id.nil? if block.deactivates_at > block.ends_at - t("user_blocks.helper.short.read_html", :time => block_short_time_in_past(block.updated_at)) + t("user_blocks.helper.short.read_html", :time => block_short_time_in_past(block.deactivates_at)) else t("user_blocks.helper.short.ended") end diff --git a/test/helpers/user_blocks_helper_test.rb b/test/helpers/user_blocks_helper_test.rb index 28cc0ad50..d308f46ea 100644 --- a/test/helpers/user_blocks_helper_test.rb +++ b/test/helpers/user_blocks_helper_test.rb @@ -58,7 +58,16 @@ class UserBlocksHelperTest < ActionView::TestCase block.update(:needs_view => false, :deactivates_at => Time.now.utc) - assert_match "read at", block_short_status(block) + read_date = Time.now.utc.to_date.strftime + short_status_dom = Rails::Dom::Testing.html_document.parse(block_short_status(block)) + assert_dom short_status_dom, ":root", :text => "read at #{read_date}" + + travel 24.hours + + block.update(:reason => "updated reason") + + short_status_dom = Rails::Dom::Testing.html_document.parse(block_short_status(block)) + assert_dom short_status_dom, ":root", :text => "read at #{read_date}" end end