From 98e11d164f6ae471c88c6f468eb1e3fe1a5cd69f Mon Sep 17 00:00:00 2001 From: Shaun McDonald Date: Wed, 4 Jun 2008 16:35:00 +0000 Subject: [PATCH] Removing id's so that the ids are generated, and it makes it easier to deal with referential tests. Now have messages and users with basic tests. Using http://api.rubyonrails.com/classes/Fixtures.html. --- test/fixtures/messages.yml | 12 ++++++++---- test/fixtures/users.yml | 15 ++++++++++++--- test/unit/message_test.rb | 2 +- test/unit/user_test.rb | 11 ++++++++++- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml index d66ebd6f0..feab6536e 100644 --- a/test/fixtures/messages.yml +++ b/test/fixtures/messages.yml @@ -1,12 +1,16 @@ # 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 - to_user_id: users(:second_user).id + recipient: second_user 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 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index be8bf4c55..89522ef7c 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,7 +1,6 @@ # 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" @@ -13,8 +12,7 @@ normal_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" @@ -24,3 +22,14 @@ second_user: 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 diff --git a/test/unit/message_test.rb b/test/unit/message_test.rb index 681280d9f..b56972704 100644 --- a/test/unit/message_test.rb +++ b/test/unit/message_test.rb @@ -1,7 +1,7 @@ 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 diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index ab957dc8b..76c32a88d 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -15,5 +15,14 @@ class UserTest < Test::Unit::TestCase 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 -- 2.43.2