Files
fizzy/test/models/user/highlights_test.rb
T
Mike Dalessio 8f39c015ea Tests now pass with local authentication
This is the first step of a multi-step SaaS engine extraction.

Looking ahead to an open source release, we need to make sure that
local authentication is treated as an "official" option, and not just
a hack I added for Kevin to do load testing outside our DC. So this PR
gets to green, and adds a CI step in "local authentication" mode.

This all probably feels a little hacky to you, Reader, but the goal of
this change is to ease the next step, which will be extracting the
37id and Queenbee integrations into a proprietary "SaaS mode" engine.

In service of that goal, this commit simply wraps all of the dependent
code and tests with a conditional check on
`config.x.local_authentication`.
2025-09-13 15:21:00 -04:00

37 lines
1.1 KiB
Ruby

require "test_helper"
class User::HighlightsTest < ActiveSupport::TestCase
# Skipping when locally authenticating because the VCR cassettes would need to be re-recorded.
unless Rails.application.config.x.local_authentication
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
stub_const(PeriodHighlights::Period, :MIN_EVENTS_TO_BE_INTERESTING, 3) do
new_period_highlights = @user.generate_weekly_highlights
assert_not_nil new_period_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
end
end