File tree Expand file tree Collapse file tree 4 files changed +38
-1
lines changed 
views/settings/ai_prompts 
config/locales/views/settings Expand file tree Collapse file tree 4 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,11 @@ def update
2121      @user . update! ( user_params . except ( :redirect_to ,  :delete_profile_image ) ) 
2222      @user . profile_image . purge  if  should_purge_profile_image? 
2323
24-       # Add a special notice if AI was just enabled 
24+       # Add a special notice if AI was just enabled or disabled  
2525      notice  =  if  !was_ai_enabled  && @user . ai_enabled 
2626        "AI Assistant has been enabled successfully." 
27+       elsif  was_ai_enabled  && !@user . ai_enabled 
28+         "AI Assistant has been disabled." 
2729      else 
2830        t ( ".success" ) 
2931      end 
@@ -72,6 +74,8 @@ def handle_redirect(notice)
7274        redirect_to  goals_onboarding_path 
7375      when  "trial" 
7476        redirect_to  trial_onboarding_path 
77+       when  "ai_prompts" 
78+         redirect_to  settings_ai_prompts_path ,  notice : notice 
7579      else 
7680        redirect_to  settings_profile_path ,  notice : notice 
7781      end 
Original file line number Diff line number Diff line change 11<%=  content_for :page_title, t(".page_title") %> 
22
3+ <%  if Current.user.ai_enabled? %> 
4+   div  class ="mb-4 flex justify-end "> 
5+     <%=  render  DS ::Button . new ( 
6+       text : t ( ".disable_ai" ) , 
7+       href : user_path ( Current . user ) , 
8+       method : :patch , 
9+       params : {  user : {  ai_enabled : false ,  redirect_to : "ai_prompts"  }  } , 
10+       data : {  turbo : false  } , 
11+       variant : :destructive 
12+     )  %> 
13+   </ div > 
14+ <%  end  %> 
15+ 
316< div  class ="bg-container rounded-xl shadow-border-xs p-4 "> 
417  < div  class ="rounded-xl bg-container-inset space-y-1 p-1 "> 
518    < div  class ="flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-secondary "> 
Original file line number Diff line number Diff line change 55      show :
66        page_title : AI Prompts 
77        openai_label : OpenAI 
8+         disable_ai : Disable AI Assistant 
89        prompt_instructions : Prompt Instructions 
910        main_system_prompt :
1011          title : Main System Prompt 
Original file line number Diff line number Diff line change 1+ require  "application_system_test_case" 
2+ 
3+ class  Settings ::AiPromptsTest  < ApplicationSystemTestCase 
4+   setup  do 
5+     @user  =  users ( :family_admin ) 
6+     @user . update! ( ai_enabled : true ) 
7+     login_as  @user 
8+   end 
9+ 
10+   test  "user can disable ai assistant"  do 
11+     visit  settings_ai_prompts_path 
12+ 
13+     click_button  "Disable AI Assistant" 
14+ 
15+     assert_current_path  settings_ai_prompts_path 
16+     @user . reload 
17+     assert_not  @user . ai_enabled? 
18+   end 
19+ end 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments