Commit 87aeadd4 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'mo-refactor-system-hooks-service-spec' into 'master'

De-duplicate system hooks service EE specs

See merge request gitlab-org/gitlab!28470
parents b22ee346 3712268d
...@@ -221,14 +221,12 @@ Gitlab/DuplicateSpecLocation: ...@@ -221,14 +221,12 @@ Gitlab/DuplicateSpecLocation:
- ee/spec/services/merge_requests/create_service_spec.rb - ee/spec/services/merge_requests/create_service_spec.rb
- ee/spec/services/merge_requests/refresh_service_spec.rb - ee/spec/services/merge_requests/refresh_service_spec.rb
- ee/spec/services/merge_requests/update_service_spec.rb - ee/spec/services/merge_requests/update_service_spec.rb
- ee/spec/services/system_hooks_service_spec.rb
- ee/spec/helpers/ee/auth_helper_spec.rb - ee/spec/helpers/ee/auth_helper_spec.rb
- ee/spec/models/ee/namespace_spec.rb - ee/spec/models/ee/namespace_spec.rb
- ee/spec/services/ee/issues/create_service_spec.rb - ee/spec/services/ee/issues/create_service_spec.rb
- ee/spec/services/ee/merge_requests/create_service_spec.rb - ee/spec/services/ee/merge_requests/create_service_spec.rb
- ee/spec/services/ee/merge_requests/refresh_service_spec.rb - ee/spec/services/ee/merge_requests/refresh_service_spec.rb
- ee/spec/services/ee/merge_requests/update_service_spec.rb - ee/spec/services/ee/merge_requests/update_service_spec.rb
- ee/spec/services/ee/system_hooks_service_spec.rb
Cop/InjectEnterpriseEditionModule: Cop/InjectEnterpriseEditionModule:
Enabled: true Enabled: true
......
...@@ -3,25 +3,35 @@ ...@@ -3,25 +3,35 @@
require 'spec_helper' require 'spec_helper'
describe EE::SystemHooksService do describe EE::SystemHooksService do
let(:group_member) { create(:group_member) }
let(:user) { create(:user) } let(:user) { create(:user) }
context 'event data' do context 'when group member' do
context 'for GitLab.com' do context 'event data' do
before do it { expect(event_data(group_member, :create)).to include(:event_name, :created_at, :updated_at, :group_name, :group_path, :group_plan, :group_id, :user_name, :user_username, :user_email, :user_id, :group_access) }
expect(Gitlab).to receive(:com?).and_return(true) it { expect(event_data(group_member, :destroy)).to include(:event_name, :created_at, :updated_at, :group_name, :group_path, :group_plan, :group_id, :user_name, :user_username, :user_email, :user_id, :group_access) }
end
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username, :email_opted_in, :email_opted_in_ip, :email_opted_in_source, :email_opted_in_at) }
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username, :email_opted_in, :email_opted_in_ip, :email_opted_in_source, :email_opted_in_at) }
end end
end
context 'for non-GitLab.com' do context 'when user' do
before do context 'event data' do
expect(Gitlab).to receive(:com?).and_return(false) context 'for GitLab.com' do
before do
expect(Gitlab).to receive(:com?).and_return(true)
end
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username, :email_opted_in, :email_opted_in_ip, :email_opted_in_source, :email_opted_in_at) }
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username, :email_opted_in, :email_opted_in_ip, :email_opted_in_source, :email_opted_in_at) }
end end
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) } context 'for non-GitLab.com' do
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) } before do
expect(Gitlab).to receive(:com?).and_return(false)
end
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
end
end end
end end
......
# frozen_string_literal: true
require 'spec_helper'
describe SystemHooksService do
let(:group_member) { create(:group_member) }
context 'event data' do
it { expect(event_data(group_member, :create)).to include(:event_name, :created_at, :updated_at, :group_name, :group_path, :group_plan, :group_id, :user_name, :user_username, :user_email, :user_id, :group_access) }
it { expect(event_data(group_member, :destroy)).to include(:event_name, :created_at, :updated_at, :group_name, :group_path, :group_plan, :group_id, :user_name, :user_username, :user_email, :user_id, :group_access) }
end
def event_data(*args)
SystemHooksService.new.send :build_event_data, *args
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment