From 18b6a33f3ab565c8c4cf31f2247b9dd99209aa8d Mon Sep 17 00:00:00 2001 From: "Bryan Hanks, PMP" Date: Thu, 14 Jan 2021 11:04:14 -0600 Subject: [PATCH 1/5] Added rails 6.0 and 6.1 to travis --- .travis.yml | 2 ++ gemfiles/rails_6.0.gemfile | 7 +++++++ gemfiles/rails_6.1.gemfile | 7 +++++++ 3 files changed, 16 insertions(+) create mode 100644 gemfiles/rails_6.0.gemfile create mode 100644 gemfiles/rails_6.1.gemfile diff --git a/.travis.yml b/.travis.yml index f2d35802..d3389dee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,8 @@ gemfile: - gemfiles/rails_5.0.gemfile - gemfiles/rails_5.1.gemfile - gemfiles/rails_5.2.gemfile + - gemfiles/rails_6.0.gemfile + - gemfiles/rails_6.1.gemfile - gemfiles/mongoid_5.0.gemfile - gemfiles/mongoid_6.0.gemfile diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile new file mode 100644 index 00000000..3113d665 --- /dev/null +++ b/gemfiles/rails_6.0.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", ">= 6.0.0", "< 6.1" + +gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile new file mode 100644 index 00000000..8aed9ccb --- /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.0", "< 6.2" + +gemspec path: "../" From 18835d298fd907623b23342bd1d1ffbef6a425ea Mon Sep 17 00:00:00 2001 From: "Bryan Hanks, PMP" Date: Thu, 14 Jan 2021 11:57:09 -0600 Subject: [PATCH 2/5] Added rails 6 support files --- Appraisals | 8 ++++++++ spec/support/rails_versions.rb | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/Appraisals b/Appraisals index a98e42a5..6a24bb79 100644 --- a/Appraisals +++ b/Appraisals @@ -19,6 +19,14 @@ appraise 'rails-5.2' do gem 'rails', '>= 5.2.0', '< 5.3' end +appraise 'rails-6.0' do + gem 'rails', '>= 6.0.0', '< 6.1' +end + +appraise 'rails-6.1' do + gem 'rails', '>= 6.1.0', '< 6.2' +end + appraise 'mongoid-4.0' do gem 'mongoid', '~> 4.0.0' end diff --git a/spec/support/rails_versions.rb b/spec/support/rails_versions.rb index e6c6d1f7..fd1662ed 100644 --- a/spec/support/rails_versions.rb +++ b/spec/support/rails_versions.rb @@ -3,6 +3,16 @@ def rails_version Gem::Version.new(Rails::VERSION::STRING) end + def rails_6_1? + Gem::Requirement.new('~> 6.1.0').satisfied_by?(rails_version) + end + alias_method :activerecord_6_1?, :rails_6_1? + + def rails_6_0? + Gem::Requirement.new('~> 6.0.0').satisfied_by?(rails_version) + end + alias_method :activerecord_6_0?, :rails_6_0? + def rails_5_2? Gem::Requirement.new('~> 5.2.0').satisfied_by?(rails_version) end From 2ccd8ac5de72ccc124a464b7299b26ca59029c81 Mon Sep 17 00:00:00 2001 From: "Bryan Hanks, PMP" Date: Thu, 14 Jan 2021 12:51:51 -0600 Subject: [PATCH 3/5] Added data for rais 6.x tests --- spec/ext/active_record_spec.rb | 12 +- spec/support/active_record_data/6_0_diana.txt | 104 +++++++++ spec/support/active_record_data/6_0_multi.txt | 210 +++++++++++++++++ spec/support/active_record_data/6_1_diana.txt | 109 +++++++++ spec/support/active_record_data/6_1_multi.txt | 220 ++++++++++++++++++ 5 files changed, 653 insertions(+), 2 deletions(-) create mode 100644 spec/support/active_record_data/6_0_diana.txt create mode 100644 spec/support/active_record_data/6_0_multi.txt create mode 100644 spec/support/active_record_data/6_1_diana.txt create mode 100644 spec/support/active_record_data/6_1_multi.txt diff --git a/spec/ext/active_record_spec.rb b/spec/ext/active_record_spec.rb index 3aab411a..603632ab 100644 --- a/spec/ext/active_record_spec.rb +++ b/spec/ext/active_record_spec.rb @@ -120,7 +120,11 @@ out = @ap.awesome(@diana) raw_object_string = - if activerecord_5_2? + if activerecord_6_1? + ActiveRecordData.raw_6_1_diana + elsif activerecord_6_0? + ActiveRecordData.raw_6_0_diana + elsif activerecord_5_2? ActiveRecordData.raw_5_2_diana elsif activerecord_5_1? ActiveRecordData.raw_5_1_diana @@ -143,7 +147,11 @@ out = @ap.awesome([@diana, @laura]) raw_object_string = - if activerecord_5_2? + if activerecord_6_1? + ActiveRecordData.raw_6_1_multi + elsif activerecord_6_0? + ActiveRecordData.raw_6_0_multi + elsif activerecord_5_2? ActiveRecordData.raw_5_2_multi elsif activerecord_5_1? ActiveRecordData.raw_5_1_multi diff --git a/spec/support/active_record_data/6_0_diana.txt b/spec/support/active_record_data/6_0_diana.txt new file mode 100644 index 00000000..d3b68ef1 --- /dev/null +++ b/spec/support/active_record_data/6_0_diana.txt @@ -0,0 +1,104 @@ +# #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "admin", + attr_reader :type = #, + attr_reader :value_before_type_cast = false + >, + "created_at" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "created_at", + attr_reader :type = #, + attr_reader :value_before_type_cast = "1992-10-10 12:30:00" + >, + "id" => #, + attr_reader :value_before_type_cast = nil + >, + "name" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "name", + attr_reader :type = #, + attr_reader :value_before_type_cast = "Diana" + >, + "rank" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "rank", + attr_reader :type = #, + attr_reader :value_before_type_cast = 1 + > + } + >, + attr_accessor :destroyed_by_association = nil +> diff --git a/spec/support/active_record_data/6_0_multi.txt b/spec/support/active_record_data/6_0_multi.txt new file mode 100644 index 00000000..987c9dae --- /dev/null +++ b/spec/support/active_record_data/6_0_multi.txt @@ -0,0 +1,210 @@ +[ + [0] # #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "admin", + attr_reader :type = #, + attr_reader :value_before_type_cast = false + >, + "created_at" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "created_at", + attr_reader :type = #, + attr_reader :value_before_type_cast = "1992-10-10 12:30:00" + >, + "id" => #, + attr_reader :value_before_type_cast = nil + >, + "name" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "name", + attr_reader :type = #, + attr_reader :value_before_type_cast = "Diana" + >, + "rank" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "rank", + attr_reader :type = #, + attr_reader :value_before_type_cast = 1 + > + } + >, + attr_accessor :destroyed_by_association = nil + >, + [1] # #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "admin", + attr_reader :type = #, + attr_reader :value_before_type_cast = true + >, + "created_at" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "created_at", + attr_reader :type = #, + attr_reader :value_before_type_cast = "2003-05-26 14:15:00" + >, + "id" => #, + attr_reader :value_before_type_cast = nil + >, + "name" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "name", + attr_reader :type = #, + attr_reader :value_before_type_cast = "Laura" + >, + "rank" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "rank", + attr_reader :type = #, + attr_reader :value_before_type_cast = 2 + > + } + >, + attr_accessor :destroyed_by_association = nil + > +] diff --git a/spec/support/active_record_data/6_1_diana.txt b/spec/support/active_record_data/6_1_diana.txt new file mode 100644 index 00000000..08ca7763 --- /dev/null +++ b/spec/support/active_record_data/6_1_diana.txt @@ -0,0 +1,109 @@ +# #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "admin", + attr_reader :type = #, + attr_reader :value_before_type_cast = false + >, + "created_at" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "created_at", + attr_reader :type = #, + attr_reader :value_before_type_cast = "1992-10-10 12:30:00" + >, + "id" => #, + attr_reader :value_before_type_cast = nil + >, + "name" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "name", + attr_reader :type = #, + attr_reader :value_before_type_cast = "Diana" + >, + "rank" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "rank", + attr_reader :type = #, + attr_reader :value_before_type_cast = 1 + > + } + >, + attr_accessor :destroyed_by_association = nil +> diff --git a/spec/support/active_record_data/6_1_multi.txt b/spec/support/active_record_data/6_1_multi.txt new file mode 100644 index 00000000..8a25372b --- /dev/null +++ b/spec/support/active_record_data/6_1_multi.txt @@ -0,0 +1,220 @@ +[ + [0] # #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "admin", + attr_reader :type = #, + attr_reader :value_before_type_cast = false + >, + "created_at" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "created_at", + attr_reader :type = #, + attr_reader :value_before_type_cast = "1992-10-10 12:30:00" + >, + "id" => #, + attr_reader :value_before_type_cast = nil + >, + "name" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "name", + attr_reader :type = #, + attr_reader :value_before_type_cast = "Diana" + >, + "rank" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "rank", + attr_reader :type = #, + attr_reader :value_before_type_cast = 1 + > + } + >, + attr_accessor :destroyed_by_association = nil + >, + [1] # #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "admin", + attr_reader :type = #, + attr_reader :value_before_type_cast = true + >, + "created_at" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "created_at", + attr_reader :type = #, + attr_reader :value_before_type_cast = "2003-05-26 14:15:00" + >, + "id" => #, + attr_reader :value_before_type_cast = nil + >, + "name" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "name", + attr_reader :type = #, + attr_reader :value_before_type_cast = "Laura" + >, + "rank" => #, + attr_reader :value_before_type_cast = nil + >, + attr_reader :name = "rank", + attr_reader :type = #, + attr_reader :value_before_type_cast = 2 + > + } + >, + attr_accessor :destroyed_by_association = nil + > +] From 4ca35ba114853a2211e15517d02f6a273cb0c667 Mon Sep 17 00:00:00 2001 From: "Bryan Hanks, PMP" Date: Thu, 14 Jan 2021 13:53:04 -0600 Subject: [PATCH 4/5] Rails 6 date helper includes float seconds --- spec/ext/active_support_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/ext/active_support_spec.rb b/spec/ext/active_support_spec.rb index f14299d2..a3471619 100644 --- a/spec/ext/active_support_spec.rb +++ b/spec/ext/active_support_spec.rb @@ -8,7 +8,11 @@ it 'should format ActiveSupport::TimeWithZone as regular Time' do Time.zone = 'Eastern Time (US & Canada)' time = Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone - expect(@ap.send(:awesome, time)).to eq("\e[0;32mSat, 10 Feb 2007 15:30:45 EST -05:00\e[0m") + if activerecord_6_1? + expect(@ap.send(:awesome, time)).to eq("\e[0;32mSat, 10 Feb 2007 15:30:45.000000000 EST -05:00\e[0m") + else + expect(@ap.send(:awesome, time)).to eq("\e[0;32mSat, 10 Feb 2007 15:30:45 EST -05:00\e[0m") + end end it 'should format HashWithIndifferentAccess as regular Hash' do From ddc9f706d37e47dc19017d4fb177e7169aab48f4 Mon Sep 17 00:00:00 2001 From: "Bryan Hanks, PMP" Date: Thu, 14 Jan 2021 14:58:26 -0600 Subject: [PATCH 5/5] Updated actionview test for rails 6.1 --- spec/ext/action_view_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/ext/action_view_spec.rb b/spec/ext/action_view_spec.rb index c772d814..76022a3a 100644 --- a/spec/ext/action_view_spec.rb +++ b/spec/ext/action_view_spec.rb @@ -1,9 +1,12 @@ require 'spec_helper' RSpec.describe 'AwesomePrint ActionView extensions', skip: -> { !ExtVerifier.has_rails? }.call do - before do - @view = ActionView::Base.new + @view = if rails_6_1? + ActionView::Base.new(ActionView::LookupContext.new([]), {}, {}) + else + ActionView::Base.new + end end it "uses HTML and adds 'debug_dump' class to plain
 tag" do