Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/hooks')
-rw-r--r--spec/models/hooks/project_hook_spec.rb9
-rw-r--r--spec/models/hooks/service_hook_spec.rb30
-rw-r--r--spec/models/hooks/system_hook_spec.rb2
3 files changed, 40 insertions, 1 deletions
diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb
index f0ee9a613d8..ec2eca96755 100644
--- a/spec/models/hooks/project_hook_spec.rb
+++ b/spec/models/hooks/project_hook_spec.rb
@@ -40,6 +40,15 @@ RSpec.describe ProjectHook do
end
end
+ describe '#parent' do
+ it 'returns the associated project' do
+ project = build(:project)
+ hook = build(:project_hook, project: project)
+
+ expect(hook.parent).to eq(project)
+ end
+ end
+
describe '#application_context' do
let_it_be(:hook) { build(:project_hook) }
diff --git a/spec/models/hooks/service_hook_spec.rb b/spec/models/hooks/service_hook_spec.rb
index 4ce2e729d89..85f433f5f81 100644
--- a/spec/models/hooks/service_hook_spec.rb
+++ b/spec/models/hooks/service_hook_spec.rb
@@ -31,6 +31,36 @@ RSpec.describe ServiceHook do
end
end
+ describe '#parent' do
+ let(:hook) { build(:service_hook, integration: integration) }
+
+ context 'with a project-level integration' do
+ let(:project) { build(:project) }
+ let(:integration) { build(:integration, project: project) }
+
+ it 'returns the associated project' do
+ expect(hook.parent).to eq(project)
+ end
+ end
+
+ context 'with a group-level integration' do
+ let(:group) { build(:group) }
+ let(:integration) { build(:integration, :group, group: group) }
+
+ it 'returns the associated group' do
+ expect(hook.parent).to eq(group)
+ end
+ end
+
+ context 'with an instance-level integration' do
+ let(:integration) { build(:integration, :instance) }
+
+ it 'returns nil' do
+ expect(hook.parent).to be_nil
+ end
+ end
+ end
+
describe '#application_context' do
let(:hook) { build(:service_hook) }
diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb
index 17cb5da977a..89bfb742f5d 100644
--- a/spec/models/hooks/system_hook_spec.rb
+++ b/spec/models/hooks/system_hook_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe SystemHook do
let(:project) { create(:project, namespace: user.namespace) }
let(:group) { create(:group) }
let(:params) do
- { name: 'John Doe', username: 'jduser', email: 'jg@example.com', password: 'mydummypass' }
+ { name: 'John Doe', username: 'jduser', email: 'jg@example.com', password: Gitlab::Password.test_default }
end
before do