-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(salesforce): Add integration models
- Loading branch information
1 parent
a677283
commit 11f82b6
Showing
7 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Integrations | ||
class SalesforceIntegration < BaseIntegration | ||
validates :instance_id, presence: true | ||
validates :code, inclusion: {in: %w[salesforce]} | ||
|
||
settings_accessors :instance_id | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: integrations | ||
# | ||
# id :uuid not null, primary key | ||
# code :string not null | ||
# name :string not null | ||
# secrets :string | ||
# settings :jsonb not null | ||
# type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organization_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_integrations_on_code_and_organization_id (code,organization_id) UNIQUE | ||
# index_integrations_on_organization_id (organization_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (organization_id => organizations.id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Integrations::SalesforceIntegration, type: :model do | ||
subject(:salesforce_integration) { build(:salesforce_integration) } | ||
|
||
it { is_expected.to validate_presence_of(:name) } | ||
it { is_expected.to validate_presence_of(:instance_id) } | ||
it { is_expected.to validate_inclusion_of(:code).in_array(%w[salesforce]) } | ||
|
||
describe 'validations' do | ||
it 'validates uniqueness of the code' do | ||
expect(salesforce_integration).to validate_uniqueness_of(:code).scoped_to(:organization_id) | ||
end | ||
end | ||
|
||
describe '#instance_id' do | ||
it 'assigns and retrieve a setting' do | ||
salesforce_integration.instance_id = 'instance_id_1' | ||
expect(salesforce_integration.instance_id).to eq('instance_id_1') | ||
end | ||
end | ||
|
||
describe '#code' do | ||
it 'returns salesforce' do | ||
expect(salesforce_integration.code).to eq('salesforce') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters