mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
* First cut of a simplified "intro" UI layout * Linter * Add guest role and intro-only access * Fix guest role UI defaults (#940) Use enum predicate to avoid missing role helper. * Remove legacy user role mapping (#941) Drop the unused user role references in role normalization and SSO role mapping forms to avoid implying a role that never existed. Refs: #0 * Remove role normalization (#942) Remove role normalization Roles are now stored directly without legacy mappings. * Revert role mapping logic * Remove `normalize_role_settings` * Remove unnecessary migration * Make `member` the default * Broken `.erb` --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
84 lines
2.6 KiB
Ruby
84 lines
2.6 KiB
Ruby
require "test_helper"
|
|
|
|
class PagesControllerTest < ActionDispatch::IntegrationTest
|
|
include EntriesTestHelper
|
|
|
|
setup do
|
|
sign_in @user = users(:family_admin)
|
|
@intro_user = users(:intro_user)
|
|
@family = @user.family
|
|
end
|
|
|
|
test "dashboard" do
|
|
get root_path
|
|
assert_response :ok
|
|
end
|
|
|
|
test "intro page requires guest role" do
|
|
get intro_path
|
|
|
|
assert_redirected_to root_path
|
|
assert_equal "Intro is only available to guest users.", flash[:alert]
|
|
end
|
|
|
|
test "intro page is accessible for guest users" do
|
|
sign_in @intro_user
|
|
|
|
get intro_path
|
|
|
|
assert_response :ok
|
|
end
|
|
|
|
test "dashboard renders sankey chart with subcategories" do
|
|
# Create parent category with subcategory
|
|
parent_category = @family.categories.create!(name: "Shopping", classification: "expense", color: "#FF5733")
|
|
subcategory = @family.categories.create!(name: "Groceries", classification: "expense", parent: parent_category, color: "#33FF57")
|
|
|
|
# Create transactions using helper
|
|
create_transaction(account: @family.accounts.first, name: "General shopping", amount: 100, category: parent_category)
|
|
create_transaction(account: @family.accounts.first, name: "Grocery store", amount: 50, category: subcategory)
|
|
|
|
get root_path
|
|
assert_response :ok
|
|
assert_select "[data-controller='sankey-chart']"
|
|
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/we-promise/sure/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
|