diff options
Diffstat (limited to 'spec/models/hooks/web_hook_log_spec.rb')
-rw-r--r-- | spec/models/hooks/web_hook_log_spec.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/models/hooks/web_hook_log_spec.rb b/spec/models/hooks/web_hook_log_spec.rb index 2f0bfbd4fed..5be2b2d3bb0 100644 --- a/spec/models/hooks/web_hook_log_spec.rb +++ b/spec/models/hooks/web_hook_log_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe WebHookLog do +RSpec.describe WebHookLog, feature_category: :integrations do it { is_expected.to belong_to(:web_hook) } it { is_expected.to serialize(:request_headers).as(Hash) } @@ -94,6 +94,35 @@ RSpec.describe WebHookLog do end end + describe 'before_save' do + describe '#set_url_hash' do + let(:web_hook_log) { build(:web_hook_log, interpolated_url: interpolated_url) } + + subject(:save_web_hook_log) { web_hook_log.save! } + + context 'when interpolated_url is nil' do + let(:interpolated_url) { nil } + + it { expect { save_web_hook_log }.not_to change { web_hook_log.url_hash } } + end + + context 'when interpolated_url has a blank value' do + let(:interpolated_url) { ' ' } + + it { expect { save_web_hook_log }.not_to change { web_hook_log.url_hash } } + end + + context 'when interpolated_url has a value' do + let(:interpolated_url) { 'example@gitlab.com' } + let(:expected_value) { Gitlab::CryptoHelper.sha256(interpolated_url) } + + it 'assigns correct digest value' do + expect { save_web_hook_log }.to change { web_hook_log.url_hash }.from(nil).to(expected_value) + end + end + end + end + describe '.delete_batch_for' do let_it_be(:hook) { build(:project_hook) } let_it_be(:hook2) { build(:project_hook) } |