aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-06-09 14:20:31 +0200
committerPiotr Sarnacki <drogus@gmail.com>2012-08-28 10:51:03 +0200
commit264624049ea02a76a84e88023f611820bfdde9eb (patch)
tree9a335e0111164fab6bed1dc0d1816c1590115157 /actionpack/test/template
parent7185e35971f4a18f48a7d67e5c86c2fcf87bdb66 (diff)
downloadrails-264624049ea02a76a84e88023f611820bfdde9eb.tar.gz
rails-264624049ea02a76a84e88023f611820bfdde9eb.tar.bz2
rails-264624049ea02a76a84e88023f611820bfdde9eb.zip
Move ActionController::RecordIdentifier to ActionView
Since it's more about DOM classes and ids it belongs to Action View better. What's more, it's more convenient to make it part of Action View to follow the rule that Action Pack can depend on Action View, but not the other way round.
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/record_identifier_test.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/actionpack/test/template/record_identifier_test.rb b/actionpack/test/template/record_identifier_test.rb
new file mode 100644
index 0000000000..a7f1420059
--- /dev/null
+++ b/actionpack/test/template/record_identifier_test.rb
@@ -0,0 +1,40 @@
+require 'abstract_unit'
+require 'controller/fake_models'
+
+class RecordIdentifierTest < ActiveSupport::TestCase
+ include ActionView::RecordIdentifier
+
+ def setup
+ @klass = Comment
+ @record = @klass.new
+ @singular = 'comment'
+ @plural = 'comments'
+ @uncountable = Sheep
+ 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
+
+ def test_dom_class_with_prefix
+ assert_equal "custom_prefix_#{@singular}", dom_class(@record, :custom_prefix)
+ end
+end