Commit 8a08fdcd32ec58bc538ce5b6fc9df3fbe61d05e1
1 parent
80e984ee
Exists in
master
and in
4 other branches
Fix worker specs to parse namespaces
Showing
2 changed files
with
11 additions
and
6 deletions
Show diff stats
app/workers/post_receive.rb
... | ... | @@ -2,8 +2,9 @@ class PostReceive |
2 | 2 | @queue = :post_receive |
3 | 3 | |
4 | 4 | def self.perform(repo_path, oldrev, newrev, ref, identifier) |
5 | - repo_path = repo_path.gsub(Gitlab.config.git_base_path, "") | |
6 | - repo_path = repo_path.gsub(/.git$/, "") | |
5 | + repo_path.gsub!(Gitlab.config.git_base_path.to_s, "") | |
6 | + repo_path.gsub!(/.git$/, "") | |
7 | + repo_path.gsub!(/^\//, "") | |
7 | 8 | |
8 | 9 | project = Project.find_with_namespace(repo_path) |
9 | 10 | return false if project.nil? | ... | ... |
spec/workers/post_receive_spec.rb
... | ... | @@ -14,8 +14,8 @@ describe PostReceive do |
14 | 14 | let(:key_id) { key.identifier } |
15 | 15 | |
16 | 16 | it "fetches the correct project" do |
17 | - Project.should_receive(:find_by_path).with(project.path).and_return(project) | |
18 | - PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', key_id) | |
17 | + Project.should_receive(:find_by_path).with(project.path_with_namespace).and_return(project) | |
18 | + PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id) | |
19 | 19 | end |
20 | 20 | |
21 | 21 | it "does not run if the author is not in the project" do |
... | ... | @@ -24,7 +24,7 @@ describe PostReceive do |
24 | 24 | project.should_not_receive(:observe_push) |
25 | 25 | project.should_not_receive(:execute_hooks) |
26 | 26 | |
27 | - PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', key_id).should be_false | |
27 | + PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id).should be_false | |
28 | 28 | end |
29 | 29 | |
30 | 30 | it "asks the project to trigger all hooks" do |
... | ... | @@ -34,7 +34,11 @@ describe PostReceive do |
34 | 34 | project.should_receive(:update_merge_requests) |
35 | 35 | project.should_receive(:observe_push) |
36 | 36 | |
37 | - PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', key_id) | |
37 | + PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id) | |
38 | 38 | end |
39 | 39 | end |
40 | + | |
41 | + def pwd(project) | |
42 | + File.join(Gitlab.config.git_base_path, project.path_with_namespace) | |
43 | + end | |
40 | 44 | end | ... | ... |