diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-03-15 15:42:31 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-03-15 16:52:22 +0100 |
commit | 3b1d5a1dffa35746d3619b90f3e82f8437e38c91 (patch) | |
tree | e38174737f589e350a6a7359d953b7d60fad9cfe /spec/workers | |
parent | 60df262c38d7c235b483cc1c4beb12f793e0e58a (diff) | |
download | gitlab-ce-3b1d5a1dffa35746d3619b90f3e82f8437e38c91.tar.gz |
Prevent gitlab-shell character encoding issues by receiving its changes as raw data.
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/post_receive_spec.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 8eabc46112b..df1a2b84a53 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -1,6 +1,10 @@ require 'spec_helper' describe PostReceive do + let(:changes) { "123456 789012 refs/heads/tést\n654321 210987 refs/tags/tag" } + let(:wrongly_encoded_changes) { changes.encode("ISO-8859-1").force_encoding("UTF-8") } + let(:base64_changes) { Base64.encode64(wrongly_encoded_changes) } + context "as a resque worker" do it "reponds to #perform" do expect(PostReceive.new).to respond_to(:perform) @@ -14,7 +18,7 @@ describe PostReceive do it "fetches the correct project" do expect(Project).to receive(:find_with_namespace).with(project.path_with_namespace).and_return(project) - PostReceive.new.perform(pwd(project), key_id, changes) + PostReceive.new.perform(pwd(project), key_id, base64_changes) end it "does not run if the author is not in the project" do @@ -22,24 +26,20 @@ describe PostReceive do expect(project).not_to receive(:execute_hooks) - expect(PostReceive.new.perform(pwd(project), key_id, changes)).to be_falsey + expect(PostReceive.new.perform(pwd(project), key_id, base64_changes)).to be_falsey end it "asks the project to trigger all hooks" do Project.stub(find_with_namespace: project) - expect(project).to receive(:execute_hooks) - expect(project).to receive(:execute_services) + expect(project).to receive(:execute_hooks).twice + expect(project).to receive(:execute_services).twice expect(project).to receive(:update_merge_requests) - PostReceive.new.perform(pwd(project), key_id, changes) + PostReceive.new.perform(pwd(project), key_id, base64_changes) end end def pwd(project) File.join(Gitlab.config.gitlab_shell.repos_path, project.path_with_namespace) end - - def changes - 'd14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master' - end end |