Skip to content
This repository was archived by the owner on Aug 7, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ end
appraise "rails_5_0" do
gem "rails", "~> 5.0.0"
end

appraise "rails_5_1" do
gem "rails", "~> 5.1.0"
end

appraise "rails_5_2" do
gem "rails", "~> 5.2.0"
end
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ gem 'timecop'
gem 'appraisal'
gem 'sqlite3'
gem 'nokogiri'

group :active_record do
gem 'sqlite3-ruby', :require => 'sqlite3'
end
2 changes: 1 addition & 1 deletion ae-validates_timeliness.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |s|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_runtime_dependency(%q<rails>, [">= 4.0", "< 5.1"])
s.add_runtime_dependency(%q<rails>, [">= 4.0", "< 5.3"])
s.add_runtime_dependency(%q<timeliness>, ["~> 0.3.7"])

s.add_development_dependency "coveralls"
Expand Down
6 changes: 1 addition & 5 deletions gemfiles/rails_4_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ gem "appraisal"
gem "sqlite3"
gem "nokogiri"

group :active_record do
gem "sqlite3-ruby", :require => "sqlite3"
end

gemspec :path => "../"
gemspec path: "../"
6 changes: 1 addition & 5 deletions gemfiles/rails_4_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ gem "appraisal"
gem "sqlite3"
gem "nokogiri"

group :active_record do
gem "sqlite3-ruby", :require => "sqlite3"
end

gemspec :path => "../"
gemspec path: "../"
6 changes: 1 addition & 5 deletions gemfiles/rails_4_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ gem "appraisal"
gem "sqlite3"
gem "nokogiri"

group :active_record do
gem "sqlite3-ruby", :require => "sqlite3"
end

gemspec :path => "../"
gemspec path: "../"
6 changes: 1 addition & 5 deletions gemfiles/rails_5_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ gem "appraisal"
gem "sqlite3"
gem "nokogiri"

group :active_record do
gem "sqlite3-ruby", :require => "sqlite3"
end

gemspec :path => "../"
gemspec path: "../"
11 changes: 11 additions & 0 deletions gemfiles/rails_5_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "rails", "~> 5.1.0"
gem "timecop"
gem "appraisal"
gem "sqlite3"
gem "nokogiri"

gemspec path: "../"
11 changes: 11 additions & 0 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "rails", "~> 5.2.0"
gem "timecop"
gem "appraisal"
gem "sqlite3"
gem "nokogiri"

gemspec path: "../"
16 changes: 12 additions & 4 deletions lib/validates_timeliness/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ def timeliness_column_for_attribute(attr_name)
::ActiveRecord::ConnectionAdapters::Column.new(attr_name, nil, validation_type.to_s)
else
connection = ::ActiveRecord::Base.connection
arguments = if ::ActiveRecord.version > ::Gem::Version.new('4.3')
[attr_name, nil, connection.send(:fetch_type_metadata, validation_type.to_s), validation_type.to_s, table_name]
sql_type = validation_type.to_s
cast_type = begin
if ::ActiveRecord.version < ::Gem::Version.new('5')
connection.send(:lookup_cast_type, sql_type)
else
[attr_name, nil, connection.lookup_cast_type(validation_type.to_s), validation_type.to_s]
connection.send(:fetch_type_metadata, sql_type)
end
connection.new_column(*arguments)
end

if ::ActiveRecord.version < ::Gem::Version.new('5.1')
connection.send(:new_column, attr_name, nil, cast_type, sql_type, table_name)
else
connection.send(:new_column_from_field, table_name, { 'name' => attr_name, 'type' => sql_type })
end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class PersonWithShim < Person

ActiveRecord::Base.default_timezone = :utc
ActiveRecord::Base.time_zone_aware_attributes = true
if ActiveRecord.version >= Gem::Version.new('5')
ActiveRecord::Base.time_zone_aware_types = [:datetime]
end
ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:'})
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define(:version => 1) do
Expand Down