gitlabhq/spec/models/system_hook_spec.rb

75 lines
1.9 KiB
Ruby
Raw Normal View History

2012-10-09 10:14:17 +02:00
# == Schema Information
#
# Table name: web_hooks
#
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# type :string(255) default("ProjectHook")
#
2012-07-18 23:24:37 +02:00
require "spec_helper"
describe SystemHook do
describe "execute" do
2012-07-20 11:08:59 +02:00
before(:each) { ActiveRecord::Base.observers.enable(:all) }
2012-07-18 23:24:37 +02:00
before(:each) do
@system_hook = Factory :system_hook
WebMock.stub_request(:post, @system_hook.url)
end
it "project_create hook" do
with_resque do
project = Factory :project
2012-07-18 23:24:37 +02:00
end
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once
end
2012-07-18 23:24:37 +02:00
it "project_destroy hook" do
project = Factory :project
with_resque do
project.destroy
end
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_destroy/).once
end
it "user_create hook" do
with_resque do
Factory :user
end
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once
end
2012-07-18 23:24:37 +02:00
it "user_destroy hook" do
user = Factory :user
with_resque do
user.destroy
end
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_destroy/).once
end
2012-07-18 23:24:37 +02:00
it "project_create hook" do
user = Factory :user
project = Factory :project
with_resque do
project.users << user
end
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once
end
2012-07-18 23:24:37 +02:00
it "project_destroy hook" do
user = Factory :user
project = Factory :project
project.users << user
with_resque do
project.users_projects.clear
end
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
end
end
end