1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00
Maybe/test/controllers/pages_controller_test.rb
Josh Pigford 3cc88f3e98
Fix changelog page crash when GitHub release notes are unavailable (#2314)
* Fix changelog page crash when GitHub release notes are unavailable

* Refactor changelog view to handle missing avatars gracefully and improve session sign-out logic in tests

* Enhance changelog view to display fallback messages for unavailable release notes and publication dates

* Update onboarding system tests to reflect UI changes and improve assertions

- Changed button labels from "Get started" to "Continue" and "Complete" to align with updated UI.
- Updated text assertions for clarity, changing "Set your preferences" to "Configure your preferences".
- Adjusted locale selection options to include language codes.
- Enhanced validation error handling in preferences form.
- Improved navigation assertions to ensure accurate path checks.
2025-05-26 19:53:25 -05:00

50 lines
1.5 KiB
Ruby

require "test_helper"
class PagesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
end
test "dashboard" do
get root_path
assert_response :ok
end
test "changelog" do
VCR.use_cassette("git_repository_provider/fetch_latest_release_notes") do
get changelog_path
assert_response :ok
end
end
test "changelog with nil release notes" do
# Mock the GitHub provider to return nil (simulating API failure or no releases)
github_provider = mock
github_provider.expects(:fetch_latest_release_notes).returns(nil)
Provider::Registry.stubs(:get_provider).with(:github).returns(github_provider)
get changelog_path
assert_response :ok
assert_select "h2", text: "Release notes unavailable"
assert_select "a[href='https://github.com/maybe-finance/maybe/releases']"
end
test "changelog with incomplete release notes" do
# Mock the GitHub provider to return incomplete data (missing some fields)
github_provider = mock
incomplete_data = {
avatar: nil,
username: "maybe-finance",
name: "Test Release",
published_at: nil,
body: nil
}
github_provider.expects(:fetch_latest_release_notes).returns(incomplete_data)
Provider::Registry.stubs(:get_provider).with(:github).returns(github_provider)
get changelog_path
assert_response :ok
assert_select "h2", text: "Test Release"
# Should not crash even with nil values
end
end