2013-02-20 05:53:15 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe SystemHooksService do
|
|
|
|
let (:user) { create :user }
|
|
|
|
let (:project) { create :project }
|
|
|
|
let (:users_project) { create :users_project }
|
|
|
|
|
2013-10-08 04:06:38 -04:00
|
|
|
context 'event data' do
|
|
|
|
it { event_data(user, :create).should include(:event_name, :name, :created_at, :email, :user_id) }
|
|
|
|
it { event_data(user, :destroy).should include(:event_name, :name, :created_at, :email, :user_id) }
|
|
|
|
it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) }
|
|
|
|
it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) }
|
|
|
|
it { event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) }
|
|
|
|
it { event_data(users_project, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) }
|
2013-02-20 05:53:15 -05:00
|
|
|
end
|
|
|
|
|
2013-10-08 04:06:38 -04:00
|
|
|
context 'event names' do
|
|
|
|
it { event_name(user, :create).should eq "user_create" }
|
|
|
|
it { event_name(user, :destroy).should eq "user_destroy" }
|
|
|
|
it { event_name(project, :create).should eq "project_create" }
|
|
|
|
it { event_name(project, :destroy).should eq "project_destroy" }
|
|
|
|
it { event_name(users_project, :create).should eq "user_add_to_team" }
|
|
|
|
it { event_name(users_project, :destroy).should eq "user_remove_from_team" }
|
|
|
|
end
|
2013-02-20 05:53:15 -05:00
|
|
|
|
2013-10-08 04:06:38 -04:00
|
|
|
def event_data(*args)
|
2014-01-15 07:26:05 -05:00
|
|
|
SystemHooksService.new.send :build_event_data, *args
|
2013-10-08 04:06:38 -04:00
|
|
|
end
|
2013-02-20 05:53:15 -05:00
|
|
|
|
2013-10-08 04:06:38 -04:00
|
|
|
def event_name(*args)
|
2014-01-15 07:26:05 -05:00
|
|
|
SystemHooksService.new.send :build_event_name, *args
|
2013-02-20 05:53:15 -05:00
|
|
|
end
|
|
|
|
end
|