Commit 0cf0487d65a482b1e9d8dfe69899e333216a387c
1 parent
4e516433
Exists in
master
and in
4 other branches
Fix TestHookContext
Showing
2 changed files
with
11 additions
and
2 deletions
Show diff stats
app/contexts/test_hook_context.rb
1 | 1 | class TestHookContext < BaseContext |
2 | 2 | def execute |
3 | 3 | hook = project.hooks.find(params[:id]) |
4 | - commits = project.repository.commits(project.default_branch, nil, 3) | |
5 | - data = project.post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{project.default_branch}", current_user) | |
4 | + data = GitPushService.new.sample_data(project, current_user) | |
6 | 5 | hook.execute(data) |
7 | 6 | end |
8 | 7 | end | ... | ... |
app/services/git_push_service.rb
... | ... | @@ -31,6 +31,16 @@ class GitPushService |
31 | 31 | create_push_event |
32 | 32 | end |
33 | 33 | |
34 | + # This method provide a sample data | |
35 | + # generated with post_receive_data method | |
36 | + # for given project | |
37 | + # | |
38 | + def sample_data(project, user) | |
39 | + @project, @user = project, user | |
40 | + commits = project.repository.commits(project.default_branch, nil, 3) | |
41 | + post_receive_data(commits.last.id, commits.first.id, "refs/heads/#{project.default_branch}") | |
42 | + end | |
43 | + | |
34 | 44 | protected |
35 | 45 | |
36 | 46 | def create_push_event | ... | ... |