Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support postGIS adapter for postgreSQL #1183

Merged
merged 1 commit into from
Nov 20, 2023
Merged
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
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 adapter for PostgreSQL. ([@Dania02525][])
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