diff options
author | José Valim <jose.valim@gmail.com> | 2011-11-25 19:29:39 +0000 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-11-25 19:29:39 +0000 |
commit | 0a4035b12a6c59253cb60f9e3456513c6a6a9d33 (patch) | |
tree | 513faab640a046e21c4b254b25f1bd601590ba2d /railties/test/generators | |
parent | 2dab493867d35d27015e3ba00d20ee6d2337320e (diff) | |
download | rails-0a4035b12a6c59253cb60f9e3456513c6a6a9d33.tar.gz rails-0a4035b12a6c59253cb60f9e3456513c6a6a9d33.tar.bz2 rails-0a4035b12a6c59253cb60f9e3456513c6a6a9d33.zip |
Revert the serializers API as other alternatives are now also under discussion
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 9 | ||||
-rw-r--r-- | railties/test/generators/serializer_generator_test.rb | 63 |
2 files changed, 0 insertions, 72 deletions
diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index 2e8b03fbef..2db8090621 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -264,15 +264,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase assert_file "app/assets/stylesheets/posts.css" end - def test_scaffold_also_generators_serializer - run_generator [ "posts", "name:string", "author:references", "--serializer" ] - assert_file "app/serializers/post_serializer.rb" do |serializer| - assert_match /class PostSerializer < ActiveModel::Serializer/, serializer - assert_match /^ attributes :name$/, serializer - assert_match /^ has_one :author$/, serializer - end - end - def test_scaffold_generator_outputs_error_message_on_missing_attribute_type run_generator ["post", "title", "body:text", "author"] diff --git a/railties/test/generators/serializer_generator_test.rb b/railties/test/generators/serializer_generator_test.rb deleted file mode 100644 index 2afaa65693..0000000000 --- a/railties/test/generators/serializer_generator_test.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'generators/generators_test_helper' -require 'rails/generators/rails/serializer/serializer_generator' - -class SerializerGeneratorTest < Rails::Generators::TestCase - include GeneratorsTestHelper - arguments %w(account name:string description:text business:references) - - def test_generates_a_serializer - run_generator - assert_file "app/serializers/account_serializer.rb", /class AccountSerializer < ActiveModel::Serializer/ - end - - def test_generates_a_namespaced_serializer - run_generator ["admin/account"] - assert_file "app/serializers/admin/account_serializer.rb", /class Admin::AccountSerializer < ActiveModel::Serializer/ - end - - def test_uses_application_serializer_if_one_exists - Object.const_set(:ApplicationSerializer, Class.new) - run_generator - assert_file "app/serializers/account_serializer.rb", /class AccountSerializer < ApplicationSerializer/ - ensure - Object.send :remove_const, :ApplicationSerializer - end - - def test_uses_namespace_application_serializer_if_one_exists - Object.const_set(:SerializerNamespace, Module.new) - SerializerNamespace.const_set(:ApplicationSerializer, Class.new) - Rails::Generators.namespace = SerializerNamespace - run_generator - assert_file "app/serializers/serializer_namespace/account_serializer.rb", - /module SerializerNamespace\n class AccountSerializer < ApplicationSerializer/ - ensure - Object.send :remove_const, :SerializerNamespace - Rails::Generators.namespace = nil - end - - def test_uses_given_parent - Object.const_set(:ApplicationSerializer, Class.new) - run_generator ["Account", "--parent=MySerializer"] - assert_file "app/serializers/account_serializer.rb", /class AccountSerializer < MySerializer/ - ensure - Object.send :remove_const, :ApplicationSerializer - end - - def test_generates_attributes_and_associations - run_generator - assert_file "app/serializers/account_serializer.rb" do |serializer| - assert_match(/^ attributes :name, :description$/, serializer) - assert_match(/^ has_one :business$/, serializer) - end - end - - def test_with_no_attributes_does_not_add_extra_space - run_generator ["account"] - assert_file "app/serializers/account_serializer.rb", /class AccountSerializer < ActiveModel::Serializer\nend/ - end - - def test_invokes_default_test_framework - run_generator - assert_file "test/unit/account_serializer_test.rb", /class AccountSerializerTest < ActiveSupport::TestCase/ - end -end |