mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 23:33:00 +00:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93b8b1a70b | ||
|
|
e531c8f8ef | ||
|
|
658deca1c8 | ||
|
|
a6d617e77d | ||
|
|
101bb5d5f7 | ||
|
|
5e6e5222dc | ||
|
|
c81ec5d604 | ||
|
|
f3f3d01db7 | ||
|
|
acd9fc13e4 | ||
|
|
5743d87bc7 | ||
|
|
e0790bca9b | ||
|
|
39f698feb2 | ||
|
|
bd39aef4fb | ||
|
|
a3431bc91a | ||
|
|
fda194584a | ||
|
|
a05f091a42 | ||
|
|
faf708e3be | ||
|
|
38bb74844d | ||
|
|
e275b63203 | ||
|
|
e73e0eb30f | ||
|
|
43554d8bf0 | ||
|
|
da473b7eea | ||
|
|
fc2af73656 | ||
|
|
936c853fdd | ||
|
|
f27324a404 | ||
|
|
4221bf7709 | ||
|
|
b51a4544ff | ||
|
|
285bc769ba | ||
|
|
a0f2759c7a | ||
|
|
cc57b1b758 | ||
|
|
d30cebfc7b | ||
|
|
a96c24268d | ||
|
|
13fcc32a83 | ||
|
|
e8a96fe9b5 | ||
|
|
f9009995fc | ||
|
|
5419a1cc42 | ||
|
|
9dd2e87087 | ||
|
|
8a04deebfa | ||
|
|
e9c9914c4f | ||
|
|
0219c3850d | ||
|
|
35caf3638e | ||
|
|
153051730b | ||
|
|
5c1406e9b0 | ||
|
|
32f92cc885 |
28
.travis.yml
28
.travis.yml
@@ -1,16 +1,26 @@
|
||||
language: ruby
|
||||
before_install:
|
||||
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
||||
- gem install bundler -v '< 2'
|
||||
before_script:
|
||||
- bundle install
|
||||
cache: bundler
|
||||
bundler_args: --verbose
|
||||
|
||||
gemfile:
|
||||
- gemfiles/rails_4_0.gemfile
|
||||
- gemfiles/rails_4_1.gemfile
|
||||
- gemfiles/rails_4_2.gemfile
|
||||
matrix:
|
||||
include:
|
||||
- rvm: "2.3.7"
|
||||
gemfile: gemfiles/rails_4_0.gemfile
|
||||
- rvm: "2.3.7"
|
||||
gemfile: gemfiles/rails_4_1.gemfile
|
||||
- rvm: "2.3.7"
|
||||
gemfile: gemfiles/rails_4_2.gemfile
|
||||
- rvm: "2.4.6"
|
||||
gemfile: gemfiles/rails_4_2.gemfile
|
||||
- rvm: "2.5.5"
|
||||
gemfile: gemfiles/rails_4_2.gemfile
|
||||
|
||||
rvm:
|
||||
- "2.2.3"
|
||||
- "2.3.0"
|
||||
|
||||
script: 'bundle exec rake'
|
||||
script: 'bundle exec rspec'
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
@@ -7,5 +7,5 @@ appraise "rails_4_1" do
|
||||
end
|
||||
|
||||
appraise "rails_4_2" do
|
||||
gem "rails", "~> 4.2.5"
|
||||
gem "rails", "~> 4.2.11"
|
||||
end
|
||||
@@ -1,3 +1,15 @@
|
||||
= 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]
|
||||
* Fix undefine_generated_methods ivar guard setting to false
|
||||
|
||||
= 4.0.1 [2016-01-06]
|
||||
* Fix undefine_generated_methods thread locking bug
|
||||
* Created an ActiveModel ORM, for manual require if using without any full blown ORM
|
||||
|
||||
= 4.0.0 [2015-12-29]
|
||||
* Extracted mongoid support into https://github.com/adzap/validates_timeliness-mongoid which is broken (not supported anymore).
|
||||
* Fixed Rails 4.0, 4.1 and 4.2 compatability issues
|
||||
|
||||
15
Gemfile
15
Gemfile
@@ -1,16 +1,13 @@
|
||||
source 'http://rubygems.org'
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gemspec
|
||||
|
||||
gem 'rails', '~> 4.0.13'
|
||||
gem 'rspec', '~> 3.4.0'
|
||||
gem 'rspec-rails', '~> 3.4.0'
|
||||
gem 'rake'
|
||||
gem 'rails', '~> 4.2.11.1'
|
||||
gem 'rspec'
|
||||
gem 'rspec-rails', '~> 3.7'
|
||||
gem 'timecop'
|
||||
gem 'byebug'
|
||||
gem 'appraisal'
|
||||
gem 'sqlite3'
|
||||
gem 'nokogiri', '1.6.7'
|
||||
|
||||
group :active_record do
|
||||
gem 'sqlite3-ruby', :require => 'sqlite3'
|
||||
end
|
||||
gem 'nokogiri', '~> 1.8'
|
||||
|
||||
@@ -22,7 +22,7 @@ If you a looking for the old version for Rails 3.x go here[http://github.com/adz
|
||||
|
||||
* Adds extensions to fix Rails date/time select issues (See Extensions)
|
||||
|
||||
* Supports I18n for the error messages
|
||||
* Supports I18n for the error messages. For multi-language support try {timeliness-i18n gem}[https://github.com/pedrofurtado/timeliness-i18n].
|
||||
|
||||
* Supports all the Rubies (that any sane person would be using in production).
|
||||
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
# This file was generated by Appraisal
|
||||
|
||||
source "http://rubygems.org"
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "rails", "~> 4.0.0"
|
||||
gem "rspec", "~> 3.0.0"
|
||||
gem "rspec-rails", "~> 3.0.0"
|
||||
gem "rails", "~> 4.0.13"
|
||||
gem "rspec", "~> 3.6.0"
|
||||
gem "rspec-rails", "~> 3.6.0"
|
||||
gem "timecop"
|
||||
gem "rspec_tag_matchers"
|
||||
gem "byebug"
|
||||
gem "appraisal"
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.0"
|
||||
gem "nokogiri", "1.6.7"
|
||||
|
||||
group :active_record do
|
||||
gem "sqlite3-ruby", :require => "sqlite3"
|
||||
end
|
||||
|
||||
gemspec :path => "../"
|
||||
gemspec path: "../"
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
# This file was generated by Appraisal
|
||||
|
||||
source "http://rubygems.org"
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "rails", "~> 4.1.0"
|
||||
gem "rspec", "~> 3.0.0"
|
||||
gem "rspec-rails", "~> 3.0.0"
|
||||
gem "rails", "~> 4.1.14"
|
||||
gem "rspec", "~> 3.6.0"
|
||||
gem "rspec-rails", "~> 3.6.0"
|
||||
gem "timecop"
|
||||
gem "rspec_tag_matchers"
|
||||
gem "byebug"
|
||||
gem "appraisal"
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.0"
|
||||
gem "nokogiri", "1.6.7"
|
||||
|
||||
group :active_record do
|
||||
gem "sqlite3-ruby", :require => "sqlite3"
|
||||
end
|
||||
|
||||
gemspec :path => "../"
|
||||
gemspec path: "../"
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
# This file was generated by Appraisal
|
||||
|
||||
source "http://rubygems.org"
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "rails", "~> 4.2.0"
|
||||
gem "rspec", "~> 3.0.0"
|
||||
gem "rspec-rails", "~> 3.0.0"
|
||||
gem "rails", "~> 4.2.8"
|
||||
gem "rspec", "~> 3.6.0"
|
||||
gem "rspec-rails", "~> 3.6.0"
|
||||
gem "timecop"
|
||||
gem "rspec_tag_matchers"
|
||||
gem "byebug"
|
||||
gem "appraisal"
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.0"
|
||||
gem "nokogiri", "1.6.7"
|
||||
|
||||
group :active_record do
|
||||
gem "sqlite3-ruby", :require => "sqlite3"
|
||||
end
|
||||
|
||||
gemspec :path => "../"
|
||||
gemspec path: "../"
|
||||
|
||||
@@ -53,7 +53,7 @@ module ValidatesTimeliness
|
||||
generated_timeliness_methods.synchronize do
|
||||
return unless @timeliness_methods_generated
|
||||
undefine_timeliness_attribute_methods
|
||||
@timeliness_methods_generated = true
|
||||
@timeliness_methods_generated = false
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@@ -56,7 +56,7 @@ module ValidatesTimeliness
|
||||
end
|
||||
|
||||
# Rails 4.0 compatibility for old #setup method with class as arg
|
||||
if ActiveModel.version <= Gem::Version.new('4.1')
|
||||
if Gem::Version.new(ActiveModel::VERSION::STRING) <= Gem::Version.new('4.1')
|
||||
alias_method(:setup, :setup_timeliness_validated_attributes)
|
||||
end
|
||||
|
||||
@@ -91,7 +91,7 @@ module ValidatesTimeliness
|
||||
|
||||
def add_error(record, attr_name, message, value=nil)
|
||||
value = format_error_value(value) if value
|
||||
message_options = { :message => options[:"#{message}_message"], :restriction => value }
|
||||
message_options = { :message => options.fetch(:"#{message}_message", options[:message]), :restriction => value }
|
||||
record.errors.add(attr_name, message, message_options)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module ValidatesTimeliness
|
||||
VERSION = '4.0.1'
|
||||
VERSION = '4.1.0'
|
||||
end
|
||||
|
||||
@@ -71,8 +71,8 @@ end
|
||||
class Employee < ActiveRecord::Base
|
||||
attr_accessor :redefined_birth_date_called
|
||||
validates_date :birth_date, :allow_nil => true
|
||||
validates_date :birth_time, :allow_nil => true
|
||||
validates_date :birth_datetime, :allow_nil => true
|
||||
validates_time :birth_time, :allow_nil => true
|
||||
validates_datetime :birth_datetime, :allow_nil => true
|
||||
|
||||
def birth_date=(value)
|
||||
self.redefined_birth_date_called = true
|
||||
|
||||
@@ -241,8 +241,14 @@ RSpec.describe ValidatesTimeliness, 'ActiveRecord' do
|
||||
end
|
||||
|
||||
context "undefine_attribute_methods" do
|
||||
it "returns a falsy value if the attribute methods have already been generated" do
|
||||
expect { Employee.undefine_attribute_methods }.to_not raise_error
|
||||
it "returns remove attribute methods that have already been generated" do
|
||||
Employee.define_attribute_methods
|
||||
|
||||
expect(Employee.instance_methods).to include(:birth_datetime)
|
||||
|
||||
Employee.undefine_attribute_methods
|
||||
|
||||
expect(Employee.instance_methods).to_not include(:birth_datetime)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,6 +87,20 @@ RSpec.describe ValidatesTimeliness::Validator do
|
||||
end
|
||||
end
|
||||
|
||||
describe ':message options' do
|
||||
it 'should allow message option too' do
|
||||
Person.validates_date :birth_date, on_or_after: :today, message: 'cannot be in past'
|
||||
invalid!(:birth_date, Date.today - 5.days, 'cannot be in past')
|
||||
valid!(:birth_date, Date.today)
|
||||
end
|
||||
|
||||
it 'should first allow the defined message' do
|
||||
Person.validates_date :birth_date, on_or_after: :today, on_or_after_message: 'cannot be in past', message: 'dummy message'
|
||||
invalid!(:birth_date, Date.today - 5.days, 'cannot be in past')
|
||||
valid!(:birth_date, Date.today)
|
||||
end
|
||||
end
|
||||
|
||||
describe ":between option" do
|
||||
describe "array value" do
|
||||
it 'should be split option into :on_or_after and :on_or_before values' do
|
||||
|
||||
@@ -10,11 +10,12 @@ Gem::Specification.new do |s|
|
||||
s.description = %q{Adds validation methods to ActiveModel for validating dates and times. Works with multiple ORMS.}
|
||||
s.email = %q{adam.meehan@gmail.com}
|
||||
s.homepage = %q{http://github.com/adzap/validates_timeliness}
|
||||
s.license = "MIT"
|
||||
|
||||
s.require_paths = ["lib"]
|
||||
s.files = `git ls-files`.split("\n") - %w{ .gitignore .rspec Gemfile Gemfile.lock autotest/discover.rb Appraisals Travis.yml } - Dir['gemsfiles/*']
|
||||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "LICENSE"]
|
||||
|
||||
s.add_runtime_dependency(%q<timeliness>, ["~> 0.3.7"])
|
||||
s.add_runtime_dependency(%q<timeliness>, [">= 0.3.10", "< 1"])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user