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
private
def user_data(model)
{
data = {
name: model.name,
email: model.email,
user_id: model.id,
username: model.username,
email_opted_in: model.email_opted_in
username: model.username
}
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
......
......@@ -4,8 +4,23 @@ describe EE::SystemHooksService do
let(:user) { create(:user) }
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) }
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username, :email_opted_in) }
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
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
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