diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5c06215e0..70f14c226 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -408,7 +408,7 @@ Lint/ShadowingOuterLocalVariable: # Offense count: 20 Metrics/AbcSize: - Max: 139 + Max: 141 # Offense count: 28 # Configuration parameters: CountComments, ExcludedMethods. diff --git a/lib/annotate/annotate_models.rb b/lib/annotate/annotate_models.rb index 9e6f306ab..d3c0a5502 100644 --- a/lib/annotate/annotate_models.rb +++ b/lib/annotate/annotate_models.rb @@ -264,7 +264,7 @@ def get_schema_info(klass, header, options = {}) if col_type == 'decimal' col_type << "(#{col.precision}, #{col.scale})" - elsif col_type != 'spatial' + elsif !%w[spatial geometry geography].include?(col_type) if col.limit if col.limit.is_a? Array attrs << "(#{col.limit.join(', ')})" diff --git a/spec/lib/annotate/annotate_models_spec.rb b/spec/lib/annotate/annotate_models_spec.rb index d537fe343..1c906b2d5 100644 --- a/spec/lib/annotate/annotate_models_spec.rb +++ b/spec/lib/annotate/annotate_models_spec.rb @@ -1055,6 +1055,32 @@ def self.when_called_with(options = {}) # EOS + mocked_columns_with_geometries = [ + [:id, :integer, { limit: 8 }], + [:active, :boolean, { default: false, null: false }], + [:geometry, :geometry, { + geometric_type: 'Geometry', srid: 4326, + limit: { srid: 4326, type: 'geometry' } + }], + [:location, :geography, { + geometric_type: 'Point', srid: 0, + limit: { srid: 0, type: 'geometry' } + }] + ] + + when_called_with with_columns: mocked_columns_with_geometries, returns: + <<-EOS.strip_heredoc + # Schema Info + # + # Table name: users + # + # id :integer not null, primary key + # active :boolean default(FALSE), not null + # geometry :geometry not null, geometry, 4326 + # location :geography not null, point, 0 + # + EOS + it 'should get schema info as RDoc' do klass = mock_class(:users, :id,