feat(captain-memory): add feature flag helpers on Account

This commit is contained in:
Rodribm10 2026-04-18 22:10:10 -03:00
parent effe6018e0
commit 2bf68e5be8
2 changed files with 36 additions and 0 deletions

View File

@ -27,6 +27,14 @@ module CaptainFeaturable
}.with_indifferent_access
end
def captain_contact_memory_extraction_enabled?
custom_attributes.fetch('captain_contact_memory_extraction_enabled', false) == true
end
def captain_contact_memory_recall_enabled?
custom_attributes.fetch('captain_contact_memory_recall_enabled', false) == true
end
private
def captain_models_with_defaults

View File

@ -112,6 +112,34 @@ RSpec.describe CaptainFeaturable do
end
end
describe '#captain_contact_memory_extraction_enabled?' do
let(:account) { create(:account) }
it 'returns false by default' do
expect(account.captain_contact_memory_extraction_enabled?).to be(false)
end
it 'returns true when flag set in custom_attributes' do
account.custom_attributes = { 'captain_contact_memory_extraction_enabled' => true }
account.save!
expect(account.captain_contact_memory_extraction_enabled?).to be(true)
end
end
describe '#captain_contact_memory_recall_enabled?' do
let(:account) { create(:account) }
it 'returns false by default' do
expect(account.captain_contact_memory_recall_enabled?).to be(false)
end
it 'returns true when flag set in custom_attributes' do
account.custom_attributes = { 'captain_contact_memory_recall_enabled' => true }
account.save!
expect(account.captain_contact_memory_recall_enabled?).to be(true)
end
end
describe 'integration with existing captain_preferences' do
it 'enabled? methods use the same logic as captain_preferences[:features]' do
account.update!(captain_features: { 'editor' => true, 'copilot' => true })