Merge branch 'feature/cw-7513' into feature/cw-7513-specs
This commit is contained in:
@@ -108,6 +108,10 @@ RSpec.describe Account do
|
||||
|
||||
it 'configures the account feature flag extension column' do
|
||||
expect(described_class.flag_columns).to include('feature_flags', 'feature_flags_ext_1')
|
||||
expect(described_class.flag_mapping['feature_flags_ext_1']).to eq(feature_whatsapp_manual_transfer: 1, feature_data_import: 1 << 1,
|
||||
feature_api_and_webhooks: 1 << 2)
|
||||
expect(described_class.flag_mapping['feature_flags_ext_1'][:feature_whatsapp_manual_transfer]).to eq(1)
|
||||
expect(described_class.flag_mapping['feature_flags_ext_1'][:feature_data_import]).to eq(2)
|
||||
end
|
||||
|
||||
it 'keeps existing feature flags on the original column' do
|
||||
@@ -116,15 +120,17 @@ RSpec.describe Account do
|
||||
end
|
||||
|
||||
it 'keeps bulk selected feature assignment compatible with existing feature names' do
|
||||
account.selected_feature_flags = [:feature_ip_lookup, :feature_assignment_v2, :feature_advanced_assignment]
|
||||
account.selected_feature_flags = [:feature_ip_lookup, :feature_assignment_v2, :feature_advanced_assignment, :feature_data_import]
|
||||
|
||||
expect(account).to be_feature_ip_lookup
|
||||
expect(account).to be_feature_assignment_v2
|
||||
expect(account).to be_feature_advanced_assignment
|
||||
expect(account).to be_feature_data_import
|
||||
expect(account.selected_feature_flags).to contain_exactly(
|
||||
:feature_ip_lookup,
|
||||
:feature_assignment_v2,
|
||||
:feature_advanced_assignment
|
||||
:feature_advanced_assignment,
|
||||
:feature_data_import
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,18 @@ RSpec.describe DataImport do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'access token encryption' do
|
||||
it 'encrypts the Intercom access token at rest' do
|
||||
skip('encryption keys missing; see run_mfa_spec workflow') unless Chatwoot.encryption_configured?
|
||||
|
||||
data_import = create(:data_import, :intercom, access_token: 'intercom-secret')
|
||||
stored_value = data_import.reload.read_attribute_before_type_cast(:access_token).to_s
|
||||
|
||||
expect(stored_value).not_to include('intercom-secret')
|
||||
expect(data_import.access_token).to eq('intercom-secret')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'callbacks' do
|
||||
let(:data_import) { build(:data_import) }
|
||||
|
||||
@@ -20,4 +32,36 @@ RSpec.describe DataImport do
|
||||
end.to have_enqueued_job(DataImportJob).with(data_import).on_queue('low')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#abandon!' do
|
||||
let(:account) { create(:account) }
|
||||
let(:data_import) do
|
||||
create(
|
||||
:data_import, :intercom,
|
||||
account: account,
|
||||
status: :processing
|
||||
)
|
||||
end
|
||||
|
||||
before do
|
||||
account.enable_features!('data_import')
|
||||
end
|
||||
|
||||
it 'abandons active Intercom imports', :aggregate_failures do
|
||||
data_import.abandon!
|
||||
|
||||
expect(data_import).to be_abandoned
|
||||
expect(data_import.abandoned_at).to be_present
|
||||
end
|
||||
|
||||
it 'does not overwrite terminal status from a stale instance', :aggregate_failures do
|
||||
stale_import = described_class.find(data_import.id)
|
||||
data_import.update!(status: :completed, completed_at: 1.minute.ago)
|
||||
|
||||
stale_import.abandon!
|
||||
|
||||
expect(data_import.reload).to be_completed
|
||||
expect(data_import.abandoned_at).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user