From 290bd1756d5f62631f54a8653e16a6da5a054857 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 25 May 2008 11:33:04 +0000 Subject: [PATCH] Merged r1442, r1443 and r1446 to r1449 from trunk. git-svn-id: http://redmine.rubyforge.org/svn/branches/0.7-stable@1450 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/users_helper.rb | 2 +- app/models/change.rb | 4 +++ app/models/repository.rb | 5 ++++ app/models/repository/subversion.rb | 15 +++++++++++ app/models/user.rb | 3 +-- app/views/repositories/revision.rhtml | 2 +- app/views/users/_form.rhtml | 2 +- public/javascripts/application.js | 2 +- public/stylesheets/application.css | 2 +- test/fixtures/changes.yml | 7 +++++ ...repositories_subversion_controller_test.rb | 26 +++++++++++++++++++ 11 files changed, 63 insertions(+), 7 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 250ed8ce8..e1d70a8e1 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -30,7 +30,7 @@ module UsersHelper link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock' elsif user.registered? link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock' - else + elsif user != User.current link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock' end end diff --git a/app/models/change.rb b/app/models/change.rb index d14f435a4..385fe5acb 100644 --- a/app/models/change.rb +++ b/app/models/change.rb @@ -19,4 +19,8 @@ class Change < ActiveRecord::Base belongs_to :changeset validates_presence_of :changeset_id, :action, :path + + def relative_path + changeset.repository.relative_path(path) + end end diff --git a/app/models/repository.rb b/app/models/repository.rb index 8b1f8d0af..1ea77f24f 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -64,6 +64,11 @@ class Repository < ActiveRecord::Base :order => "committed_on DESC, #{Changeset.table_name}.id DESC").collect(&:changeset) end + # Returns a path relative to the url of the repository + def relative_path(path) + path + end + def latest_changeset @latest_changeset ||= changesets.find(:first) end diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb index 0c2239c43..3981d6f4c 100644 --- a/app/models/repository/subversion.rb +++ b/app/models/repository/subversion.rb @@ -35,6 +35,11 @@ class Repository::Subversion < Repository revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC") : [] end + # Returns a path relative to the url of the repository + def relative_path(path) + path.gsub(Regexp.new("^\/?#{Regexp.escape(relative_url)}"), '') + end + def fetch_changesets scm_info = scm.info if scm_info @@ -71,4 +76,14 @@ class Repository::Subversion < Repository end end end + + private + + # Returns the relative url of the repository + # Eg: root_url = file:///var/svn/foo + # url = file:///var/svn/foo/bar + # => returns /bar + def relative_url + @relative_url ||= url.gsub(Regexp.new("^#{Regexp.escape(root_url)}"), '') + end end diff --git a/app/models/user.rb b/app/models/user.rb index a67a08567..573261b77 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -258,13 +258,12 @@ class User < ActiveRecord::Base end def self.anonymous - return @anonymous_user if @anonymous_user anonymous_user = AnonymousUser.find(:first) if anonymous_user.nil? anonymous_user = AnonymousUser.create(:lastname => 'Anonymous', :firstname => '', :mail => '', :login => '', :status => 0) raise 'Unable to create the anonymous user.' if anonymous_user.new_record? end - @anonymous_user = anonymous_user + anonymous_user end private diff --git a/app/views/repositories/revision.rhtml b/app/views/repositories/revision.rhtml index f1e176669..2fdf58faf 100644 --- a/app/views/repositories/revision.rhtml +++ b/app/views/repositories/revision.rhtml @@ -49,7 +49,7 @@
<%= change.path %> <%= "(#{change.revision})" unless change.revision.blank? %> <% if change.action == "M" %> -<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => without_leading_slash(change.path), :rev => @changeset.revision %> +<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => without_leading_slash(change.relative_path), :rev => @changeset.revision %> <% end %> diff --git a/app/views/users/_form.rhtml b/app/views/users/_form.rhtml index ff4278c1f..65f35907d 100644 --- a/app/views/users/_form.rhtml +++ b/app/views/users/_form.rhtml @@ -13,7 +13,7 @@

<%= custom_field_tag_with_label @custom_value %>

<% end if @custom_values%> -

<%= f.check_box :admin %>

+

<%= f.check_box :admin, :disabled => (@user == User.current) %>

diff --git a/public/javascripts/application.js b/public/javascripts/application.js index f3d771a10..a8b6c0e46 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -56,7 +56,7 @@ function setPredecessorFieldsVisibility() { function promptToRemote(text, param, url) { value = prompt(text + ':'); if (value) { - new Ajax.Request(url + '?' + param + '=' + value, {asynchronous:true, evalScripts:true}); + new Ajax.Request(url + '?' + param + '=' + encodeURIComponent(value), {asynchronous:true, evalScripts:true}); return false; } } diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 8e4bf995c..fbbe0b2f7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -80,7 +80,7 @@ a.issue.closed, .issue.closed a { text-decoration: line-through; } /***** Tables *****/ table.list { border: 1px solid #e4e4e4; border-collapse: collapse; width: 100%; margin-bottom: 4px; } table.list th { background-color:#EEEEEE; padding: 4px; white-space:nowrap; } -table.list td { overflow: hidden; vertical-align: top;} +table.list td { vertical-align: top; } table.list td.id { width: 2%; text-align: center;} table.list td.checkbox { width: 15px; padding: 0px;} diff --git a/test/fixtures/changes.yml b/test/fixtures/changes.yml index 30acbd02d..56d936296 100644 --- a/test/fixtures/changes.yml +++ b/test/fixtures/changes.yml @@ -13,4 +13,11 @@ changes_002: path: /test/some/path/elsewhere/in/the/repo from_path: from_revision: +changes_003: + id: 3 + changeset_id: 101 + action: M + path: /test/some/path/in/the/repo + from_path: + from_revision: \ No newline at end of file diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb index dd56947fc..bc3f261a0 100644 --- a/test/functional/repositories_subversion_controller_test.rb +++ b/test/functional/repositories_subversion_controller_test.rb @@ -97,6 +97,32 @@ class RepositoriesSubversionControllerTest < Test::Unit::TestCase assert_equal 'folder', assigns(:entry).name end + def test_revision + get :revision, :id => 1, :rev => 2 + assert_response :success + assert_template 'revision' + assert_tag :tag => 'tr', + :child => { :tag => 'td', :content => %r{/test/some/path/in/the/repo} }, + :child => { :tag => 'td', + :child => { :tag => 'a', :attributes => { :href => '/repositories/diff/ecookbook/test/some/path/in/the/repo?rev=2' } } + } + end + + def test_revision_with_repository_pointing_to_a_subdirectory + r = Project.find(1).repository + # Changes repository url to a subdirectory + r.update_attribute :url, (r.url + '/test/some') + + get :revision, :id => 1, :rev => 2 + assert_response :success + assert_template 'revision' + assert_tag :tag => 'tr', + :child => { :tag => 'td', :content => %r{/test/some/path/in/the/repo} }, + :child => { :tag => 'td', + :child => { :tag => 'a', :attributes => { :href => '/repositories/diff/ecookbook/path/in/the/repo?rev=2' } } + } + end + def test_diff get :diff, :id => 1, :rev => 3 assert_response :success -- 2.39.5