2012-03-02 23:20:17 -05:00
|
|
|
require 'cases/helper'
|
|
|
|
|
|
|
|
class ModelTest < ActiveModel::TestCase
|
|
|
|
include ActiveModel::Lint::Tests
|
|
|
|
|
|
|
|
class BasicModel
|
|
|
|
include ActiveModel::Model
|
|
|
|
attr_accessor :attr
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@model = BasicModel.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_initialize_with_params
|
|
|
|
object = BasicModel.new(:attr => "value")
|
|
|
|
assert_equal object.attr, "value"
|
|
|
|
end
|
2012-03-03 02:19:39 -05:00
|
|
|
|
|
|
|
def test_initialize_with_nil_or_empty_hash_params_does_not_explode
|
|
|
|
assert_nothing_raised do
|
|
|
|
BasicModel.new()
|
2013-01-12 14:31:33 -05:00
|
|
|
BasicModel.new nil
|
2012-03-03 02:19:39 -05:00
|
|
|
BasicModel.new({})
|
|
|
|
end
|
|
|
|
end
|
2013-01-12 14:31:33 -05:00
|
|
|
|
|
|
|
def test_persisted_is_always_false
|
|
|
|
object = BasicModel.new(:attr => "value")
|
|
|
|
assert object.persisted? == false
|
|
|
|
end
|
2012-03-02 23:20:17 -05:00
|
|
|
end
|