Commit 8a08fdcd authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix worker specs to parse namespaces

parent 80e984ee
...@@ -2,8 +2,9 @@ class PostReceive ...@@ -2,8 +2,9 @@ class PostReceive
@queue = :post_receive @queue = :post_receive
def self.perform(repo_path, oldrev, newrev, ref, identifier) def self.perform(repo_path, oldrev, newrev, ref, identifier)
repo_path = repo_path.gsub(Gitlab.config.git_base_path, "") repo_path.gsub!(Gitlab.config.git_base_path.to_s, "")
repo_path = repo_path.gsub(/.git$/, "") repo_path.gsub!(/.git$/, "")
repo_path.gsub!(/^\//, "")
project = Project.find_with_namespace(repo_path) project = Project.find_with_namespace(repo_path)
return false if project.nil? return false if project.nil?
......
...@@ -14,8 +14,8 @@ describe PostReceive do ...@@ -14,8 +14,8 @@ describe PostReceive do
let(:key_id) { key.identifier } let(:key_id) { key.identifier }
it "fetches the correct project" do it "fetches the correct project" do
Project.should_receive(:find_by_path).with(project.path).and_return(project) Project.should_receive(:find_by_path).with(project.path_with_namespace).and_return(project)
PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', key_id) PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id)
end end
it "does not run if the author is not in the project" do it "does not run if the author is not in the project" do
...@@ -24,7 +24,7 @@ describe PostReceive do ...@@ -24,7 +24,7 @@ describe PostReceive do
project.should_not_receive(:observe_push) project.should_not_receive(:observe_push)
project.should_not_receive(:execute_hooks) project.should_not_receive(:execute_hooks)
PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', key_id).should be_false PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id).should be_false
end end
it "asks the project to trigger all hooks" do it "asks the project to trigger all hooks" do
...@@ -34,7 +34,11 @@ describe PostReceive do ...@@ -34,7 +34,11 @@ describe PostReceive do
project.should_receive(:update_merge_requests) project.should_receive(:update_merge_requests)
project.should_receive(:observe_push) project.should_receive(:observe_push)
PostReceive.perform(project.path, 'sha-old', 'sha-new', 'refs/heads/master', key_id) PostReceive.perform(pwd(project), 'sha-old', 'sha-new', 'refs/heads/master', key_id)
end end
end end
def pwd(project)
File.join(Gitlab.config.git_base_path, project.path_with_namespace)
end
end end
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