-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #363 from rgeo/activerecord-tests
Test Against ActiveRecord
- Loading branch information
Showing
27 changed files
with
1,374 additions
and
988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ Gemfile.lock | |
/travis/*.lock | ||
/test/database_local.yml | ||
.idea | ||
debug.log | ||
/test/db/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,45 @@ | ||
require "bundler/gem_tasks" | ||
require "rake/testtask" | ||
require_relative "test/rake_helper" | ||
|
||
task default: [:test] | ||
task test: "test:postgis" | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.libs << "test" | ||
t.test_files = %w(test/**/*_test.rb) | ||
Rake::TestTask.new(:test_postgis) do |t| | ||
t.libs << postgis_test_load_paths | ||
t.test_files = postgis_test_files | ||
t.verbose = false | ||
end | ||
|
||
Rake::TestTask.new(:test_activerecord) do |t| | ||
t.libs << postgis_test_load_paths | ||
t.test_files = activerecord_test_files | ||
t.verbose = false | ||
end | ||
|
||
Rake::TestTask.new(:test_all) do |t| | ||
t.libs << postgis_test_load_paths | ||
t.test_files = all_test_files | ||
t.verbose = false | ||
end | ||
|
||
# We invoke the tests from here so we can add environment varaible(s) | ||
# necessary for ActiveRecord tests. TestTask.new runs its block | ||
# regardless of whether it has been invoked or not, so environment | ||
# variables cannot be set in there if they're only needed for specific | ||
# tests. | ||
namespace :test do | ||
task :postgis do | ||
Rake::Task["test_postgis"].invoke | ||
end | ||
|
||
task :activerecord do | ||
ENV["ARCONN"] = "postgis" | ||
Rake::Task["test_activerecord"].invoke | ||
end | ||
|
||
task :all do | ||
ENV["ARCONN"] = "postgis" | ||
Rake::Task["test_all"].invoke | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
lib/active_record/connection_adapters/postgis/oid/date_time.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActiveRecord | ||
module ConnectionAdapters | ||
module PostGIS | ||
module OID | ||
module DateTime | ||
protected | ||
|
||
# Uses PostGIS instead of PostgreSQLAdapter | ||
def real_type_unless_aliased(real_type) | ||
ActiveRecord::ConnectionAdapters::PostGISAdapter.datetime_type == real_type ? :datetime : real_type | ||
end | ||
end | ||
|
||
PostgreSQL::OID::DateTime.prepend(DateTime) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.