mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
commit
7e2051a369
62
.travis.yml
62
.travis.yml
@ -1,28 +1,46 @@
|
|||||||
language: ruby
|
language: ruby
|
||||||
|
sudo: false
|
||||||
rvm:
|
rvm:
|
||||||
- 1.8.7
|
# - 1.8.7
|
||||||
- 1.9.2
|
# - ree
|
||||||
- 1.9.3
|
# - jruby-18mode
|
||||||
- 2.0.0
|
# - 1.9.2
|
||||||
- ree
|
# - 1.9.3
|
||||||
- jruby-18mode
|
|
||||||
- jruby-19mode
|
- jruby-19mode
|
||||||
|
- 2.0.0
|
||||||
|
- 2.1
|
||||||
|
- 2.2
|
||||||
- rbx-2
|
- rbx-2
|
||||||
gemfile:
|
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
|
||||||
- Gemfile
|
cache:
|
||||||
- Gemfile.edge
|
directories:
|
||||||
|
- vendor/bundle
|
||||||
|
script:
|
||||||
|
- bundle exec rake ci
|
||||||
|
env:
|
||||||
|
# - "RAILS_VERSION=3.0"
|
||||||
|
# - "RAILS_VERSION=3.1"
|
||||||
|
# - "RAILS_VERSION=3.2"
|
||||||
|
- "RAILS_VERSION=4.0"
|
||||||
|
- "RAILS_VERSION=4.1"
|
||||||
|
- "RAILS_VERSION=4.2"
|
||||||
|
- "RAILS_VERSION=master"
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
|
||||||
- gemfile: Gemfile.edge
|
|
||||||
exclude:
|
exclude:
|
||||||
# Edge Rails is only compatible with 1.9.3
|
# - rvm: 1.8.7
|
||||||
- gemfile: Gemfile.edge
|
# - ree
|
||||||
rvm: 1.8.7
|
# - jruby-18mode
|
||||||
- gemfile: Gemfile.edge
|
# - rvm: 1.9.2
|
||||||
rvm: 1.9.2
|
- rvm: 1.9.3
|
||||||
- gemfile: Gemfile.edge
|
env: RAILS_VERSION=master
|
||||||
rvm: ree
|
- rvm: jruby-19mode
|
||||||
- gemfile: Gemfile.edge
|
env: RAILS_VERSION=master
|
||||||
rvm: jruby-18mode
|
- rvm: 2.0.0
|
||||||
- gemfile: Gemfile.edge
|
env: RAILS_VERSION=master
|
||||||
rvm: rbx-18mode
|
- rvm: 2.1
|
||||||
|
env: RAILS_VERSION=master
|
||||||
|
- rvm: 2.2
|
||||||
|
env: RAILS_VERSION=master
|
||||||
|
- rvm: rbx-2
|
||||||
|
env: RAILS_VERSION=master
|
||||||
|
fast_finish: true
|
||||||
|
|||||||
29
Gemfile
29
Gemfile
@ -2,3 +2,32 @@ source 'https://rubygems.org'
|
|||||||
|
|
||||||
# Specify gem dependencies in active_model_serializers.gemspec
|
# Specify gem dependencies in active_model_serializers.gemspec
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
|
version = ENV['RAILS_VERSION'] || '4.0'
|
||||||
|
|
||||||
|
if version == 'master'
|
||||||
|
gem 'rack', github: 'rack/rack'
|
||||||
|
gem 'arel', github: 'rails/arel'
|
||||||
|
git 'https://github.com/rails/rails.git' do
|
||||||
|
gem 'railties'
|
||||||
|
gem 'activesupport'
|
||||||
|
gem 'activemodel'
|
||||||
|
gem 'actionpack'
|
||||||
|
gem 'activerecord', group: :test
|
||||||
|
# Rails 5
|
||||||
|
gem 'actionview'
|
||||||
|
end
|
||||||
|
else
|
||||||
|
gem_version = "~> #{version}.0"
|
||||||
|
gem 'railties', gem_version
|
||||||
|
gem 'activesupport', gem_version
|
||||||
|
gem 'activemodel', gem_version
|
||||||
|
gem 'actionpack', gem_version
|
||||||
|
gem 'activerecord', gem_version, group: :test
|
||||||
|
end
|
||||||
|
|
||||||
|
# https://github.com/bundler/bundler/blob/89a8778c19269561926cea172acdcda241d26d23/lib/bundler/dependency.rb#L30-L54
|
||||||
|
@windows_platforms = [:mswin, :mingw, :x64_mingw]
|
||||||
|
|
||||||
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
|
gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby])
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
source 'http://rubygems.org'
|
|
||||||
|
|
||||||
gemspec
|
|
||||||
|
|
||||||
gem 'rails', github: 'rails/rails'
|
|
||||||
|
|
||||||
# Current dependencies of edge rails
|
|
||||||
gem 'journey', github: 'rails/journey'
|
|
||||||
gem 'activerecord-deprecated_finders' , github: 'rails/activerecord-deprecated_finders'
|
|
||||||
4
Rakefile
4
Rakefile
@ -7,6 +7,7 @@ Rake::TestTask.new(:test) do |t|
|
|||||||
t.libs << 'lib'
|
t.libs << 'lib'
|
||||||
t.libs << 'test'
|
t.libs << 'test'
|
||||||
t.pattern = 'test/**/*_test.rb'
|
t.pattern = 'test/**/*_test.rb'
|
||||||
|
t.ruby_opts = ['-r./test/test_helper.rb']
|
||||||
t.verbose = true
|
t.verbose = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -16,3 +17,6 @@ task :bench do
|
|||||||
end
|
end
|
||||||
|
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
|
desc 'CI test task'
|
||||||
|
task :ci => :default
|
||||||
|
|||||||
27
appveyor.yml
Normal file
27
appveyor.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
version: '{build}'
|
||||||
|
|
||||||
|
skip_tags: true
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- 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
|
||||||
@ -242,9 +242,13 @@ class RenderJsonTest < ActionController::TestCase
|
|||||||
|
|
||||||
def test_render_json_with_callback
|
def test_render_json_with_callback
|
||||||
get :render_json_hello_world_with_callback
|
get :render_json_hello_world_with_callback
|
||||||
|
if Rails::VERSION::MAJOR == 3
|
||||||
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), @response.content_type.to_s
|
||||||
assert_match %r(application/json|text/javascript), @response.content_type.to_s
|
else
|
||||||
|
assert_equal '/**/alert({"hello":"world"})', @response.body
|
||||||
|
assert_match %r(text/javascript), @response.content_type.to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_render_json_with_custom_content_type
|
def test_render_json_with_custom_content_type
|
||||||
|
|||||||
@ -1370,6 +1370,7 @@ class SerializerTest < ActiveModel::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
data_class = Class.new do
|
data_class = Class.new do
|
||||||
|
include ActiveModel::Serializers::JSON
|
||||||
attr_accessor :title, :body
|
attr_accessor :title, :body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -199,6 +199,7 @@ class SomeSerializer < ActiveModel::Serializer
|
|||||||
end
|
end
|
||||||
|
|
||||||
class SomeObject < Struct.new(:some)
|
class SomeObject < Struct.new(:some)
|
||||||
|
include ActiveModel::Serializers::JSON
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set up some classes for polymorphic testing
|
# Set up some classes for polymorphic testing
|
||||||
|
|||||||
@ -1,13 +1,36 @@
|
|||||||
require "rubygems"
|
require "rubygems"
|
||||||
require "bundler/setup"
|
require "bundler/setup"
|
||||||
|
|
||||||
|
require 'rails'
|
||||||
|
require 'action_controller'
|
||||||
|
require 'action_controller/test_case'
|
||||||
|
require 'action_controller/railtie'
|
||||||
|
require 'active_support/json'
|
||||||
|
|
||||||
|
gem 'minitest'
|
||||||
|
require 'minitest/autorun'
|
||||||
|
if defined?(Minitest::Test)
|
||||||
|
$minitest_version = 5 # rubocop:disable Style/GlobalVars
|
||||||
|
# Minitest 5
|
||||||
|
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest/autorun.rb
|
||||||
|
# https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest.rb#L45-L59
|
||||||
|
else
|
||||||
|
$minitest_version = 4 # rubocop:disable Style/GlobalVars
|
||||||
|
# Minitest 4
|
||||||
|
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/autorun.rb
|
||||||
|
# https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/unit.rb#L768-L787
|
||||||
|
# Ensure backward compatibility with Minitest 4
|
||||||
|
Minitest = MiniTest unless defined?(Minitest)
|
||||||
|
Minitest::Test = MiniTest::Unit::TestCase
|
||||||
|
def Minitest.after_run(&block)
|
||||||
|
MiniTest::Unit.after_tests(&block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
require "pry"
|
require "pry"
|
||||||
|
|
||||||
require "active_model_serializers"
|
require "active_model_serializers"
|
||||||
require "active_support/json"
|
|
||||||
require "minitest/autorun"
|
|
||||||
|
|
||||||
require 'rails'
|
|
||||||
|
|
||||||
module TestHelper
|
module TestHelper
|
||||||
Routes = ActionDispatch::Routing::RouteSet.new
|
Routes = ActionDispatch::Routing::RouteSet.new
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user