]> git.openstreetmap.org Git - rails.git/commitdiff
Removing id's so that the ids are generated, and it makes it easier to deal with...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Wed, 4 Jun 2008 16:35:00 +0000 (16:35 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Wed, 4 Jun 2008 16:35:00 +0000 (16:35 +0000)
test/fixtures/messages.yml
test/fixtures/users.yml
test/unit/message_test.rb
test/unit/user_test.rb

index d66ebd6f030c363c630eec5e42746248c38d113c..feab6536ef91ea83ea57db374571630224fd8448 100644 (file)
@@ -1,12 +1,16 @@
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 one:
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 one:
-  id: 1
-  from_user_id: users(:normal_user).id
+  sender: normal_user
   title: test message 1
   body: some body text
   sent_on: "2008-05-01 12:34:56"
   message_read: false
   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
+  recipient: second_user
   
 two:
   
 two:
-  id: 2
+  sender: second_user
+  title: test message 2
+  body: some body test
+  sent_on: "2008-05-02 12:45:23"
+  message_read: true
+  recipient: normal_user
index be8bf4c554e62ef59940bb34e8ead8f3cacce12a..89522ef7c457f3860d5bf01e7c485bbb0fcc082a 100644 (file)
@@ -1,7 +1,6 @@
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 normal_user:
   email: test@openstreetmap.org
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 normal_user:
   email: test@openstreetmap.org
-  id: 1
   active: 1
   pass_crypt: <%= Digest::MD5.hexdigest('test') %>
   creation_time: "2007-01-01 00:00:00"
   active: 1
   pass_crypt: <%= Digest::MD5.hexdigest('test') %>
   creation_time: "2007-01-01 00:00:00"
@@ -13,8 +12,7 @@ normal_user:
   home_zoom: 3
   
 second_user:
   home_zoom: 3
   
 second_user:
-  email:test@example.com
-  id: 2
+  email: test@example.com
   active: 1
   pass_crypt: <%= Digest::MD5.hexdigest('test') %>
   creation_time: "2008-05-01 01:23:45"
   active: 1
   pass_crypt: <%= Digest::MD5.hexdigest('test') %>
   creation_time: "2008-05-01 01:23:45"
@@ -24,3 +22,14 @@ second_user:
   home_lat: 12
   home_lon: 12
   home_zoom: 12
   home_lat: 12
   home_lon: 12
   home_zoom: 12
+  
+inactive_user:
+  email: inactive@openstreetmap.org
+  active: 0
+  pass_crypt: <%= Digest::MD5::hexdigest('test2') %>
+  display_name: Inactive User
+  data_public: 1
+  description: description
+  home_lat: 12.34
+  home_lon: 12.34
+  home_zoom: 15
index 681280d9f10ed53366d4d3798b875ffd4b00db6e..b56972704e4a024349713a9404b6bb0da6ecab17 100644 (file)
@@ -1,7 +1,7 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class MessageTest < Test::Unit::TestCase
 require File.dirname(__FILE__) + '/../test_helper'
 
 class MessageTest < Test::Unit::TestCase
-  fixtures :messages
+  fixtures :messages, :users
 
   def test_check_empty_message_fails
     message = Message.new
 
   def test_check_empty_message_fails
     message = Message.new
index ab957dc8b8bcbf03b268c35fb02c7acad4a1a8b9..76c32a88d87da26e80cdaf5666d2676e521cd505 100644 (file)
@@ -15,5 +15,14 @@ class UserTest < Test::Unit::TestCase
     assert !user.errors.invalid?(:home_zoom)
   end
   
     assert !user.errors.invalid?(:home_zoom)
   end
   
-  
+  def test_unique_email
+    new_user = User.new(:email => users(:normal_user).email,
+      :active => 1, 
+      :pass_crypt => Digest::MD5.hexdigest('test'),
+      :display_name => "new user",
+      :data_public => 1,
+      :description => "desc")
+    assert !new_user.save
+    assert_equal ActiveRecord::Errors.default_error_messages[:taken], new_user.errors.on(:email)
+  end
 end
 end