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:
parent
f58fb85e03
commit
98e11d164f
4 changed files with 31 additions and 9 deletions
12
test/fixtures/messages.yml
vendored
12
test/fixtures/messages.yml
vendored
|
@ -1,12 +1,16 @@
|
||||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||||
one:
|
one:
|
||||||
id: 1
|
sender: normal_user
|
||||||
from_user_id: users(:normal_user).id
|
|
||||||
title: test message 1
|
title: test message 1
|
||||||
body: some body text
|
body: some body text
|
||||||
sent_on: "2008-05-01 12:34:56"
|
sent_on: "2008-05-01 12:34:56"
|
||||||
message_read: false
|
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
|
||||||
|
|
15
test/fixtures/users.yml
vendored
15
test/fixtures/users.yml
vendored
|
@ -1,7 +1,6 @@
|
||||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||||
normal_user:
|
normal_user:
|
||||||
email: test@openstreetmap.org
|
email: test@openstreetmap.org
|
||||||
id: 1
|
|
||||||
active: 1
|
active: 1
|
||||||
pass_crypt: <%= Digest::MD5.hexdigest('test') %>
|
pass_crypt: <%= Digest::MD5.hexdigest('test') %>
|
||||||
creation_time: "2007-01-01 00:00:00"
|
creation_time: "2007-01-01 00:00:00"
|
||||||
|
@ -13,8 +12,7 @@ normal_user:
|
||||||
home_zoom: 3
|
home_zoom: 3
|
||||||
|
|
||||||
second_user:
|
second_user:
|
||||||
email:test@example.com
|
email: test@example.com
|
||||||
id: 2
|
|
||||||
active: 1
|
active: 1
|
||||||
pass_crypt: <%= Digest::MD5.hexdigest('test') %>
|
pass_crypt: <%= Digest::MD5.hexdigest('test') %>
|
||||||
creation_time: "2008-05-01 01:23:45"
|
creation_time: "2008-05-01 01:23:45"
|
||||||
|
@ -24,3 +22,14 @@ second_user:
|
||||||
home_lat: 12
|
home_lat: 12
|
||||||
home_lon: 12
|
home_lon: 12
|
||||||
home_zoom: 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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class MessageTest < Test::Unit::TestCase
|
class MessageTest < Test::Unit::TestCase
|
||||||
fixtures :messages
|
fixtures :messages, :users
|
||||||
|
|
||||||
def test_check_empty_message_fails
|
def test_check_empty_message_fails
|
||||||
message = Message.new
|
message = Message.new
|
||||||
|
|
|
@ -15,5 +15,14 @@ class UserTest < Test::Unit::TestCase
|
||||||
assert !user.errors.invalid?(:home_zoom)
|
assert !user.errors.invalid?(:home_zoom)
|
||||||
end
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue