summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-05-05 01:01:29 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-05-05 01:01:29 +0000
commitb0414ec1fbabfa8fa84e69eedcf7617fb969fd82 (patch)
tree9c3f633024197ef7756a40c584a25d6545944306
parent569e1b37cc0893cd8b1015a6d12212b205f0fbdf (diff)
downloadredmine-b0414ec1fbabfa8fa84e69eedcf7617fb969fd82.tar.gz
redmine-b0414ec1fbabfa8fa84e69eedcf7617fb969fd82.zip
route: scm: split entry and raw actions
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9625 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/repositories_controller.rb11
-rw-r--r--app/views/repositories/_link_to_functions.html.erb6
-rw-r--r--config/routes.rb26
-rw-r--r--lib/redmine.rb2
-rw-r--r--test/functional/repositories_filesystem_controller_test.rb3
-rw-r--r--test/functional/repositories_subversion_controller_test.rb5
-rw-r--r--test/integration/routing/repositories_test.rb16
7 files changed, 35 insertions, 34 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 1fb708355..d74b59b60 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -152,7 +152,15 @@ class RepositoriesController < ApplicationController
end
end
+ def raw
+ entry_and_raw(true)
+ end
+
def entry
+ entry_and_raw(false)
+ end
+
+ def entry_and_raw(is_raw)
@entry = @repository.entry(@path, @rev)
(show_error_not_found; return) unless @entry
@@ -161,7 +169,7 @@ class RepositoriesController < ApplicationController
@content = @repository.cat(@path, @rev)
(show_error_not_found; return) unless @content
- if 'raw' == params[:format] ||
+ if is_raw ||
(@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
! is_entry_text_data?(@content, @path)
# Force the download
@@ -177,6 +185,7 @@ class RepositoriesController < ApplicationController
@changeset = @repository.find_changeset_by_name(@rev)
end
end
+ private :entry_and_raw
def is_entry_text_data?(ent, path)
# UTF-16 contains "\x00".
diff --git a/app/views/repositories/_link_to_functions.html.erb b/app/views/repositories/_link_to_functions.html.erb
index aed88ebb7..f75a7ce5f 100644
--- a/app/views/repositories/_link_to_functions.html.erb
+++ b/app/views/repositories/_link_to_functions.html.erb
@@ -8,7 +8,11 @@
<% if @repository.supports_annotate? %>
<%= link_to_if action_name != 'annotate', l(:button_annotate), {:action => 'annotate', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> |
<% end %>
-<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %>
+<%= link_to(l(:button_download),
+ {:action => 'raw', :id => @project,
+ :repository_id => @repository.identifier_param,
+ :path => to_path_param(@path),
+ :rev => @rev}) if @repository.supports_cat? %>
<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
</p>
diff --git a/config/routes.rb b/config/routes.rb
index 22c61acb8..384f6b938 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -222,16 +222,10 @@ RedmineApp::Application.routes.draw do
post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
- get 'projects/:id/repository/:repository_id/revisions/:rev/:format(/*path(.:ext))',
- :to => 'repositories#entry',
- :constraints => {
- :format => 'raw',
- :rev => /[a-z0-9\.\-_]+/
- }
get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
:controller => 'repositories',
:constraints => {
- :action => /(browse|show|entry|annotate|diff)/,
+ :action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/
}
@@ -246,24 +240,20 @@ RedmineApp::Application.routes.draw do
get 'projects/:id/repository/revision', :to => 'repositories#revision'
post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
- get 'projects/:id/repository/revisions/:rev/:format(/*path(.:ext))',
- :to => 'repositories#entry',
- :constraints => {
- :format => 'raw',
- :rev => /[a-z0-9\.\-_]+/
- }
get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))',
:controller => 'repositories',
:constraints => {
- :action => /(browse|show|entry|annotate|diff)/,
+ :action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/
}
- get 'projects/:id/repository/:repository_id/:format(/*path(.:ext))', :to => 'repositories#entry', :format => /raw/
- get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', :controller => 'repositories', :action => /(browse|show|entry|changes|annotate|diff)/
+ get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
+ :controller => 'repositories',
+ :action => /(browse|show|entry|raw|changes|annotate|diff)/
get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
- get 'projects/:id/repository/:format(/*path(.:ext))', :to => 'repositories#entry', :format => /raw/
- get 'projects/:id/repository/:action(/*path(.:ext))', :controller => 'repositories', :action => /(browse|show|entry|changes|annotate|diff)/
+ get 'projects/:id/repository/:action(/*path(.:ext))',
+ :controller => 'repositories',
+ :action => /(browse|show|entry|raw|changes|annotate|diff)/
get 'projects/:id/repository', :to => 'repositories#show', :path => nil
# additional routes for having the file name at the end of url
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 9cd025c69..6b74af731 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -125,7 +125,7 @@ Redmine::AccessControl.map do |map|
map.project_module :repository do |map|
map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member
- map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph]
+ map.permission :browse_repository, :repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph]
map.permission :view_changesets, :repositories => [:show, :revisions, :revision]
map.permission :commit_access, {}
map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]}
diff --git a/test/functional/repositories_filesystem_controller_test.rb b/test/functional/repositories_filesystem_controller_test.rb
index dc9b98041..d6a29ffbf 100644
--- a/test/functional/repositories_filesystem_controller_test.rb
+++ b/test/functional/repositories_filesystem_controller_test.rb
@@ -78,8 +78,7 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase
end
def test_entry_download_no_extension
- get :entry, :id => PRJ_ID, :path => repository_path_hash(['test'])[:param],
- :format => 'raw'
+ get :raw, :id => PRJ_ID, :path => repository_path_hash(['test'])[:param]
assert_response :success
assert_equal 'application/octet-stream', @response.content_type
end
diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb
index 188dd2fd8..a68501c31 100644
--- a/test/functional/repositories_subversion_controller_test.rb
+++ b/test/functional/repositories_subversion_controller_test.rb
@@ -216,9 +216,8 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
@repository.fetch_changesets
@project.reload
assert_equal NUM_REV, @repository.changesets.count
- get :entry, :id => PRJ_ID,
- :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param],
- :format => 'raw'
+ get :raw, :id => PRJ_ID,
+ :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
assert_response :success
assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
end
diff --git a/test/integration/routing/repositories_test.rb b/test/integration/routing/repositories_test.rb
index f02791b9f..17d391801 100644
--- a/test/integration/routing/repositories_test.rb
+++ b/test/integration/routing/repositories_test.rb
@@ -184,8 +184,8 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
assert_routing(
{ :method => 'get',
:path => "/projects/redmine/repository/revisions/2/raw/#{@path_hash[:path]}" },
- { :controller => 'repositories', :action => 'entry', :id => 'redmine',
- :path => @path_hash[:param], :rev => '2', :format => 'raw' }
+ { :controller => 'repositories', :action => 'raw', :id => 'redmine',
+ :path => @path_hash[:param], :rev => '2' }
)
assert_routing(
{ :method => 'get',
@@ -278,8 +278,8 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
assert_routing(
{ :method => 'get',
:path => "/projects/redmine/repository/foo/revisions/2/raw/#{@path_hash[:path]}" },
- { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo',
- :path => @path_hash[:param], :rev => '2', :format => 'raw' }
+ { :controller => 'repositories', :action => 'raw', :id => 'redmine', :repository_id => 'foo',
+ :path => @path_hash[:param], :rev => '2' }
)
assert_routing(
{ :method => 'get',
@@ -311,8 +311,8 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
assert_routing(
{ :method => 'get',
:path => "/projects/redmine/repository/raw/#{@path_hash[:path]}" },
- { :controller => 'repositories', :action => 'entry', :id => 'redmine',
- :path => @path_hash[:param], :format => 'raw' }
+ { :controller => 'repositories', :action => 'raw', :id => 'redmine',
+ :path => @path_hash[:param] }
)
assert_routing(
{ :method => 'get',
@@ -355,8 +355,8 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
assert_routing(
{ :method => 'get',
:path => "/projects/redmine/repository/foo/raw/#{@path_hash[:path]}" },
- { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo',
- :path => @path_hash[:param], :format => 'raw' }
+ { :controller => 'repositories', :action => 'raw', :id => 'redmine', :repository_id => 'foo',
+ :path => @path_hash[:param] }
)
assert_routing(
{ :method => 'get',