Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Oct 17, 2024
1 parent ac74f4e commit 96eb346
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Run Tests
run: bundle exec rake test
env:
PGHOST: 127.0.0.1
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
TESTOPTS: --profile=3
Expand Down
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ gemspec

gem "pg", "~> 1.0", platform: :ruby
gem "byebug" if ENV["BYEBUG"]
gem "tracer"

def activerecord_version
return ENV["AR_VERSION"] if ENV["AR_VERSION"]
Expand Down Expand Up @@ -39,8 +38,4 @@ group :development do
gem "bcrypt"
gem "sqlite3"
gem "msgpack"

# Still used a little bit in our tests.
# TODO: get rid of the dependency
gem "mocha"
end
3 changes: 2 additions & 1 deletion activerecord-postgis-adapter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
spec.files = Dir["lib/**/*", "LICENSE.txt"]
spec.platform = Gem::Platform::RUBY

# # ruby-lang.org/en/downloads/branches
# ruby-lang.org/en/downloads/branches
spec.required_ruby_version = ">= 3.1.0"

spec.add_dependency "activerecord", "~> 7.2.0"
Expand All @@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rubocop", "~> 1.50"

spec.metadata = {
"funding_uri" => "https://opencollective.com/rgeo",
"rubygems_mfa_required" => "true"
}
end
26 changes: 1 addition & 25 deletions lib/active_record/connection_adapters/postgis/oid/spatial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,10 @@ def self.parse_sql_type(sql_type)
end

def spatial_factory
return @spatial_factory if defined?(@spatial_factory)
@spatial_factory =
@spatial_factory ||=
RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
factory_attrs
)

if @srid != @spatial_factory.srid
puts
puts "INITIALIZATION ERROR"
puts
end

# Tracer is waaay too noisy
# require "tracer"
# Tracer.trace(@spatial_factory)
@spatial_factory
end

def spatial?
Expand All @@ -83,18 +71,6 @@ def type
def serialize(value)
return if value.nil?
geo_value = cast_value(value)
if spatial_factory.srid != @srid
$something_wrong = true
puts ?* * 100
puts "@geo_type: #{@geo_type}"
puts "type.to_s: #{type.to_s}"
puts "@srid: #{@srid}"
p spatial_factory # It has srid=0 when bugged
p value
p geo_value
puts
puts
end

# TODO - only valid types should be allowed
# e.g. linestring is not valid for point column
Expand Down
2 changes: 1 addition & 1 deletion test/cases/ddl_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_no_query_spatial_column_info

# `SpatialColumnInfo#all` queries column info from the database.
# It should not be called when klass.columns is called
assert_queries_count(0) do
assert_no_queries do
# first column is id, second is name
refute klass.columns[1].spatial?
assert_nil klass.columns[1].has_z
Expand Down
2 changes: 1 addition & 1 deletion test/rake_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def activerecord_test_files
.map { |file| File.join ar_root, file.strip }
.sort
.prepend(POSTGIS_TEST_HELPER)
.then{ FileList[*_1] }
.then { FileList[*_1] }
else
FileList["#{ar_root}/test/cases/**/*_test.rb"]
.reject { _1.include?("/adapters/") || _1.include?("/encryption/performance") }
Expand Down
13 changes: 0 additions & 13 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,10 @@ def time_it
end
end

$something_wrong = false
$last_test = nil
module ActiveSupport
class TestCase
include TestTimeoutHelper

teardown do
if $something_wrong
puts
puts "SOMETHING WRONG in test #{name.inspect}"
puts "ran after #{$last_test.inspect}"
puts
$something_wrong = false
end
$last_test = name
end

def factory(srid: 3785)
RGeo::Cartesian.preferred_factory(srid: srid)
end
Expand Down

0 comments on commit 96eb346

Please sign in to comment.