Merge pull request #1274 from paper-trail-gem/dummy_app_load_defaults
Tests: Various updates to `dummy_app`, in preparation for rails 6.1
This commit is contained in:
commit
68522182af
|
@ -8,13 +8,14 @@
|
||||||
# > appraisal. If something is specified in both the Gemfile and an appraisal,
|
# > appraisal. If something is specified in both the Gemfile and an appraisal,
|
||||||
# > the version from the appraisal takes precedence.
|
# > the version from the appraisal takes precedence.
|
||||||
# > https://github.com/thoughtbot/appraisal
|
# > https://github.com/thoughtbot/appraisal
|
||||||
|
#
|
||||||
|
#
|
||||||
appraise "ar-5.2" do
|
appraise "ar-5.2" do
|
||||||
gem "activerecord", "~> 5.2.4"
|
gem "rails", "~> 5.2.4"
|
||||||
gem "rails-controller-testing", "~> 1.0.2"
|
gem "rails-controller-testing", "~> 1.0.2"
|
||||||
end
|
end
|
||||||
|
|
||||||
appraise "ar-6.0" do
|
appraise "ar-6.0" do
|
||||||
gem "activerecord", "~> 6.0.3"
|
gem "rails", "~> 6.0.3"
|
||||||
gem "rails-controller-testing", "~> 1.0.3"
|
gem "rails-controller-testing", "~> 1.0.3"
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "activerecord", "~> 5.2.4"
|
gem "rails", "~> 5.2.4"
|
||||||
gem "rails-controller-testing", "~> 1.0.2"
|
gem "rails-controller-testing", "~> 1.0.2"
|
||||||
|
|
||||||
gemspec path: "../"
|
gemspec path: "../"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "activerecord", "~> 6.0.3"
|
gem "rails", "~> 6.0.3"
|
||||||
gem "rails-controller-testing", "~> 1.0.3"
|
gem "rails-controller-testing", "~> 1.0.3"
|
||||||
|
|
||||||
gemspec path: "../"
|
gemspec path: "../"
|
||||||
|
|
|
@ -31,7 +31,7 @@ has been destroyed.
|
||||||
# https://www.ruby-lang.org/en/news/2019/10/02/ruby-2-4-9-released/
|
# https://www.ruby-lang.org/en/news/2019/10/02/ruby-2-4-9-released/
|
||||||
s.required_ruby_version = ">= 2.4.0"
|
s.required_ruby_version = ">= 2.4.0"
|
||||||
|
|
||||||
# We no longer specify a maximum rails version.
|
# We no longer specify a maximum activerecord version.
|
||||||
# See discussion in paper_trail/compatibility.rb
|
# See discussion in paper_trail/compatibility.rb
|
||||||
s.add_dependency "activerecord", ::PaperTrail::Compatibility::ACTIVERECORD_GTE
|
s.add_dependency "activerecord", ::PaperTrail::Compatibility::ACTIVERECORD_GTE
|
||||||
s.add_dependency "request_store", "~> 1.1"
|
s.add_dependency "request_store", "~> 1.1"
|
||||||
|
@ -41,6 +41,12 @@ has been destroyed.
|
||||||
s.add_development_dependency "ffaker", "~> 2.11"
|
s.add_development_dependency "ffaker", "~> 2.11"
|
||||||
s.add_development_dependency "generator_spec", "~> 0.9.4"
|
s.add_development_dependency "generator_spec", "~> 0.9.4"
|
||||||
s.add_development_dependency "memory_profiler", "~> 0.9.14"
|
s.add_development_dependency "memory_profiler", "~> 0.9.14"
|
||||||
|
|
||||||
|
# For `spec/dummy_app`. Technically, we only need `actionpack` (as of 2020).
|
||||||
|
# However, that might change in the future, and the advantages of specifying a
|
||||||
|
# subset (e.g. actionpack only) are unclear.
|
||||||
|
s.add_development_dependency "rails", ::PaperTrail::Compatibility::ACTIVERECORD_GTE
|
||||||
|
|
||||||
s.add_development_dependency "rake", "~> 13.0"
|
s.add_development_dependency "rake", "~> 13.0"
|
||||||
s.add_development_dependency "rspec-rails", "~> 4.0"
|
s.add_development_dependency "rspec-rails", "~> 4.0"
|
||||||
s.add_development_dependency "rubocop", "~> 0.89.1"
|
s.add_development_dependency "rubocop", "~> 0.89.1"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Family
|
module Family
|
||||||
class CelebrityFamily < Family::Family
|
class CelebrityFamily < ::Family::Family
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,38 +11,14 @@ require "paper_trail"
|
||||||
|
|
||||||
module Dummy
|
module Dummy
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
|
config.load_defaults(::Rails.gem_version.segments.take(2).join("."))
|
||||||
|
|
||||||
config.encoding = "utf-8"
|
config.encoding = "utf-8"
|
||||||
config.filter_parameters += [:password]
|
config.filter_parameters += [:password]
|
||||||
config.active_support.escape_html_entities_in_json = true
|
config.active_support.escape_html_entities_in_json = true
|
||||||
config.active_support.test_order = :sorted
|
config.active_support.test_order = :sorted
|
||||||
|
|
||||||
# Disable assets in rails 4.2. In rails 5, config does not respond to
|
|
||||||
# assets, probably because it was moved out of railties to some other gem,
|
|
||||||
# and we only have dev. dependencies on railties, not all of rails. When
|
|
||||||
# we drop support for rails 4.2, we can remove this whole conditional.
|
|
||||||
if config.respond_to?(:assets)
|
|
||||||
config.assets.enabled = false
|
|
||||||
end
|
|
||||||
|
|
||||||
config.secret_key_base = "A fox regularly kicked the screaming pile of biscuits."
|
config.secret_key_base = "A fox regularly kicked the screaming pile of biscuits."
|
||||||
|
|
||||||
# `raise_in_transactional_callbacks` was added in rails 4, then deprecated
|
|
||||||
# in rails 5. Oh, how fickle are the gods.
|
|
||||||
if ActiveRecord.respond_to?(:gem_version)
|
|
||||||
v = ActiveRecord.gem_version
|
|
||||||
if v >= Gem::Version.new("4.2") && v < Gem::Version.new("5.0.0.beta1")
|
|
||||||
config.active_record.raise_in_transactional_callbacks = true
|
|
||||||
end
|
|
||||||
if v >= Gem::Version.new("5.0.0.beta1") && v < Gem::Version.new("5.1")
|
|
||||||
config.active_record.belongs_to_required_by_default = true
|
|
||||||
config.active_record.time_zone_aware_types = [:datetime]
|
|
||||||
end
|
|
||||||
if v >= Gem::Version.new("5.1")
|
|
||||||
config.load_defaults "5.1"
|
|
||||||
config.active_record.time_zone_aware_types = [:datetime]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# In rails >= 6.0, "`.represent_boolean_as_integer=` is now always true,
|
# In rails >= 6.0, "`.represent_boolean_as_integer=` is now always true,
|
||||||
# so setting this is deprecated and will be removed in Rails 6.1."
|
# so setting this is deprecated and will be removed in Rails 6.1."
|
||||||
if ::ENV["DB"] == "sqlite" &&
|
if ::ENV["DB"] == "sqlite" &&
|
||||||
|
|
|
@ -335,8 +335,9 @@ RSpec.describe(::PaperTrail, versioning: true) do
|
||||||
expect(previous_widget.a_datetime.to_time.utc.to_i).to(eq(t0.to_time.utc.to_i))
|
expect(previous_widget.a_datetime.to_time.utc.to_i).to(eq(t0.to_time.utc.to_i))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handle times" do
|
it "handle times (time only, no date)" do
|
||||||
expect(previous_widget.a_time.utc.to_i).to(eq(t0.utc.to_i))
|
format = ->(t) { t.utc.strftime "%H:%M:%S" }
|
||||||
|
expect(format[previous_widget.a_time]).to eq(format[t0])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handle dates" do
|
it "handle dates" do
|
||||||
|
@ -362,7 +363,8 @@ RSpec.describe(::PaperTrail, versioning: true) do
|
||||||
assert_in_delta(153.01, reified.a_float, 0.001)
|
assert_in_delta(153.01, reified.a_float, 0.001)
|
||||||
assert_in_delta(2.7183, reified.a_decimal, 0.0001)
|
assert_in_delta(2.7183, reified.a_decimal, 0.0001)
|
||||||
expect(reified.a_datetime.to_time.utc.to_i).to(eq(t0.to_time.utc.to_i))
|
expect(reified.a_datetime.to_time.utc.to_i).to(eq(t0.to_time.utc.to_i))
|
||||||
expect(reified.a_time.utc.to_i).to(eq(t0.utc.to_i))
|
format = ->(t) { t.utc.strftime "%H:%M:%S" }
|
||||||
|
expect(format[reified.a_time]).to eq(format[t0])
|
||||||
expect(reified.a_date).to(eq(d0))
|
expect(reified.a_date).to(eq(d0))
|
||||||
expect(reified.a_boolean).to(be_truthy)
|
expect(reified.a_boolean).to(be_truthy)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue