2020-06-12 17:42:47 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Integrations::Hook, type: :model do
|
|
|
|
context 'with validations' do
|
|
|
|
it { is_expected.to validate_presence_of(:app_id) }
|
|
|
|
it { is_expected.to validate_presence_of(:account_id) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'associations' do
|
|
|
|
it { is_expected.to belong_to(:account) }
|
|
|
|
end
|
2021-05-17 05:02:59 +00:00
|
|
|
|
|
|
|
describe 'when trying to create multiple hooks for an app' do
|
|
|
|
let(:account) { create(:account) }
|
|
|
|
|
|
|
|
context 'when app allows multiple hooks' do
|
|
|
|
it 'allows to create succesfully' do
|
|
|
|
create(:integrations_hook, account: account, app_id: 'webhook')
|
2022-07-15 02:51:59 +00:00
|
|
|
expect(build(:integrations_hook, account: account, app_id: 'webhook').valid?).to be true
|
2021-05-17 05:02:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when app doesnot allow multiple hooks' do
|
|
|
|
it 'throws invalid error' do
|
|
|
|
create(:integrations_hook, account: account, app_id: 'slack')
|
2022-07-15 02:51:59 +00:00
|
|
|
expect(build(:integrations_hook, account: account, app_id: 'slack').valid?).to be false
|
2021-05-17 05:02:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-06-12 17:42:47 +00:00
|
|
|
end
|