diff options
author | Robert Speicher <robert@gitlab.com> | 2016-03-30 21:16:07 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-03-30 21:16:07 +0000 |
commit | 794674379e31a154b2b71ed492fcccdac12ffe3c (patch) | |
tree | 40c6eca740668e593c35bd96dac3933eed3e3b37 /spec | |
parent | 2fb7392ed7afeb47cfaae4059426aeda45a12cff (diff) | |
parent | 4b1ad75ab5abb48608bb1f6ff1a33b2efce48be8 (diff) | |
download | gitlab-ce-794674379e31a154b2b71ed492fcccdac12ffe3c.tar.gz |
Merge branch 'cleanup-system-hook-spec' into 'master'
minor cleanup in system_hook_spec
Clean up extracted from !3439
See merge request !3459
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/hooks/system_hook_spec.rb | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb index fd1513cab1b..56a9fbe9720 100644 --- a/spec/models/hooks/system_hook_spec.rb +++ b/spec/models/hooks/system_hook_spec.rb @@ -20,24 +20,27 @@ require "spec_helper" describe SystemHook, models: true do describe "execute" do - before(:each) do - @system_hook = create(:system_hook) - WebMock.stub_request(:post, @system_hook.url) + let(:system_hook) { create(:system_hook) } + let(:user) { create(:user) } + let(:project) { create(:project, namespace: user.namespace) } + let(:group) { create(:group) } + + before do + WebMock.stub_request(:post, system_hook.url) end it "project_create hook" do - Projects::CreateService.new(create(:user), name: 'empty').execute - expect(WebMock).to have_requested(:post, @system_hook.url).with( + Projects::CreateService.new(user, name: 'empty').execute + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /project_create/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once end it "project_destroy hook" do - user = create(:user) - project = create(:empty_project, namespace: user.namespace) Projects::DestroyService.new(project, user, {}).pending_delete! - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /project_destroy/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once @@ -45,37 +48,36 @@ describe SystemHook, models: true do it "user_create hook" do create(:user) - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_create/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once end it "user_destroy hook" do - user = create(:user) user.destroy - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_destroy/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once end it "project_create hook" do - user = create(:user) - project = create(:project) project.team << [user, :master] - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_add_to_team/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once end it "project_destroy hook" do - user = create(:user) - project = create(:project) project.team << [user, :master] project.project_members.destroy_all - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_remove_from_team/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once @@ -83,41 +85,39 @@ describe SystemHook, models: true do it 'group create hook' do create(:group) - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /group_create/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once end it 'group destroy hook' do - group = create(:group) group.destroy - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /group_destroy/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once end it 'group member create hook' do - group = create(:group) - user = create(:user) group.add_master(user) - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_add_to_group/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once end it 'group member destroy hook' do - group = create(:group) - user = create(:user) group.add_master(user) group.group_members.destroy_all - expect(WebMock).to have_requested(:post, @system_hook.url).with( + + expect(WebMock).to have_requested(:post, system_hook.url).with( body: /user_remove_from_group/, headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' } ).once end - end end |