diff options
author | GitLab Release Tools Bot <delivery-team+release-tools@gitlab.com> | 2023-03-30 21:08:43 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <delivery-team+release-tools@gitlab.com> | 2023-03-30 21:08:43 +0000 |
commit | 125e519c15ece1361000fcdb8379cb40329b33fd (patch) | |
tree | 78253d9abc4a68b07c0013e4d8448f0104cd199d /spec/models/hooks/web_hook_spec.rb | |
parent | b405157ce7809b3671155faa8f3c3395e3fc74ce (diff) | |
parent | d6192c2ab77ab814b9bd66103663047556fd67e4 (diff) | |
download | gitlab-ce-125e519c15ece1361000fcdb8379cb40329b33fd.tar.gz |
Merge remote-tracking branch 'dev/15-9-stable' into 15-9-stable
Diffstat (limited to 'spec/models/hooks/web_hook_spec.rb')
-rw-r--r-- | spec/models/hooks/web_hook_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb index 72958a54e10..ad5f01fe056 100644 --- a/spec/models/hooks/web_hook_spec.rb +++ b/spec/models/hooks/web_hook_spec.rb @@ -242,6 +242,22 @@ RSpec.describe WebHook, feature_category: :integrations do expect(hook.url_variables).to eq({}) end + it 'resets url variables if url is changed and url variables are appended' do + hook.url = 'http://suspicious.example.com/{abc}/{foo}' + hook.url_variables = hook.url_variables.merge('foo' => 'bar') + + expect(hook).not_to be_valid + expect(hook.url_variables).to eq({}) + end + + it 'resets url variables if url is changed and url variables are removed' do + hook.url = 'http://suspicious.example.com/{abc}' + hook.url_variables = hook.url_variables.except("def") + + expect(hook).not_to be_valid + expect(hook.url_variables).to eq({}) + end + it 'does not reset url variables if both url and url variables are changed' do hook.url = 'http://example.com/{one}/{two}' hook.url_variables = { 'one' => 'foo', 'two' => 'bar' } @@ -249,6 +265,18 @@ RSpec.describe WebHook, feature_category: :integrations do expect(hook).to be_valid expect(hook.url_variables).to eq({ 'one' => 'foo', 'two' => 'bar' }) end + + context 'without url variables' do + subject(:hook) { build_stubbed(:project_hook, project: project, url: 'http://example.com') } + + it 'does not reset url variables' do + hook.url = 'http://example.com/{one}/{two}' + hook.url_variables = { 'one' => 'foo', 'two' => 'bar' } + + expect(hook).to be_valid + expect(hook.url_variables).to eq({ 'one' => 'foo', 'two' => 'bar' }) + end + end end it "only consider these branch filter strategies are valid" do |