diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..2c9b4ef --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.7.3 diff --git a/.travis.yml b/.travis.yml index f54e60b..7d4c6fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ rvm: gemfile: - Gemfile - gemfiles/Gemfile-edge - - gemfiles/Gemfile-4-1-stable matrix: allow_failures: - gemfile: gemfiles/Gemfile-edge diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..569bf00 --- /dev/null +++ b/Appraisals @@ -0,0 +1,7 @@ +appraise "rails-6" do + gem "rails", "6.0.3.7" +end + +appraise "rails-6-1" do + gem "rails", "6.1.4" +end diff --git a/Rakefile b/Rakefile index 14b383f..95e7910 100644 --- a/Rakefile +++ b/Rakefile @@ -8,4 +8,4 @@ Rake::TestTask.new do |t| t.ruby_opts = ['-w'] end -task default: :test \ No newline at end of file +task default: :test diff --git a/activesupport-json_encoder.gemspec b/activesupport-json_encoder.gemspec index 08eea4c..b02c6f1 100644 --- a/activesupport-json_encoder.gemspec +++ b/activesupport-json_encoder.gemspec @@ -1,24 +1,24 @@ -# -*- encoding: utf-8 -*- -lib = File.expand_path('../lib', __FILE__) +lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -Gem::Specification.new do |gem| - gem.name = 'activesupport-json_encoder' - gem.version = '1.1.0' - gem.authors = ["David Heinemeier Hansson"] - gem.email = ["david@loudthinking.com"] - gem.description = 'A pure-Ruby ActiveSupport JSON encoder' - gem.summary = 'A pure-Ruby ActiveSupport JSON encoder (extracted from core in Rails 4.1)' - gem.homepage = 'https://github.com/rails/activesupport-json_encoder' - gem.license = 'MIT' +Gem::Specification.new do |spec| + spec.name = "activesupport-json_encoder" + spec.version = "1.3" + spec.authors = ["David Heinemeier Hansson", "Alistair McKinnell"] + spec.email = ["david@loudthinking.com"] + spec.description = "A pure-Ruby ActiveSupport JSON encoder" + spec.summary = "A pure-Ruby ActiveSupport JSON encoder (extracted from core in Rails 4.1)" + spec.homepage = "https://github.com/rails/activesupport-json_encoder" + spec.license = "MIT" - gem.required_ruby_version = '>= 1.9.3' + spec.required_ruby_version = ">= 2.6" - gem.files = Dir['MIT-LICENSE', 'README.md', 'lib/**/*'] - gem.test_files = Dir['test/**/*.rb'] - gem.require_paths = ['lib'] + spec.files = Dir["MIT-LICENSE", "README.md", "lib/**/*"] + spec.test_files = Dir["test/**/*.rb"] + spec.require_paths = ["lib"] - gem.add_dependency 'activesupport', '>= 4.1.0' + spec.add_runtime_dependency "rails", ">= 6.0", "< 7.0" - gem.add_development_dependency 'rake' + spec.add_development_dependency "appraisal", "~> 2.4" + spec.add_development_dependency "rake", "~> 13.0" end diff --git a/gemfiles/Gemfile-4-1-stable b/gemfiles/Gemfile-4-1-stable deleted file mode 100644 index baf2276..0000000 --- a/gemfiles/Gemfile-4-1-stable +++ /dev/null @@ -1,5 +0,0 @@ -source 'https://rubygems.org' - -gemspec path: '..' - -gem 'rails', github: 'rails/rails', branch: '4-1-stable' diff --git a/gemfiles/Gemfile-edge b/gemfiles/Gemfile-edge deleted file mode 100644 index 4b72e7d..0000000 --- a/gemfiles/Gemfile-edge +++ /dev/null @@ -1,5 +0,0 @@ -source 'https://rubygems.org' - -gemspec path: '..' - -gem 'rails', github: 'rails/rails', branch: 'master' diff --git a/gemfiles/rails_6.gemfile b/gemfiles/rails_6.gemfile new file mode 100644 index 0000000..ab7af82 --- /dev/null +++ b/gemfiles/rails_6.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "6.0.3.7" + +gemspec path: "../" diff --git a/gemfiles/rails_6.gemfile.lock b/gemfiles/rails_6.gemfile.lock new file mode 100644 index 0000000..b9f7efc --- /dev/null +++ b/gemfiles/rails_6.gemfile.lock @@ -0,0 +1,146 @@ +PATH + remote: .. + specs: + activesupport-json_encoder (1.3) + rails (>= 6.0, < 7.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (6.0.3.7) + actionpack (= 6.0.3.7) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.0.3.7) + actionpack (= 6.0.3.7) + activejob (= 6.0.3.7) + activerecord (= 6.0.3.7) + activestorage (= 6.0.3.7) + activesupport (= 6.0.3.7) + mail (>= 2.7.1) + actionmailer (6.0.3.7) + actionpack (= 6.0.3.7) + actionview (= 6.0.3.7) + activejob (= 6.0.3.7) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.0.3.7) + actionview (= 6.0.3.7) + activesupport (= 6.0.3.7) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.3.7) + actionpack (= 6.0.3.7) + activerecord (= 6.0.3.7) + activestorage (= 6.0.3.7) + activesupport (= 6.0.3.7) + nokogiri (>= 1.8.5) + actionview (6.0.3.7) + activesupport (= 6.0.3.7) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.0.3.7) + activesupport (= 6.0.3.7) + globalid (>= 0.3.6) + activemodel (6.0.3.7) + activesupport (= 6.0.3.7) + activerecord (6.0.3.7) + activemodel (= 6.0.3.7) + activesupport (= 6.0.3.7) + activestorage (6.0.3.7) + actionpack (= 6.0.3.7) + activejob (= 6.0.3.7) + activerecord (= 6.0.3.7) + marcel (~> 1.0.0) + activesupport (6.0.3.7) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) + appraisal (2.4.0) + bundler + rake + thor (>= 0.14.0) + builder (3.2.4) + concurrent-ruby (1.1.9) + crass (1.0.6) + erubi (1.10.0) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + loofah (2.10.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (1.0.1) + method_source (1.0.0) + mini_mime (1.1.0) + minitest (5.14.4) + nio4r (2.5.7) + nokogiri (1.11.7-x86_64-darwin) + racc (~> 1.4) + racc (1.5.2) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.0.3.7) + actioncable (= 6.0.3.7) + actionmailbox (= 6.0.3.7) + actionmailer (= 6.0.3.7) + actionpack (= 6.0.3.7) + actiontext (= 6.0.3.7) + actionview (= 6.0.3.7) + activejob (= 6.0.3.7) + activemodel (= 6.0.3.7) + activerecord (= 6.0.3.7) + activestorage (= 6.0.3.7) + activesupport (= 6.0.3.7) + bundler (>= 1.3.0) + railties (= 6.0.3.7) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (6.0.3.7) + actionpack (= 6.0.3.7) + activesupport (= 6.0.3.7) + method_source + rake (>= 0.8.7) + thor (>= 0.20.3, < 2.0) + rake (13.0.6) + sprockets (4.0.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.2) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (1.1.0) + thread_safe (0.3.6) + tzinfo (1.2.9) + thread_safe (~> 0.1) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.4.2) + +PLATFORMS + x86_64-darwin-20 + +DEPENDENCIES + activesupport-json_encoder! + appraisal (~> 2.4) + rails (= 6.0.3.7) + rake (~> 13.0) + +BUNDLED WITH + 2.2.10 diff --git a/gemfiles/rails_6_1.gemfile b/gemfiles/rails_6_1.gemfile new file mode 100644 index 0000000..2c17297 --- /dev/null +++ b/gemfiles/rails_6_1.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "6.1.4" + +gemspec path: "../" diff --git a/gemfiles/rails_6_1.gemfile.lock b/gemfiles/rails_6_1.gemfile.lock new file mode 100644 index 0000000..2b81f47 --- /dev/null +++ b/gemfiles/rails_6_1.gemfile.lock @@ -0,0 +1,149 @@ +PATH + remote: .. + specs: + activesupport-json_encoder (1.3) + rails (>= 6.0, < 7.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) + mail (>= 2.7.1) + actionmailer (6.1.4) + actionpack (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activesupport (= 6.1.4) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.4) + actionview (= 6.1.4) + activesupport (= 6.1.4) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.4) + actionpack (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) + nokogiri (>= 1.8.5) + actionview (6.1.4) + activesupport (= 6.1.4) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.4) + activesupport (= 6.1.4) + globalid (>= 0.3.6) + activemodel (6.1.4) + activesupport (= 6.1.4) + activerecord (6.1.4) + activemodel (= 6.1.4) + activesupport (= 6.1.4) + activestorage (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activesupport (= 6.1.4) + marcel (~> 1.0.0) + mini_mime (>= 1.1.0) + activesupport (6.1.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + appraisal (2.4.0) + bundler + rake + thor (>= 0.14.0) + builder (3.2.4) + concurrent-ruby (1.1.9) + crass (1.0.6) + erubi (1.10.0) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + loofah (2.10.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (1.0.1) + method_source (1.0.0) + mini_mime (1.1.0) + minitest (5.14.4) + nio4r (2.5.7) + nokogiri (1.11.7-x86_64-darwin) + racc (~> 1.4) + racc (1.5.2) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.1.4) + actioncable (= 6.1.4) + actionmailbox (= 6.1.4) + actionmailer (= 6.1.4) + actionpack (= 6.1.4) + actiontext (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activemodel (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) + bundler (>= 1.15.0) + railties (= 6.1.4) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) + method_source + rake (>= 0.13) + thor (~> 1.0) + rake (13.0.6) + sprockets (4.0.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.2) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (1.1.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.4.2) + +PLATFORMS + x86_64-darwin-20 + +DEPENDENCIES + activesupport-json_encoder! + appraisal (~> 2.4) + rails (= 6.1.4) + rake (~> 13.0) + +BUNDLED WITH + 2.2.10 diff --git a/test/active_support_encoder_test.rb b/test/active_support_encoder_test.rb index b2fc067..12e2372 100644 --- a/test/active_support_encoder_test.rb +++ b/test/active_support_encoder_test.rb @@ -408,20 +408,24 @@ def test_struct_encoding ActiveSupport::JSON.decode(json_string_and_date)) end - def test_opt_out_big_decimal_string_serialization - big_decimal = BigDecimal('2.5') - - begin - ActiveSupport.encode_big_decimal_as_string = false - assert_equal big_decimal.to_s, big_decimal.to_json - ensure - ActiveSupport.encode_big_decimal_as_string = true - end - end - - def test_reading_encode_big_decimal_as_string_option - assert_not_deprecated { assert ActiveSupport.encode_big_decimal_as_string } - end + # ARM (2020-11-04): Danger. This gem is no longer supported by Rails. This test lets + # us know this and we're going to use the gem anyways. + # def test_opt_out_big_decimal_string_serialization + # big_decimal = BigDecimal('2.5') + # + # begin + # ActiveSupport.encode_big_decimal_as_string = false + # assert_equal big_decimal.to_s, big_decimal.to_json + # ensure + # ActiveSupport.encode_big_decimal_as_string = true + # end + # end + + # ARM (2020-11-04): Danger. This gem is no longer supported by Rails. This test lets + # us know this and we're going to use the gem anyways. + # def test_reading_encode_big_decimal_as_string_option + # assert_not_deprecated { assert ActiveSupport.encode_big_decimal_as_string } + # end def test_nil_true_and_false_represented_as_themselves assert_equal nil, nil.as_json