Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-07-24 09:52:21 +0300
committerStan Hu <stanhu@gmail.com>2015-07-24 20:14:58 +0300
commita5e8ea54eceeb02fe34f0265d8cfe6af8b599098 (patch)
tree595e52ba7c91ed6eeb99bd7c94d0642448727eff /spec/helpers
parent5dd4dea93baa6386ed860a50125dce3ca3890f16 (diff)
Fix Error 500 when browsing projects with no HEAD
Steps to reproduce: 1. Create a project with a README 2. In the actual remote, type: `git symbolic-ref HEAD refs/heads/nowhere` 3. Check that HEAD is gone via `git ls-remote .` 4. Go to the projects page and see the Error 500 Closes https://github.com/gitlabhq/gitlabhq/issues/9484
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/projects_helper_spec.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index beb9b4e438e..99abb95d906 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -22,7 +22,7 @@ describe ProjectsHelper do
let(:user) { create(:user) }
- it "returns false if there are no approipriate permissions" do
+ it "returns false if there are no appropriate permissions" do
allow(helper).to receive(:can?) { false }
expect(helper.can_change_visibility_level?(project, user)).to be_falsey
@@ -52,4 +52,22 @@ describe ProjectsHelper do
end
end
end
+
+ describe "readme_cache_key" do
+ let(:project) { create(:project) }
+
+ before do
+ helper.instance_variable_set(:@project, project)
+ end
+
+ it "returns a valid cach key" do
+ expect(helper.send(:readme_cache_key)).to eq("#{project.id}-#{project.commit.id}-readme")
+ end
+
+ it "returns a valid cache key if HEAD does not exist" do
+ allow(project).to receive(:commit) { nil }
+
+ expect(helper.send(:readme_cache_key)).to eq("#{project.id}-nil-readme")
+ end
+ end
end