2008-01-05 08:32:06 -05:00
|
|
|
require 'abstract_unit'
|
2010-10-01 21:09:37 -04:00
|
|
|
require 'controller/fake_models'
|
2007-04-29 21:17:56 -04:00
|
|
|
|
|
|
|
class RecordIdentifierTest < Test::Unit::TestCase
|
|
|
|
include ActionController::RecordIdentifier
|
|
|
|
|
|
|
|
def setup
|
2007-05-14 13:30:35 -04:00
|
|
|
@klass = Comment
|
2007-04-29 21:17:56 -04:00
|
|
|
@record = @klass.new
|
2007-05-14 13:30:35 -04:00
|
|
|
@singular = 'comment'
|
|
|
|
@plural = 'comments'
|
2010-06-19 17:35:54 -04:00
|
|
|
@uncountable = Sheep
|
2007-04-29 21:17:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_dom_id_with_new_record
|
|
|
|
assert_equal "new_#{@singular}", dom_id(@record)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_dom_id_with_new_record_and_prefix
|
|
|
|
assert_equal "custom_prefix_#{@singular}", dom_id(@record, :custom_prefix)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_dom_id_with_saved_record
|
|
|
|
@record.save
|
|
|
|
assert_equal "#{@singular}_1", dom_id(@record)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_dom_id_with_prefix
|
|
|
|
@record.save
|
|
|
|
assert_equal "edit_#{@singular}_1", dom_id(@record, :edit)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_dom_class
|
|
|
|
assert_equal @singular, dom_class(@record)
|
|
|
|
end
|
2010-06-19 17:35:54 -04:00
|
|
|
|
2007-04-29 21:17:56 -04:00
|
|
|
def test_dom_class_with_prefix
|
|
|
|
assert_equal "custom_prefix_#{@singular}", dom_class(@record, :custom_prefix)
|
|
|
|
end
|
|
|
|
end
|