Commit 172f253a authored by Michael Kozono's avatar Michael Kozono

Include all email opt-in data for marketo

parent 1012b1c2
...@@ -5,12 +5,23 @@ module EE ...@@ -5,12 +5,23 @@ module EE
private private
def user_data(model) def user_data(model)
{ data = {
name: model.name, name: model.name,
email: model.email, email: model.email,
user_id: model.id, user_id: model.id,
username: model.username, username: model.username
email_opted_in: model.email_opted_in }
data.merge!(email_opted_in_data(model)) if ::Gitlab.com?
data
end
def email_opted_in_data(model)
{
email_opted_in: model.email_opted_in,
email_opted_in_ip: model.email_opted_in_ip,
email_opted_in_source: model.email_opted_in_source,
email_opted_in_at: model.email_opted_in_at,
} }
end end
end end
......
...@@ -4,8 +4,23 @@ describe EE::SystemHooksService do ...@@ -4,8 +4,23 @@ describe EE::SystemHooksService do
let(:user) { create(:user) } let(:user) { create(:user) }
context 'event data' do context 'event data' do
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username, :email_opted_in) } context 'for GitLab.com' do
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username, :email_opted_in) } 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
context 'for non-GitLab.com' do
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
def event_data(*args) def event_data(*args)
......
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