From 2dbc4ddbaeb00388068843a9aecf00356b11abf7 Mon Sep 17 00:00:00 2001 From: mhuggins Date: Tue, 3 Nov 2015 13:36:59 -0700 Subject: [PATCH 1/4] Fix `#as_json` glitch caused by JSON and Rails --- lib/active_model/serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index 73b6ba426..444e1c70f 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -338,7 +338,7 @@ def to_json(*args) # object including the root. def as_json(options={}) options ||= {} - if root = options.fetch(:root, @options.fetch(:root, root_name)) + if root = options.to_hash.fetch(:root, @options.fetch(:root, root_name)) @options[:hash] = hash = {} @options[:unique_values] = {} From 0045719665d8736202b6b5cba6802b7825994dca Mon Sep 17 00:00:00 2001 From: mhuggins Date: Thu, 5 Nov 2015 23:03:31 -0700 Subject: [PATCH 2/4] Fix failing tests --- test/serialization_test.rb | 2 +- test/serializer_test.rb | 2 ++ test/test_fakes.rb | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/serialization_test.rb b/test/serialization_test.rb index a92858209..121e7fd84 100644 --- a/test/serialization_test.rb +++ b/test/serialization_test.rb @@ -242,7 +242,7 @@ def test_render_json_with_status def test_render_json_with_callback get :render_json_hello_world_with_callback - assert_equal 'alert({"hello":"world"})', @response.body + assert_equal '/**/alert({"hello":"world"})', @response.body # For JSONP, Rails 3 uses application/json, but Rails 4 uses text/javascript assert_match %r(application/json|text/javascript), @response.content_type.to_s end diff --git a/test/serializer_test.rb b/test/serializer_test.rb index 2ef49a87d..27de686bb 100644 --- a/test/serializer_test.rb +++ b/test/serializer_test.rb @@ -1363,6 +1363,7 @@ def name def test_inheritance_does_not_used_cached_attributes parent = Class.new(ActiveModel::Serializer) do attributes :title + alias :read_attribute_for_serialization :send end child = Class.new(parent) do @@ -1371,6 +1372,7 @@ def test_inheritance_does_not_used_cached_attributes data_class = Class.new do attr_accessor :title, :body + alias :read_attribute_for_serialization :send end item = data_class.new diff --git a/test/test_fakes.rb b/test/test_fakes.rb index dd2039e98..98228ef88 100644 --- a/test/test_fakes.rb +++ b/test/test_fakes.rb @@ -199,6 +199,7 @@ class SomeSerializer < ActiveModel::Serializer end class SomeObject < Struct.new(:some) + alias :read_attribute_for_serialization :send end # Set up some classes for polymorphic testing From 942d37714328d39c5a034c7376aa482f6656d1c3 Mon Sep 17 00:00:00 2001 From: mhuggins Date: Mon, 14 Dec 2015 09:23:58 -0700 Subject: [PATCH 3/4] Remove Ruby 1.8 and 1.9.2 support --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index d96b3eed5..b4b8d0099 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,7 @@ language: ruby rvm: - - 1.8.7 - - 1.9.2 - 1.9.3 - 2.0.0 - - ree - - jruby-18mode - jruby-19mode - rbx-2 gemfile: @@ -14,15 +10,3 @@ gemfile: matrix: allow_failures: - gemfile: Gemfile.edge - exclude: - # Edge Rails is only compatible with 1.9.3 - - gemfile: Gemfile.edge - rvm: 1.8.7 - - gemfile: Gemfile.edge - rvm: 1.9.2 - - gemfile: Gemfile.edge - rvm: ree - - gemfile: Gemfile.edge - rvm: jruby-18mode - - gemfile: Gemfile.edge - rvm: rbx-18mode From 4ab6697989b5184f800b7de1007cc5d7e6e5728d Mon Sep 17 00:00:00 2001 From: mhuggins Date: Mon, 14 Dec 2015 11:34:58 -0700 Subject: [PATCH 4/4] Add appveyor.yml --- Rakefile | 3 +++ appveyor.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 appveyor.yml diff --git a/Rakefile b/Rakefile index 23f17c4ae..c9dc801b0 100644 --- a/Rakefile +++ b/Rakefile @@ -16,3 +16,6 @@ task :bench do end task :default => :test + +desc 'CI test task' +task :ci => :default diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..6190feab6 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,29 @@ +version: '{build}' + +skip_tags: true + +environment: + matrix: + - ruby_version: "193" + - ruby_version: "193-x64" + - ruby_version: "200" + - ruby_version: "200-x64" + - ruby_version: "21" + - ruby_version: "21-x64" + +cache: + - vendor/bundle + +install: + - SET PATH=C:\Ruby%ruby_version%\bin;%PATH% + - ruby --version + - gem --version + - gem install bundler + - bundler --version + - bundle platform + - bundle install --path=vendor/bundle --retry=3 --jobs=3 + +test_script: + - bundle exec rake ci + +build: off