diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-07-26 17:41:47 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-07-26 17:41:47 +0000 |
commit | 87f284dcb6c54047948f39cf5ce58444eae73c1e (patch) | |
tree | ae8088be75660a852b08baaf50de4cf2d3b553a0 /test/unit/repository_test.rb | |
parent | 04f9a321b1205d6017c86030eebd6f8b3b93774a (diff) | |
download | redmine-87f284dcb6c54047948f39cf5ce58444eae73c1e.tar.gz redmine-87f284dcb6c54047948f39cf5ce58444eae73c1e.zip |
Repository Identifier should be frozen (#11109).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10081 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/repository_test.rb')
-rw-r--r-- | test/unit/repository_test.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb index f99711623..56663c165 100644 --- a/test/unit/repository_test.rb +++ b/test/unit/repository_test.rb @@ -105,6 +105,38 @@ class RepositoryTest < ActiveSupport::TestCase ) assert r.save end + + def test_identifier_should_not_be_frozen_for_a_new_repository + assert_equal false, Repository.new.identifier_frozen? + end + + def test_identifier_should_not_be_frozen_for_a_saved_repository_with_blank_identifier + Repository.update_all(["identifier = ''"], "id = 10") + + assert_equal false, Repository.find(10).identifier_frozen? + end + + def test_identifier_should_be_frozen_for_a_saved_repository_with_valid_identifier + Repository.update_all(["identifier = 'abc123'"], "id = 10") + + assert_equal true, Repository.find(10).identifier_frozen? + end + + def test_identifier_should_not_accept_change_if_frozen + r = Repository.new(:identifier => 'foo') + r.stubs(:identifier_frozen?).returns(true) + + r.identifier = 'bar' + assert_equal 'foo', r.identifier + end + + def test_identifier_should_accept_change_if_not_frozen + r = Repository.new(:identifier => 'foo') + r.stubs(:identifier_frozen?).returns(false) + + r.identifier = 'bar' + assert_equal 'bar', r.identifier + end def test_destroy repository = Repository.find(10) |