From: Tom Hughes Date: Mon, 6 Jan 2025 19:07:56 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/5476' X-Git-Tag: live~78 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/f946797520d5420804a730657dab99c504cae693?hp=e6b0afc6c84928ac7cf2c746080812a07f23aca9 Merge remote-tracking branch 'upstream/pull/5476' --- diff --git a/app/helpers/user_blocks_helper.rb b/app/helpers/user_blocks_helper.rb index c7c12f6d1..75bd4a46d 100644 --- a/app/helpers/user_blocks_helper.rb +++ b/app/helpers/user_blocks_helper.rb @@ -34,7 +34,7 @@ module UserBlocksHelper end else if block.revoker_id.nil? - if block.updated_at > block.ends_at + if block.deactivates_at > block.ends_at t("user_blocks.helper.short.read_html", :time => block_short_time_in_past(block.updated_at)) else t("user_blocks.helper.short.ended") diff --git a/test/helpers/user_blocks_helper_test.rb b/test/helpers/user_blocks_helper_test.rb index 99f59af47..28cc0ad50 100644 --- a/test/helpers/user_blocks_helper_test.rb +++ b/test/helpers/user_blocks_helper_test.rb @@ -30,6 +30,38 @@ class UserBlocksHelperTest < ActionView::TestCase end end + def test_block_short_status_with_immediate_update + freeze_time do + block = UserBlock.new :user => create(:user), + :creator => create(:moderator_user), + :reason => "because", + :created_at => Time.now.utc, + :ends_at => Time.now.utc, + :deactivates_at => Time.now.utc, + :needs_view => false + + travel 1.second + + block.save + + assert_equal "ended", block_short_status(block) + end + end + + def test_block_short_status_read + freeze_time do + block = create(:user_block, :needs_view, :ends_at => Time.now.utc) + + travel 24.hours + + assert_equal "active until read", block_short_status(block) + + block.update(:needs_view => false, :deactivates_at => Time.now.utc) + + assert_match "read at", block_short_status(block) + end + end + def test_block_duration_in_words words = block_duration_in_words(364.days) assert_equal "11 months", words