Commit 72f8a090 authored by Michael Kozono's avatar Michael Kozono

Include email_opted_in in system hooks user data

parent ac26518f
class SystemHooksService
prepend EE::SystemHooksService
def execute_hooks_for(model, event)
execute_hooks(build_event_data(model, event))
end
......@@ -35,12 +37,7 @@ class SystemHooksService
data[:old_path_with_namespace] = model.old_path_with_namespace
end
when User
data.merge!({
name: model.name,
email: model.email,
user_id: model.id,
username: model.username
})
data.merge!(user_data(model))
when ProjectMember
data.merge!(project_member_data(model))
when Group
......@@ -116,4 +113,13 @@ class SystemHooksService
group_access: model.human_access
}
end
def user_data(model)
{
name: model.name,
email: model.email,
user_id: model.id,
username: model.username
}
end
end
module EE
module SystemHooksService
# override
private
def user_data(model)
{
name: model.name,
email: model.email,
user_id: model.id,
username: model.username,
email_opted_in: model.email_opted_in
}
end
end
end
require 'spec_helper'
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) }
end
def event_data(*args)
SystemHooksService.new.send :build_event_data, *args
end
end
......@@ -10,8 +10,8 @@ describe SystemHooksService do
let(:group_member) { create(:group_member) }
context 'event data' do
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) }
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) }
it { expect(event_data(project, :create)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
it { expect(event_data(project, :update)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
it { expect(event_data(project, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
......
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