summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/helpers/repositories_helper.rb16
-rw-r--r--app/models/repository.rb4
-rw-r--r--app/models/repository/cvs.rb3
-rw-r--r--test/functional/repositories_controller_test.rb4
4 files changed, 15 insertions, 12 deletions
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb
index ccc606642..66c63fa90 100644
--- a/app/helpers/repositories_helper.rb
+++ b/app/helpers/repositories_helper.rb
@@ -159,7 +159,7 @@ module RepositoriesHelper
def subversion_field_tags(form, repository)
content_tag('p', form.text_field(:url, :size => 60, :required => true,
- :disabled => (repository && !repository.root_url.blank?)) +
+ :disabled => !repository.safe_attribute?('url')) +
'<br />'.html_safe +
'(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
content_tag('p', form.text_field(:login, :size => 30)) +
@@ -174,7 +174,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository),
:size => 60, :required => true,
- :disabled => (repository && !repository.new_record?))) +
+ :disabled => !repository.safe_attribute?('url'))) +
content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true))
@@ -184,7 +184,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository),
:size => 60, :required => true,
- :disabled => (repository && !repository.root_url.blank?)
+ :disabled => !repository.safe_attribute?('url')
) +
'<br />'.html_safe + l(:text_mercurial_repository_note)) +
content_tag('p', form.select(
@@ -198,7 +198,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository),
:size => 60, :required => true,
- :disabled => (repository && !repository.root_url.blank?)
+ :disabled => !repository.safe_attribute?('url')
) +
'<br />'.html_safe +
l(:text_git_repository_note)) +
@@ -218,12 +218,12 @@ module RepositoriesHelper
:root_url,
:label => l(:field_cvsroot),
:size => 60, :required => true,
- :disabled => !repository.new_record?)) +
+ :disabled => !repository.safe_attribute?('root_url'))) +
content_tag('p', form.text_field(
:url,
:label => l(:field_cvs_module),
:size => 30, :required => true,
- :disabled => !repository.new_record?)) +
+ :disabled => !repository.safe_attribute?('url'))) +
content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true)) +
@@ -238,7 +238,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_path_to_repository),
:size => 60, :required => true,
- :disabled => (repository && !repository.new_record?))) +
+ :disabled => !repository.safe_attribute?('url'))) +
content_tag('p', form.select(
:log_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_commit_logs_encoding), :required => true))
@@ -248,7 +248,7 @@ module RepositoriesHelper
content_tag('p', form.text_field(
:url, :label => l(:field_root_directory),
:size => 60, :required => true,
- :disabled => (repository && !repository.root_url.blank?))) +
+ :disabled => !repository.safe_attribute?('url'))) +
content_tag('p', form.select(
:path_encoding, [nil] + Setting::ENCODINGS,
:label => l(:field_scm_path_encoding)
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 8f2cd5c67..c81979a26 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -44,13 +44,15 @@ class Repository < ActiveRecord::Base
validate :repo_create_validation, :on => :create
safe_attributes 'identifier',
- 'url',
'login',
'password',
'path_encoding',
'log_encoding',
'is_default'
+ safe_attributes 'url',
+ :if => lambda {|repository, user| repository.new_record?}
+
def repo_create_validation
unless Setting.enabled_scm.include?(self.class.name.demodulize)
errors.add(:type, :invalid)
diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb
index f43a15620..3cf5b7036 100644
--- a/app/models/repository/cvs.rb
+++ b/app/models/repository/cvs.rb
@@ -21,7 +21,8 @@ require 'digest/sha1'
class Repository::Cvs < Repository
validates_presence_of :url, :root_url, :log_encoding
- safe_attributes 'root_url'
+ safe_attributes 'root_url',
+ :if => lambda {|repository, user| repository.new_record?}
def self.human_attribute_name(attribute_key_name, *args)
attr_name = attribute_key_name.to_s
diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb
index bb6c19d3d..213a1f81a 100644
--- a/test/functional/repositories_controller_test.rb
+++ b/test/functional/repositories_controller_test.rb
@@ -40,7 +40,7 @@ class RepositoriesControllerTest < ActionController::TestCase
assert_template 'new'
assert_kind_of Repository::Subversion, assigns(:repository)
assert assigns(:repository).new_record?
- assert_tag 'input', :attributes => {:name => 'repository[url]'}
+ assert_tag 'input', :attributes => {:name => 'repository[url]', :disabled => nil}
end
def test_new_should_propose_enabled_scm_only
@@ -91,7 +91,7 @@ class RepositoriesControllerTest < ActionController::TestCase
assert_response :success
assert_template 'edit'
assert_equal Repository.find(11), assigns(:repository)
- assert_tag 'input', :attributes => {:name => 'repository[url]', :value => 'svn://localhost/test'}
+ assert_tag 'input', :attributes => {:name => 'repository[url]', :value => 'svn://localhost/test', :disabled => 'disabled'}
end
def test_update