2013-02-20 05:53:15 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe SystemHooksService do
|
|
|
|
let (:user) { create :user }
|
|
|
|
let (:project) { create :project }
|
2014-09-15 03:57:02 -04:00
|
|
|
let (:project_member) { create :project_member }
|
2014-08-18 10:46:46 -04:00
|
|
|
let (:key) { create(:key, user: user) }
|
2013-02-20 05:53:15 -05:00
|
|
|
|
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) }
|
2014-05-12 05:23:24 -04:00
|
|
|
it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
|
|
|
|
it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
|
2014-09-15 03:57:02 -04:00
|
|
|
it { event_data(project_member, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) }
|
|
|
|
it { event_data(project_member, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) }
|
2014-08-18 10:46:46 -04:00
|
|
|
it { event_data(key, :create).should include(:username, :key, :id) }
|
|
|
|
it { event_data(key, :destroy).should include(:username, :key, :id) }
|
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" }
|
2014-09-15 03:57:02 -04:00
|
|
|
it { event_name(project_member, :create).should eq "user_add_to_team" }
|
|
|
|
it { event_name(project_member, :destroy).should eq "user_remove_from_team" }
|
2014-08-18 10:46:46 -04:00
|
|
|
it { event_name(key, :create).should eq 'key_create' }
|
|
|
|
it { event_name(key, :destroy).should eq 'key_destroy' }
|
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_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
|