diff options
| author | Jason Hollingsworth <jhworth.developer@gmail.com> | 2013-12-20 13:12:44 -0600 |
|---|---|---|
| committer | Jason Hollingsworth <jhworth.developer@gmail.com> | 2014-01-02 10:18:56 -0600 |
| commit | 7cc25205410efc6b20b11d94ab2cbc1a322ff816 (patch) | |
| tree | 8d8ce2cd304bd46426bb4c186ca690e6650e5d57 /spec | |
| parent | b512fbc0ecba0a8de9c9efe5c7d82a97f0ea744c (diff) | |
| download | gitlab-ce-7cc25205410efc6b20b11d94ab2cbc1a322ff816.tar.gz | |
Add support for various archive formats.
Used mime-types gem instead of hardcoding content types.
Allow multiple extensions in archive route (.tar.gz, .tar.bz2).
Change content disposition from infile(?) to attachment for api.
Fixed api would return “archive” instead of {project}-{hash}.{ext}
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/requests/api/repositories_spec.rb | 23 | ||||
| -rw-r--r-- | spec/routing/project_routing_spec.rb | 8 |
2 files changed, 29 insertions, 2 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index e078efcc50a..f73ac4372b2 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' +require 'mime/types' describe API::API do include ApiHelpers @@ -232,11 +233,29 @@ describe API::API do end end - describe "GET /projects/:id/repository/archive/:sha" do + describe "GET /projects/:id/repository/archive(.:format)?:sha" do it "should get the archive" do get api("/projects/#{project.id}/repository/archive", user) + repo_name = project.repository.name.gsub("\.git", "") response.status.should == 200 - response.content_type.should == 'application/x-gzip' + response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.tar.gz\"/ + response.content_type.should == MIME::Types.type_for('file.tar.gz').first.content_type + end + + it "should get the archive.zip" do + get api("/projects/#{project.id}/repository/archive.zip", user) + repo_name = project.repository.name.gsub("\.git", "") + response.status.should == 200 + response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.zip\"/ + response.content_type.should == MIME::Types.type_for('file.zip').first.content_type + end + + it "should get the archive.tar.bz2" do + get api("/projects/#{project.id}/repository/archive.tar.bz2", user) + repo_name = project.repository.name.gsub("\.git", "") + response.status.should == 200 + response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.tar.bz2\"/ + response.content_type.should == MIME::Types.type_for('file.tar.bz2').first.content_type end it "should return 404 for invalid sha" do diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 5597f08d186..97f7392e50a 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -130,6 +130,14 @@ describe Projects::RepositoriesController, "routing" do get("/gitlab/gitlabhq/repository/archive").should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq') end + it "to #archive format:zip" do + get("/gitlab/gitlabhq/repository/archive.zip").should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq', format: 'zip') + end + + it "to #archive format:tar.bz2" do + get("/gitlab/gitlabhq/repository/archive.tar.bz2").should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq', format: 'tar.bz2') + end + it "to #show" do get("/gitlab/gitlabhq/repository").should route_to('projects/repositories#show', project_id: 'gitlab/gitlabhq') end |
