Files
fizzy/test/models/user/highlights_test.rb
T
Jorge Manrubia aad61b36bc Generate highlights in the user timezone, now that we persist it
Also, remove the dates and duration from the highlights records. Those are not relevant, only the events-derived
key is. If two users with different timezones have different activities, they should see different summaries.
2025-09-05 12:39:09 +02:00

31 lines
830 B
Ruby

require "test_helper"
class User::HighlightsTest < ActiveSupport::TestCase
include VcrTestHelper
setup do
@user = users(:david)
travel_to 1.week.ago + 2.days
end
test "generate weekly highlights" do
stub_const(PeriodHighlights::Period, :MIN_EVENTS_TO_BE_INTERESTING, 3) do
period_highlights = assert_difference -> { PeriodHighlights.count }, 1 do
@user.generate_weekly_highlights
end
assert_match /logo/i, period_highlights.to_html
end
end
test "don't generate highlights for existing periods" do
new_period_highlights = @user.generate_weekly_highlights
existing_period_highlights = assert_no_difference -> { PeriodHighlights.count } do
@user.generate_weekly_highlights
end
assert_equal new_period_highlights, existing_period_highlights
end
end