2012-10-09 04:14:17 -04:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: web_hooks
|
|
|
|
#
|
2013-12-03 12:11:10 -05:00
|
|
|
# id :integer not null, primary key
|
|
|
|
# url :string(255)
|
|
|
|
# project_id :integer
|
2014-04-09 08:05:03 -04:00
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2013-12-03 12:11:10 -05:00
|
|
|
# type :string(255) default("ProjectHook")
|
|
|
|
# service_id :integer
|
|
|
|
# push_events :boolean default(TRUE), not null
|
|
|
|
# issues_events :boolean default(FALSE), not null
|
|
|
|
# merge_requests_events :boolean default(FALSE), not null
|
2014-04-09 08:05:03 -04:00
|
|
|
# tag_push_events :boolean default(FALSE)
|
2012-10-09 04:14:17 -04:00
|
|
|
#
|
|
|
|
|
2012-07-18 17:24:37 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe SystemHook do
|
|
|
|
describe "execute" do
|
|
|
|
before(:each) do
|
2012-11-05 22:31:55 -05:00
|
|
|
@system_hook = create(:system_hook)
|
2012-07-18 17:24:37 -04:00
|
|
|
WebMock.stub_request(:post, @system_hook.url)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "project_create hook" do
|
2014-06-17 16:49:17 -04:00
|
|
|
Projects::CreateService.new(create(:user), name: 'empty').execute
|
2012-07-18 17:24:37 -04:00
|
|
|
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
|
2012-07-18 17:24:37 -04:00
|
|
|
it "project_destroy hook" do
|
2014-06-17 16:49:17 -04:00
|
|
|
user = create(:user)
|
|
|
|
project = create(:empty_project, namespace: user.namespace)
|
|
|
|
Projects::DestroyService.new(project, user, {}).execute
|
2012-07-18 17:24:37 -04:00
|
|
|
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_destroy/).once
|
|
|
|
end
|
|
|
|
|
|
|
|
it "user_create hook" do
|
2013-01-09 01:14:05 -05:00
|
|
|
create(:user)
|
2012-07-18 17:24:37 -04:00
|
|
|
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
|
2012-07-18 17:24:37 -04:00
|
|
|
it "user_destroy hook" do
|
2012-11-05 22:31:55 -05:00
|
|
|
user = create(:user)
|
2013-01-09 01:14:05 -05:00
|
|
|
user.destroy
|
2012-07-18 17:24:37 -04:00
|
|
|
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_destroy/).once
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
|
2012-07-18 17:24:37 -04:00
|
|
|
it "project_create hook" do
|
2012-11-05 22:31:55 -05:00
|
|
|
user = create(:user)
|
|
|
|
project = create(:project)
|
2013-01-09 01:14:05 -05:00
|
|
|
project.team << [user, :master]
|
2012-07-18 17:24:37 -04:00
|
|
|
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
|
2012-07-18 17:24:37 -04:00
|
|
|
it "project_destroy hook" do
|
2012-11-05 22:31:55 -05:00
|
|
|
user = create(:user)
|
|
|
|
project = create(:project)
|
2013-01-04 01:43:25 -05:00
|
|
|
project.team << [user, :master]
|
2014-06-02 10:22:51 -04:00
|
|
|
project.users_projects.destroy_all
|
2012-07-18 17:24:37 -04:00
|
|
|
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|