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.

This commit is contained in:
Shaun McDonald 2008-06-04 16:35:00 +00:00
parent f58fb85e03
commit 98e11d164f
4 changed files with 31 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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