Skip to content

Commit

Permalink
support postGIS adapter for postgreSQL
Browse files Browse the repository at this point in the history
remove puts

rename changelog

change wording in changelog

update pr number

Update lib/rubocop/cop/rails/bulk_change_table.rb

Co-authored-by: Koichi ITO <koic.ito@gmail.com>
  • Loading branch information
Dania02525 and koic committed Nov 17, 2023
1 parent c176f6b commit bdcc1a9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/new_support_postgis_adapter_for_postgresql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#1183](https://github.com/rubocop/rubocop-rails/pull/1183): Support PostGIS adapater for PostgreSQL. ([@Dania02525][])

Check failure on line 1 in changelog/new_support_postgis_adapter_for_postgresql.md

View workflow job for this annotation

GitHub Actions / Check spelling of all files with codespell

adapater ==> adapter
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_rails.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ the PostgreSQL (5.2 later) adapter; thus it will
automatically detect an adapter from `development` environment
in `config/database.yml` or the environment variable `DATABASE_URL`
when the `Database` option is not set.
If the adapter is not `mysql2`, `trilogy`, or `postgresql`,
If the adapter is not `mysql2`, `trilogy`, `postgresql`, or `postgis`,
this Cop ignores offenses.

=== Examples
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/database_type_resolvable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def database_from_yaml
case database_adapter
when 'mysql2', 'trilogy'
MYSQL
when 'postgresql'
when 'postgresql', 'postgis'
POSTGRESQL
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/bulk_change_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Rails
# automatically detect an adapter from `development` environment
# in `config/database.yml` or the environment variable `DATABASE_URL`
# when the `Database` option is not set.
# If the adapter is not `mysql2`, `trilogy`, or `postgresql`,
# If the adapter is not `mysql2`, `trilogy`, `postgresql`, or `postgis`,
# this Cop ignores offenses.
#
# @example
Expand Down
40 changes: 40 additions & 0 deletions spec/rubocop/cop/rails/bulk_change_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,46 @@ def change
end
end

context 'postgis' do
context 'with top-level adapter configuration' do
let(:yaml) do
{
'development' => {
'adapter' => 'postgis'
}
}
end

context 'with Rails 5.2', :rails52 do
it_behaves_like 'offense for postgresql'
end

context 'with Rails 5.1', :rails51 do
it_behaves_like 'no offense for postgresql'
end
end

context 'with nested adapter configuration' do
let(:yaml) do
{
'development' => {
'primary' => {
'adapter' => 'postgis'
}
}
}
end

context 'with Rails 5.2', :rails52 do
it_behaves_like 'offense for postgresql'
end

context 'with Rails 5.1', :rails51 do
it_behaves_like 'no offense for postgresql'
end
end
end

context 'invalid (e.g. ERB)' do
before do
allow(YAML).to receive(:load_file).with('config/database.yml') do
Expand Down

0 comments on commit bdcc1a9

Please sign in to comment.