feat(captain-memory): add feature flag helpers on Account
This commit is contained in:
parent
effe6018e0
commit
2bf68e5be8
@ -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
|
||||
|
||||
@ -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 })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user