]> source.dussan.org Git - redmine.git/commitdiff
Replaced a custom test with a shoulda macro.
authorEric Davis <edavis@littlestreamsoftware.com>
Mon, 19 Oct 2009 00:27:08 +0000 (00:27 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Mon, 19 Oct 2009 00:27:08 +0000 (00:27 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2935 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/project_test.rb

index 2ace065ab0207fd5fede572a45fcbc3d762ef30b..6f985cb13b6d11b2c6d8a3fa0eb9292e2ec43502 100644 (file)
@@ -28,6 +28,12 @@ class ProjectTest < ActiveSupport::TestCase
     @ecookbook_sub1 = Project.find(3)
   end
   
+  should_validate_presence_of :name
+  should_validate_presence_of :identifier
+
+  should_validate_uniqueness_of :name
+  should_validate_uniqueness_of :identifier
+
   def test_truth
     assert_kind_of Project, @ecookbook
     assert_equal "eCookbook", @ecookbook.name
@@ -41,13 +47,6 @@ class ProjectTest < ActiveSupport::TestCase
     assert_equal "eCook", @ecookbook.name
   end
   
-  def test_validate
-    @ecookbook.name = ""
-    assert !@ecookbook.save
-    assert_equal 1, @ecookbook.errors.count
-    assert_equal I18n.translate('activerecord.errors.messages.blank'), @ecookbook.errors.on(:name)
-  end
-  
   def test_validate_identifier
     to_test = {"abc" => true,
                "ab12" => true,
@@ -62,7 +61,7 @@ class ProjectTest < ActiveSupport::TestCase
       assert_equal valid, p.errors.on('identifier').nil?
     end
   end
-  
+
   def test_members_should_be_active_users
     Project.all.each do |project|
       assert_nil project.members.detect {|m| !(m.user.is_a?(User) && m.user.active?) }