summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-30 19:11:46 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-31 18:34:45 -0300
commit21f10af0956c69b6a5bad6b36b7d6e12e60e7867 (patch)
treeb67fa1c084a144f89559e14b0be5c5a0e7421c76 /spec/services
parentdd64f8aaf867516043dbbf559595a0ed9671ab3b (diff)
downloadgitlab-ce-21f10af0956c69b6a5bad6b36b7d6e12e60e7867.tar.gz
Scope hooks thal will run for confidential issues
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/issues/close_service_spec.rb15
-rw-r--r--spec/services/issues/create_service_spec.rb15
-rw-r--r--spec/services/issues/reopen_service_spec.rb30
-rw-r--r--spec/services/issues/update_service_spec.rb6
4 files changed, 49 insertions, 17 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index 4df99e41987..5dfb33f4b28 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -53,12 +53,21 @@ describe Issues::CloseService, services: true do
end
end
+ context 'when issue is not confidential' do
+ it 'executes issue hooks' do
+ expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
+ expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks)
+
+ described_class.new(project, user).execute(issue)
+ end
+ end
+
context 'when issue is confidential' do
- it 'does not execute hooks' do
+ it 'executes confidential issue hooks' do
issue = create(:issue, :confidential, project: project)
- expect(project).not_to receive(:execute_hooks)
- expect(project).not_to receive(:execute_services)
+ expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
+ expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks)
described_class.new(project, user).execute(issue)
end
diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb
index 81beca47738..58569ba96c3 100644
--- a/spec/services/issues/create_service_spec.rb
+++ b/spec/services/issues/create_service_spec.rb
@@ -73,11 +73,20 @@ describe Issues::CreateService, services: true do
end
end
- it 'does not execute hooks when issue is confidential' do
+ it 'executes issue hooks when issue is not confidential' do
+ opts = { title: 'Title', description: 'Description', confidential: false }
+
+ expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
+ expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks)
+
+ described_class.new(project, user, opts).execute
+ end
+
+ it 'executes confidential issue hooks when issue is confidential' do
opts = { title: 'Title', description: 'Description', confidential: true }
- expect(project).not_to receive(:execute_hooks)
- expect(project).not_to receive(:execute_services)
+ expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
+ expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks)
described_class.new(project, user, opts).execute
end
diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb
index 4549e2b395b..93a8270fd16 100644
--- a/spec/services/issues/reopen_service_spec.rb
+++ b/spec/services/issues/reopen_service_spec.rb
@@ -5,7 +5,7 @@ describe Issues::ReopenService, services: true do
let(:issue) { create(:issue, :closed, project: project) }
describe '#execute' do
- context 'current user is not authorized to reopen issue' do
+ context 'when user is not authorized to reopen issue' do
before do
guest = create(:user)
project.team << [guest, :guest]
@@ -20,17 +20,31 @@ describe Issues::ReopenService, services: true do
end
end
- context 'when issue is confidential' do
- it 'does not execute hooks' do
- user = create(:user)
+ context 'when user is authrized to reopen issue' do
+ let(:user) { create(:user) }
+
+ before do
project.team << [user, :master]
+ end
+
+ context 'when issue is not confidential' do
+ it 'executes issue hooks' do
+ expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
+ expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks)
- issue = create(:issue, :confidential, :closed, project: project)
+ described_class.new(project, user).execute(issue)
+ end
+ end
- expect(project).not_to receive(:execute_hooks)
- expect(project).not_to receive(:execute_services)
+ context 'when issue is confidential' do
+ it 'executes confidential issue hooks' do
+ issue = create(:issue, :confidential, :closed, project: project)
- described_class.new(project, user).execute(issue)
+ expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
+ expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks)
+
+ described_class.new(project, user).execute(issue)
+ end
end
end
end
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 3c3a861b3af..4f5375a3583 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -105,9 +105,9 @@ describe Issues::UpdateService, services: true do
expect(note.note).to eq 'Made the issue confidential'
end
- it 'does not execute hooks' do
- expect(project).not_to receive(:execute_hooks)
- expect(project).not_to receive(:execute_services)
+ it 'executes confidential issue hooks' do
+ expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
+ expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks)
update_issue(confidential: true)
end