summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-27 12:49:24 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-27 12:49:24 -0800
commit5e20cb82d74fea786e6dad436fb0a4dff8305646 (patch)
treea284a0f164337e99c9255a8875c626ffb67ba0fd /spec
parentb35f1d1c2f8741e777a670e06785b6ff47e7e764 (diff)
parent93bc2d5202e5802bd31419d05232b62355516a53 (diff)
downloadgitlab-ce-5e20cb82d74fea786e6dad436fb0a4dff8305646.tar.gz
Merge pull request #8652 from bladealslayer/feature/system_hook_for_groups
Added support for firing system hooks on group create/destroy and adding...
Diffstat (limited to 'spec')
-rw-r--r--spec/models/system_hook_spec.rb35
-rw-r--r--spec/services/system_hooks_service_spec.rb31
2 files changed, 66 insertions, 0 deletions
diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb
index 4ab5261dc9d..8deb732de9c 100644
--- a/spec/models/system_hook_spec.rb
+++ b/spec/models/system_hook_spec.rb
@@ -61,5 +61,40 @@ describe SystemHook do
project.project_members.destroy_all
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
end
+
+ it 'group create hook' do
+ create(:group)
+ WebMock.should have_requested(:post, @system_hook.url).with(
+ body: /group_create/
+ ).once
+ end
+
+ it 'group destroy hook' do
+ group = create(:group)
+ group.destroy
+ WebMock.should have_requested(:post, @system_hook.url).with(
+ body: /group_destroy/
+ ).once
+ end
+
+ it 'group member create hook' do
+ group = create(:group)
+ user = create(:user)
+ group.add_user(user, Gitlab::Access::MASTER)
+ WebMock.should have_requested(:post, @system_hook.url).with(
+ body: /user_add_to_group/
+ ).once
+ end
+
+ it 'group member destroy hook' do
+ group = create(:group)
+ user = create(:user)
+ group.add_user(user, Gitlab::Access::MASTER)
+ group.group_members.destroy_all
+ WebMock.should have_requested(:post, @system_hook.url).with(
+ body: /user_remove_from_group/
+ ).once
+ end
+
end
end
diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb
index 573446d3a19..a45e9d0575c 100644
--- a/spec/services/system_hooks_service_spec.rb
+++ b/spec/services/system_hooks_service_spec.rb
@@ -5,6 +5,8 @@ describe SystemHooksService do
let (:project) { create :project }
let (:project_member) { create :project_member }
let (:key) { create(:key, user: user) }
+ let (:group) { create(:group) }
+ let (:group_member) { create(:group_member) }
context 'event data' do
it { event_data(user, :create).should include(:event_name, :name, :created_at, :email, :user_id) }
@@ -15,6 +17,31 @@ describe SystemHooksService do
it { event_data(project_member, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) }
it { event_data(key, :create).should include(:username, :key, :id) }
it { event_data(key, :destroy).should include(:username, :key, :id) }
+
+ it do
+ event_data(group, :create).should include(
+ :event_name, :name, :created_at, :path, :group_id, :owner_name,
+ :owner_email
+ )
+ end
+ it do
+ event_data(group, :destroy).should include(
+ :event_name, :name, :created_at, :path, :group_id, :owner_name,
+ :owner_email
+ )
+ end
+ it do
+ event_data(group_member, :create).should include(
+ :event_name, :created_at, :group_name, :group_path, :group_id, :user_id,
+ :user_name, :user_email, :group_access
+ )
+ end
+ it do
+ event_data(group_member, :destroy).should include(
+ :event_name, :created_at, :group_name, :group_path, :group_id, :user_id,
+ :user_name, :user_email, :group_access
+ )
+ end
end
context 'event names' do
@@ -26,6 +53,10 @@ describe SystemHooksService do
it { event_name(project_member, :destroy).should eq "user_remove_from_team" }
it { event_name(key, :create).should eq 'key_create' }
it { event_name(key, :destroy).should eq 'key_destroy' }
+ it { event_name(group, :create).should eq 'group_create' }
+ it { event_name(group, :destroy).should eq 'group_destroy' }
+ it { event_name(group_member, :create).should eq 'user_add_to_group' }
+ it { event_name(group_member, :destroy).should eq 'user_remove_from_group' }
end
def event_data(*args)