diff options
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) |