Commit 0cf0487d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix TestHookContext

parent 4e516433
class TestHookContext < BaseContext class TestHookContext < BaseContext
def execute def execute
hook = project.hooks.find(params[:id]) hook = project.hooks.find(params[:id])
commits = project.repository.commits(project.default_branch, nil, 3) data = GitPushService.new.sample_data(project, current_user)
data = project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{project.default_branch}", current_user)
hook.execute(data) hook.execute(data)
end end
end end
...@@ -31,6 +31,16 @@ class GitPushService ...@@ -31,6 +31,16 @@ class GitPushService
create_push_event create_push_event
end end
# This method provide a sample data
# generated with post_receive_data method
# for given project
#
def sample_data(project, user)
@project, @user = project, user
commits = project.repository.commits(project.default_branch, nil, 3)
post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{project.default_branch}")
end
protected protected
def create_push_event def create_push_event
......
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