improved messages fixtures. Additional user fixture (for sending messages between...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Wed, 4 Jun 2008 06:48:49 +0000 (06:48 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Wed, 4 Jun 2008 06:48:49 +0000 (06:48 +0000)
test/fixtures/messages.yml
test/fixtures/users.yml
test/unit/message_test.rb
test/unit/user_test.rb

index b49c4eb4e1e9d522e9424c822ce1ce80662e94cc..d66ebd6f030c363c630eec5e42746248c38d113c 100644 (file)
@@ -1,5 +1,12 @@
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 one:
   id: 1
+  from_user_id: users(:normal_user).id
+  title: test message 1
+  body: some body text
+  sent_on: "2008-05-01 12:34:56"
+  message_read: false
+  to_user_id: users(:second_user).id
+  
 two:
   id: 2
index bcce2f7db5b9732ad1ff59109917c83060427711..be8bf4c554e62ef59940bb34e8ead8f3cacce12a 100644 (file)
@@ -11,3 +11,16 @@ normal_user:
   home_lat: 1
   home_lon: 1
   home_zoom: 3
+  
+second_user:
+  email:test@example.com
+  id: 2
+  active: 1
+  pass_crypt: <%= Digest::MD5.hexdigest('test') %>
+  creation_time: "2008-05-01 01:23:45"
+  display_name: test2
+  data_public: 1
+  description: some test description
+  home_lat: 12
+  home_lon: 12
+  home_zoom: 12
index 8804fe003b6c54f794acfa8f56aaec792d44b08b..681280d9f10ed53366d4d3798b875ffd4b00db6e 100644 (file)
@@ -3,8 +3,13 @@ require File.dirname(__FILE__) + '/../test_helper'
 class MessageTest < Test::Unit::TestCase
   fixtures :messages
 
-  # Replace this with your real tests.
-  def test_truth
-    assert true
+  def test_check_empty_message_fails
+    message = Message.new
+    assert !message.valid?
+    assert message.errors.invalid?(:title)
+    assert message.errors.invalid?(:body)
+    assert message.errors.invalid?(:sent_on)
+    assert true, message.message_read
   end
+  
 end
index 5f4c9525fec14cd7b19d8681a296f6bad46a6aa1..ab957dc8b8bcbf03b268c35fb02c7acad4a1a8b9 100644 (file)
@@ -2,11 +2,6 @@ require File.dirname(__FILE__) + '/../test_helper'
 
 class UserTest < Test::Unit::TestCase
   fixtures :users
-
-  # Replace this with your real tests.
-  def test_truth
-    assert true
-  end
   
   def test_invalid_with_empty_attributes
     user = User.new