Created
October 24, 2016 10:56
-
-
Save groyoh/5d7f5dc71f4463139bc395731977a370 to your computer and use it in GitHub Desktop.
AMS #1944
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| require 'bundler/inline' | |
| rescue LoadError => e | |
| $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
| raise e | |
| end | |
| gemfile(true) do | |
| source 'https://rubygems.org' | |
| gem 'active_model_serializers', '0.10.2' | |
| gem 'minitest' | |
| end | |
| class FullUserSerializer < ActiveModel::Serializer | |
| attributes :email, :name | |
| end | |
| class UserSerializer < ActiveModel::Serializer | |
| attributes :name | |
| end | |
| class User < ActiveModelSerializers::Model | |
| attr_accessor :email, :name | |
| end | |
| require 'minitest/autorun' | |
| # Ensure backward compatibility with Minitest 4 | |
| Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
| class BugTest < Minitest::Test | |
| def test_ams | |
| u = User.new(email: '[email protected]', name: "test") | |
| hash = ActiveModelSerializers::SerializableResource.new(u, serializer: UserSerializer).as_json | |
| expected = {:name=>"test"} | |
| assert_equal(expected, hash) | |
| hash = ActiveModelSerializers::SerializableResource.new(u, serializer: FullUserSerializer).as_json | |
| expected = {:email=>"[email protected]", :name=>"test"} | |
| assert_equal(expected, hash) | |
| end | |
| end | |
| __END__ | |
| Fetching gem metadata from https://rubygems.org/............. | |
| Fetching version metadata from https://rubygems.org/. | |
| Resolving dependencies... | |
| Using rake 11.3.0 | |
| Using concurrent-ruby 1.0.2 | |
| Using i18n 0.7.0 | |
| Using minitest 5.9.1 | |
| Using thread_safe 0.3.5 | |
| Using builder 3.2.2 | |
| Using erubis 2.7.0 | |
| Using mini_portile2 2.1.0 | |
| Using rack 2.0.1 | |
| Using jsonapi-parser 0.1.1.beta2 | |
| Using jsonapi-renderer 0.1.1.beta1 | |
| Using method_source 0.8.2 | |
| Using thor 0.19.1 | |
| Using bundler 1.13.6 | |
| Using tzinfo 1.2.2 | |
| Using nokogiri 1.6.8.1 | |
| Using rack-test 0.6.3 | |
| Using jsonapi 0.1.1.beta5 | |
| Using activesupport 5.0.0.1 | |
| Using loofah 2.0.3 | |
| Using rails-dom-testing 2.0.1 | |
| Using activemodel 5.0.0.1 | |
| Using rails-html-sanitizer 1.0.3 | |
| Using actionview 5.0.0.1 | |
| Using actionpack 5.0.0.1 | |
| Using railties 5.0.0.1 | |
| Using active_model_serializers 0.10.2 | |
| Run options: --seed 27606 | |
| # Running: | |
| [active_model_serializers] Rendered UserSerializer with ActiveModelSerializers::Adapter::Attributes (0.11ms) | |
| [active_model_serializers] Rendered FullUserSerializer with ActiveModelSerializers::Adapter::Attributes (0.04ms) | |
| . | |
| Finished in 0.010447s, 95.7186 runs/s, 191.4372 assertions/s. | |
| 1 runs, 2 assertions, 0 failures, 0 errors, 0 skips |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment