summaryrefslogtreecommitdiff
path: root/spec/controllers/projects/commits_controller_spec.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-10-07 16:49:48 +0100
committerSean McGivern <sean@gitlab.com>2016-10-11 13:31:12 +0100
commit1022456bb15d18b05c14fe344950fb75c7c69f48 (patch)
treeaace3fadc569905719232d73811739961450c22e /spec/controllers/projects/commits_controller_spec.rb
parent8581df3bfb9e847d07a585a22cfa21658ae40ea2 (diff)
downloadgitlab-ce-1022456bb15d18b05c14fe344950fb75c7c69f48.tar.gz
Allow browsing branches that end with '.atom'
We need to do two things to support this: 1. Simplify the regex capture in the routing for the CommitsController to not exclude the '.atom' suffix. That's a perfectly valid git branch name, so we shouldn't blow up if we get it. 2. Because Rails now can't automatically detect the request format, add some code to do so in `ExtractPath` when there is no path. This means that, given branches 'foo' and 'foo.atom', the Atom feed for the former is unroutable. To fix this: don't do that! Give the branches different names!
Diffstat (limited to 'spec/controllers/projects/commits_controller_spec.rb')
-rw-r--r--spec/controllers/projects/commits_controller_spec.rb41
1 files changed, 32 insertions, 9 deletions
diff --git a/spec/controllers/projects/commits_controller_spec.rb b/spec/controllers/projects/commits_controller_spec.rb
index 2518a48e336..1ac7e03a2db 100644
--- a/spec/controllers/projects/commits_controller_spec.rb
+++ b/spec/controllers/projects/commits_controller_spec.rb
@@ -10,15 +10,38 @@ describe Projects::CommitsController do
end
describe "GET show" do
- context "as atom feed" do
- it "renders as atom" do
- get(:show,
- namespace_id: project.namespace.to_param,
- project_id: project.to_param,
- id: "master",
- format: "atom")
- expect(response).to be_success
- expect(response.content_type).to eq('application/atom+xml')
+ context "when the ref name ends in .atom" do
+ render_views
+
+ context "when the ref does not exist with the suffix" do
+ it "renders as atom" do
+ get(:show,
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: "master.atom")
+
+ expect(response).to be_success
+ expect(response.content_type).to eq('application/atom+xml')
+ end
+ end
+
+ context "when the ref exists with the suffix" do
+ before do
+ commit = project.repository.commit('master')
+
+ allow_any_instance_of(Repository).to receive(:commit).and_call_original
+ allow_any_instance_of(Repository).to receive(:commit).with('master.atom').and_return(commit)
+
+ get(:show,
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: "master.atom")
+ end
+
+ it "renders as HTML" do
+ expect(response).to be_success
+ expect(response.content_type).to eq('text/html')
+ end
end
end
end