# 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
# 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"
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"
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
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
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