2010-02-21 07:47:37 +00:00
|
|
|
require 'cases/helper'
|
|
|
|
require 'models/contact'
|
|
|
|
|
|
|
|
class ConversionTest < ActiveModel::TestCase
|
|
|
|
test "to_model default implementation returns self" do
|
|
|
|
contact = Contact.new
|
|
|
|
assert_equal contact, contact.to_model
|
|
|
|
end
|
|
|
|
|
|
|
|
test "to_key default implementation returns nil for new records" do
|
|
|
|
assert_nil Contact.new.to_key
|
|
|
|
end
|
|
|
|
|
|
|
|
test "to_key default implementation returns the id in an array for persisted records" do
|
2010-02-21 10:09:21 +00:00
|
|
|
assert_equal [1], Contact.new(:id => 1).to_key
|
2010-02-21 07:47:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test "to_param default implementation returns nil for new records" do
|
|
|
|
assert_nil Contact.new.to_param
|
|
|
|
end
|
|
|
|
|
|
|
|
test "to_param default implementation returns a string of ids for persisted records" do
|
2010-02-21 10:09:21 +00:00
|
|
|
assert_equal "1", Contact.new(:id => 1).to_param
|
2010-02-21 07:47:37 +00:00
|
|
|
end
|
|
|
|
end
|