mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 23:33:00 +00:00
Compare commits
14 Commits
v5.0.0.alp
...
v5.0.0.bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3134072f01 | ||
|
|
797ba48036 | ||
|
|
f8e6480f58 | ||
|
|
3835b2b161 | ||
|
|
00d038bc6f | ||
|
|
a3d0182b5e | ||
|
|
46296f914f | ||
|
|
4447361743 | ||
|
|
4523138c3c | ||
|
|
72807b87a7 | ||
|
|
9daf12c4a1 | ||
|
|
2a80683683 | ||
|
|
3a2882be75 | ||
|
|
bf1c808846 |
@@ -3,12 +3,19 @@
|
|||||||
* Relaxed Timeliness dependency version which allows for >= 0.4.0 with
|
* Relaxed Timeliness dependency version which allows for >= 0.4.0 with
|
||||||
threadsafety fix for use_us_formats and use_euro_formats for hot switching
|
threadsafety fix for use_us_formats and use_euro_formats for hot switching
|
||||||
in a request.
|
in a request.
|
||||||
|
* Add initializer to ensure Timeliness v0.4+ ambiguous date config is set
|
||||||
|
correctly when using `use_euro_formats` or `remove_use_formats'.
|
||||||
|
|
||||||
Breaking Changes
|
Breaking Changes
|
||||||
* Update Multiparameter extension to use ActiveRecord type classes with multiparameter handling
|
* Update Multiparameter extension to use ActiveRecord type classes with multiparameter handling
|
||||||
which stores a hash of multiparamter values as the value before type cast, no longer a mushed datetime string
|
which stores a hash of multiparamter values as the value before type cast, no longer a mushed datetime string
|
||||||
* Removed all custom plugin attribute methods and method overrides in favour using ActiveModel type system
|
* Removed all custom plugin attribute methods and method overrides in favour using ActiveModel type system
|
||||||
|
|
||||||
|
= 4.1.0 [2019-06-11]
|
||||||
|
* Relaxed Timeliness dependency version to >= 0.3.10 and < 1, which allows
|
||||||
|
version 0.4 with threadsafety fix for use_us_formats and use_euro_formats
|
||||||
|
hot switching in a request.
|
||||||
|
|
||||||
= 4.0.2 [2016-01-07]
|
= 4.0.2 [2016-01-07]
|
||||||
* Fix undefine_generated_methods ivar guard setting to false
|
* Fix undefine_generated_methods ivar guard setting to false
|
||||||
|
|
||||||
|
|||||||
2
Gemfile
2
Gemfile
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
|
|||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
gem 'rails', '~> 5.0.0'
|
gem 'rails', '~> 5.1.7'
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
gem 'rspec-rails', '~> 3.7'
|
gem 'rspec-rails', '~> 3.7'
|
||||||
gem 'timecop'
|
gem 'timecop'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
== Description
|
== Description
|
||||||
|
|
||||||
Complete validation of dates, times and datetimes for Rails 5.0.x and ActiveModel.
|
Complete validation of dates, times and datetimes for Rails 5.x and ActiveModel.
|
||||||
|
|
||||||
If you a looking for the old version for Rails 4.x go here [https://github.com/adzap/validates_timeliness/tree/4-0-stable].
|
If you a looking for the old version for Rails 4.x go here [https://github.com/adzap/validates_timeliness/tree/4-0-stable].
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,7 @@ gem "rspec-rails", "~> 3.7"
|
|||||||
gem "timecop"
|
gem "timecop"
|
||||||
gem "byebug"
|
gem "byebug"
|
||||||
gem "appraisal"
|
gem "appraisal"
|
||||||
gem "sqlite3"
|
gem "sqlite3", "~> 1.3.6"
|
||||||
gem "nokogiri", "~> 1.8"
|
gem "nokogiri", "~> 1.8"
|
||||||
|
|
||||||
group :active_record do
|
|
||||||
gem "sqlite3-ruby", require: "sqlite3"
|
|
||||||
end
|
|
||||||
|
|
||||||
gemspec path: "../"
|
gemspec path: "../"
|
||||||
|
|||||||
@@ -8,11 +8,7 @@ gem "rspec-rails", "~> 3.7"
|
|||||||
gem "timecop"
|
gem "timecop"
|
||||||
gem "byebug"
|
gem "byebug"
|
||||||
gem "appraisal"
|
gem "appraisal"
|
||||||
gem "sqlite3"
|
gem "sqlite3", "~> 1.3.6"
|
||||||
gem "nokogiri", "~> 1.8"
|
gem "nokogiri", "~> 1.8"
|
||||||
|
|
||||||
group :active_record do
|
|
||||||
gem "sqlite3-ruby", require: "sqlite3"
|
|
||||||
end
|
|
||||||
|
|
||||||
gemspec path: "../"
|
gemspec path: "../"
|
||||||
|
|||||||
@@ -8,11 +8,7 @@ gem "rspec-rails", "~> 3.7"
|
|||||||
gem "timecop"
|
gem "timecop"
|
||||||
gem "byebug"
|
gem "byebug"
|
||||||
gem "appraisal"
|
gem "appraisal"
|
||||||
gem "sqlite3"
|
gem "sqlite3", "~> 1.3.6"
|
||||||
gem "nokogiri", "~> 1.8"
|
gem "nokogiri", "~> 1.8"
|
||||||
|
|
||||||
group :active_record do
|
|
||||||
gem "sqlite3-ruby", require: "sqlite3"
|
|
||||||
end
|
|
||||||
|
|
||||||
gemspec path: "../"
|
gemspec path: "../"
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ module ValidatesTimeliness
|
|||||||
|
|
||||||
# Shorthand time and date symbols for restrictions
|
# Shorthand time and date symbols for restrictions
|
||||||
self.restriction_shorthand_symbols = {
|
self.restriction_shorthand_symbols = {
|
||||||
:now => lambda { Time.current },
|
now: proc { Time.current },
|
||||||
:today => lambda { Date.current }
|
today: proc { Date.current }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use the plugin date/time parser which is stricter and extensible
|
# Use the plugin date/time parser which is stricter and extensible
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ module ValidatesTimeliness
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ActiveRecord::Base
|
ActiveSupport.on_load(:active_record) do
|
||||||
include ValidatesTimeliness::AttributeMethods
|
include ValidatesTimeliness::AttributeMethods
|
||||||
include ValidatesTimeliness::ORM::ActiveRecord
|
include ValidatesTimeliness::ORM::ActiveRecord
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,5 +11,13 @@ module ValidatesTimeliness
|
|||||||
initializer "validates_timeliness.initialize_restriction_errors" do
|
initializer "validates_timeliness.initialize_restriction_errors" do
|
||||||
ValidatesTimeliness.ignore_restriction_errors = !Rails.env.test?
|
ValidatesTimeliness.ignore_restriction_errors = !Rails.env.test?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
initializer "validates_timeliness.initialize_timeliness_ambiguous_date_format", :after => 'load_config_initializers' do
|
||||||
|
if Timeliness.respond_to?(:ambiguous_date_format) # i.e. v0.4+
|
||||||
|
# Set default for each new thread if you have changed the default using
|
||||||
|
# the format switching methods.
|
||||||
|
Timeliness.configuration.ambiguous_date_format = Timeliness::Definitions.current_date_format
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module ValidatesTimeliness
|
module ValidatesTimeliness
|
||||||
VERSION = '5.0.0.alpha4'
|
VERSION = '5.0.0.beta1'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ require 'timecop'
|
|||||||
require 'validates_timeliness'
|
require 'validates_timeliness'
|
||||||
require 'validates_timeliness/orm/active_model'
|
require 'validates_timeliness/orm/active_model'
|
||||||
|
|
||||||
|
require 'rails/railtie'
|
||||||
|
|
||||||
require 'support/test_model'
|
require 'support/test_model'
|
||||||
require 'support/model_helpers'
|
require 'support/model_helpers'
|
||||||
require 'support/config_helper'
|
require 'support/config_helper'
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ module ModelHelpers
|
|||||||
|
|
||||||
def with_each_person_value(attr_name, values)
|
def with_each_person_value(attr_name, values)
|
||||||
record = Person.new
|
record = Person.new
|
||||||
values = [values] unless values.is_a?(Array)
|
Array.wrap(values).each do |value|
|
||||||
values.each do |value|
|
|
||||||
record.send("#{attr_name}=", value)
|
record.send("#{attr_name}=", value)
|
||||||
yield record, value
|
yield record, value
|
||||||
end
|
end
|
||||||
|
|||||||
22
spec/validates_timeliness/railtie_spec.rb
Normal file
22
spec/validates_timeliness/railtie_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
require 'validates_timeliness/railtie'
|
||||||
|
|
||||||
|
RSpec.describe ValidatesTimeliness::Railtie do
|
||||||
|
context "intializers" do
|
||||||
|
context "validates_timeliness.initialize_timeliness_ambiguous_date_format" do
|
||||||
|
it 'should set the timeliness default ambiguous date format from the current format' do
|
||||||
|
expect(Timeliness.configuration.ambiguous_date_format).to eq :us
|
||||||
|
ValidatesTimeliness.parser.use_euro_formats
|
||||||
|
|
||||||
|
initializer("validates_timeliness.initialize_timeliness_ambiguous_date_format").run
|
||||||
|
|
||||||
|
expect(Timeliness.configuration.ambiguous_date_format).to eq :euro
|
||||||
|
end
|
||||||
|
end if Timeliness.respond_to?(:ambiguous_date_format)
|
||||||
|
|
||||||
|
def initializer(name)
|
||||||
|
ValidatesTimeliness::Railtie.initializers.find { |i|
|
||||||
|
i.name == name
|
||||||
|
} || raise("Initializer #{name} not found")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user