diff options
author | Johan Sørensen <johan@johansorensen.com> | 2009-02-11 15:11:48 +0100 |
---|---|---|
committer | Johan Sørensen <johan@johansorensen.com> | 2009-04-22 14:05:16 +0200 |
commit | e539846e5e1a262b2fb4b768f288d4942fdd6f3e (patch) | |
tree | 95f4135c7f16290b2e116a44cd6af976fd45ecc5 | |
parent | 423392c2bb59f69342464c514351790c01f5e226 (diff) | |
download | gitorious-mainline-outdated-e539846e5e1a262b2fb4b768f288d4942fdd6f3e.zip gitorious-mainline-outdated-e539846e5e1a262b2fb4b768f288d4942fdd6f3e.tar.gz gitorious-mainline-outdated-e539846e5e1a262b2fb4b768f288d4942fdd6f3e.tar.bz2 |
Work around a rails 2.3 bug, until we have time to fix it proper
-rw-r--r-- | app/controllers/trees_controller.rb | 6 | ||||
-rw-r--r-- | config/routes.rb | 3 | ||||
-rw-r--r-- | spec/controllers/trees_controller_spec.rb | 42 |
3 files changed, 47 insertions, 4 deletions
diff --git a/app/controllers/trees_controller.rb b/app/controllers/trees_controller.rb index 66f35a0..8ae55f4 100644 --- a/app/controllers/trees_controller.rb +++ b/app/controllers/trees_controller.rb @@ -40,8 +40,10 @@ class TreesController < ApplicationController end def archive - @git = @repository.git - @commit = @git.commit(desplat_path(params[:branch])) + @git = @repository.git + # FIXME: update route when we've fixed rails bug #1939 + ref, ext = desplat_path(params[:branch]).split(".", 2) + @commit = @git.commit(ref) if @commit prefix = "#{@project.slug}-#{@repository.name}" diff --git a/config/routes.rb b/config/routes.rb index 7ade326..e6976da 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -40,8 +40,7 @@ ActionController::Routing::Routes.draw do |map| repo.trees "tree/", :controller => "trees", :action => "index" repo.tree "tree/*branch_and_path", :controller => "trees", :action => "show" repo.formatted_tree "trees/*branch_and_path.:format", :controller => "trees", :action => "show" - repo.archive_tree "archive/*branch.:format", :controller => "trees", :action => "archive", - :requirements => { :format => /zip|tar\.gz/ } + repo.archive_tree "archive/*branch.:format", :controller => "trees", :action => "archive" repo.raw_blob "blobs/raw/*branch_and_path", :controller => "blobs", :action => "raw" repo.blob "blobs/*branch_and_path", :controller => "blobs", :action => "show" end diff --git a/spec/controllers/trees_controller_spec.rb b/spec/controllers/trees_controller_spec.rb index 822d8b8..5b88f83 100644 --- a/spec/controllers/trees_controller_spec.rb +++ b/spec/controllers/trees_controller_spec.rb @@ -20,6 +20,48 @@ require File.dirname(__FILE__) + '/../spec_helper' describe TreesController do + describe "routing" do + it "recognizes a single glob with a format" do + pending "fix rails bug #1939" + params_from(:get, "/proj/repo/archive/foo.tar.gz").should == { + :controller => "trees", + :action => "archive", + :project_id => "proj", + :repository_id => "repo", + :branch => ["foo"], + :format => "tar.gz", + } + params_from(:get, "/proj/repo/archive/foo.zip").should == { + :controller => "trees", + :action => "archive", + :project_id => "proj", + :repository_id => "repo", + :branch => ["foo"], + :format => "zip", + } + end + + it "recognizes multiple globs with a format" do + pending "fix rails bug #1939" + params_from(:get, "/proj/repo/archive/foo/bar.zip").should == { + :controller => "trees", + :action => "archive", + :project_id => "proj", + :repository_id => "repo", + :branch => ["foo", "bar"], + :format => "zip", + } + params_from(:get, "/proj/repo/archive/foo/bar.tar.gz").should == { + :controller => "trees", + :action => "archive", + :project_id => "proj", + :repository_id => "repo", + :branch => ["foo", "bar"], + :format => "tar.gz", + } + end + end + before(:each) do @project = projects(:johans) @repository = @project.repositories.first |