feat(goals): gate Goals v2 behind beta features toggle

Add require_beta_features! to GoalsController and GoalPledgesController,
hide the Goals nav item for non-beta users, and tag index/show headers
with the Beta pill marker. Update controller tests to enable the
preference in setup and assert the redirect for users without access.
This commit is contained in:
Guillem Arias
2026-05-18 20:13:44 +02:00
parent ac23521c0a
commit 5c7babc44e
7 changed files with 36 additions and 6 deletions

View File

@@ -2,13 +2,24 @@ require "test_helper"
class GoalPledgesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in users(:family_admin)
@user = users(:family_admin)
@user.update!(preferences: (@user.preferences || {}).merge("beta_features_enabled" => true))
sign_in @user
@goal = goals(:vacation_italy)
@account = accounts(:depository)
@pledge = goal_pledges(:open_transfer)
ensure_tailwind_build
end
test "redirects users without beta access" do
@user.update!(preferences: (@user.preferences || {}).merge("beta_features_enabled" => false))
get new_goal_pledge_url(@goal), headers: { "Turbo-Frame" => "modal" }
assert_redirected_to root_path
assert_match(/beta/i, flash[:alert])
end
test "new renders the pledge form inside a turbo frame" do
get new_goal_pledge_url(@goal), headers: { "Turbo-Frame" => "modal" }
assert_response :success

View File

@@ -2,13 +2,24 @@ require "test_helper"
class GoalsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in users(:family_admin)
@user = users(:family_admin)
@user.update!(preferences: (@user.preferences || {}).merge("beta_features_enabled" => true))
sign_in @user
@goal = goals(:vacation_italy)
@depository = accounts(:depository)
@connected = accounts(:connected)
ensure_tailwind_build
end
test "redirects users without beta access" do
@user.update!(preferences: (@user.preferences || {}).merge("beta_features_enabled" => false))
get goals_url
assert_redirected_to root_path
assert_match(/beta/i, flash[:alert])
end
test "index renders with active filter by default" do
get goals_url
assert_response :success