summaryrefslogtreecommitdiff
path: root/spec/models/alert_management/http_integration_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/alert_management/http_integration_spec.rb')
-rw-r--r--spec/models/alert_management/http_integration_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/models/alert_management/http_integration_spec.rb b/spec/models/alert_management/http_integration_spec.rb
index ddd65e723eb..f88a66a7c27 100644
--- a/spec/models/alert_management/http_integration_spec.rb
+++ b/spec/models/alert_management/http_integration_spec.rb
@@ -81,6 +81,32 @@ RSpec.describe AlertManagement::HttpIntegration do
end
end
+ describe 'before validation' do
+ describe '#ensure_payload_example_not_nil' do
+ subject(:integration) { build(:alert_management_http_integration, payload_example: payload_example) }
+
+ context 'when the payload_example is nil' do
+ let(:payload_example) { nil }
+
+ it 'sets the payload_example to empty JSON' do
+ integration.valid?
+
+ expect(integration.payload_example).to eq({})
+ end
+ end
+
+ context 'when the payload_example is not nil' do
+ let(:payload_example) { { 'key' => 'value' } }
+
+ it 'sets the payload_example to specified value' do
+ integration.valid?
+
+ expect(integration.payload_example).to eq(payload_example)
+ end
+ end
+ end
+ end
+
describe '#token' do
subject { integration.token }