diff --git a/app/controllers/goal_pledges_controller.rb b/app/controllers/goal_pledges_controller.rb index c3c9c438d..d2fe99326 100644 --- a/app/controllers/goal_pledges_controller.rb +++ b/app/controllers/goal_pledges_controller.rb @@ -1,4 +1,5 @@ class GoalPledgesController < ApplicationController + before_action :require_beta_features! before_action :set_goal before_action :set_pledge, only: %i[renew destroy] rescue_from ActiveRecord::RecordNotFound, with: :record_not_found diff --git a/app/controllers/goals_controller.rb b/app/controllers/goals_controller.rb index ae34762a0..c37345a09 100644 --- a/app/controllers/goals_controller.rb +++ b/app/controllers/goals_controller.rb @@ -1,4 +1,5 @@ class GoalsController < ApplicationController + before_action :require_beta_features! before_action :set_goal, only: %i[show edit update destroy pause resume complete archive unarchive] rescue_from ActiveRecord::RecordNotFound, with: :goal_not_found diff --git a/app/views/goals/index.html.erb b/app/views/goals/index.html.erb index f9d8ffc04..eed6522ce 100644 --- a/app/views/goals/index.html.erb +++ b/app/views/goals/index.html.erb @@ -1,6 +1,9 @@
<%= t(".subtitle") %>
<%= @goal.header_summary %>
<% last_days = @goal.last_matched_pledge_days_ago %> <% unless last_days.nil? %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 16457cc86..b3244bb88 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,9 +11,9 @@ else { name: t(".nav.transactions"), path: transactions_path, icon: "credit-card", icon_custom: false, active: page_active?(transactions_path) }, { name: t(".nav.reports"), path: reports_path, icon: "chart-bar", icon_custom: false, active: page_active?(reports_path) }, { name: t(".nav.budgets"), path: budgets_path, icon: "map", icon_custom: false, active: page_active?(budgets_path) }, - { name: t(".nav.goals"), path: goals_path, icon: "piggy-bank", icon_custom: false, active: page_active?(goals_path) }, + (beta_features_enabled? ? { name: t(".nav.goals"), path: goals_path, icon: "piggy-bank", icon_custom: false, active: page_active?(goals_path) } : nil), { name: t(".nav.assistant"), path: chats_path, icon: "icon-assistant", icon_custom: true, active: page_active?(chats_path), mobile_only: true } - ] + ].compact end %> <% desktop_nav_items = mobile_nav_items.reject { |item| item[:mobile_only] } %> diff --git a/test/controllers/goal_pledges_controller_test.rb b/test/controllers/goal_pledges_controller_test.rb index af9227ad5..274a37149 100644 --- a/test/controllers/goal_pledges_controller_test.rb +++ b/test/controllers/goal_pledges_controller_test.rb @@ -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 diff --git a/test/controllers/goals_controller_test.rb b/test/controllers/goals_controller_test.rb index b959e6eaf..4ae4f9c6b 100644 --- a/test/controllers/goals_controller_test.rb +++ b/test/controllers/goals_controller_test.rb @@ -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