houdini/spec/models/object_event_hook_config_spec.rb

38 lines
1.2 KiB
Ruby
Raw Normal View History

2021-02-09 01:37:47 +00:00
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
require 'rails_helper'
RSpec.describe ObjectEventHookConfig, type: :model do
let(:nonprofit) { create(:nm_justice) }
let(:open_fn_config) { create(:open_fn_config, nonprofit_id: nonprofit.id) }
describe 'validation' do
subject{ oehc = ObjectEventHookConfig.new(object_event_types:[]); oehc.validate; oehc}
it 'has an error for webhook_service missing' do
expect(subject.errors[:webhook_service]).to_not be_nil
end
it 'has an error for configuraiton missing' do
expect(subject.errors[:configuration]).to_not be_nil
end
it 'has an error for configuraition empty' do
expect(subject.errors[:object_event_types]).to_not be_empty
end
end
2021-02-09 01:37:47 +00:00
describe '.webhook' do
it 'returns an instance of OpenFn webhook' do
webhook = double
2021-02-09 23:46:19 +00:00
expect(Houdini::WebhookAdapter)
.to receive(:build)
.with(open_fn_config.webhook_service, open_fn_config.configuration.symbolize_keys)
2021-02-09 01:37:47 +00:00
.and_return(webhook)
result = open_fn_config.webhook
expect(result).to eq(webhook)
end
end
end