From bb2cdffea2e178d39449e274cf03157dbbd769d9 Mon Sep 17 00:00:00 2001 From: Manfred Stienstra Date: Fri, 17 Oct 2025 09:10:01 +0200 Subject: [PATCH 1/3] Small edits to the README. --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 804dca2..6cd2723 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,17 @@ See [Postgres collation documentation](https://www.postgresql.org/docs/current/c ## Setup -Add `activerecord-collations` to your dependencies. If you also want the `collate` class method on your model you also include the collation module: +Add `activerecord-collations` to your dependencies. Include the collation concern into your models to get access to the `collate` class method. ```ruby class ApplicationRecord < ActiveRecord::Base - self.abstract_class = true + primary_abstract_class include ActiveRecord::Collation end ``` -The collate method creates an ARel expression for the column with a certain collation. +The `collate` method creates an ARel expression for the column with a certain collation. ```ruby scope :ordered, -> { order(collate(:title, "natural_#{I18n.locale}") } @@ -45,11 +45,11 @@ Arel::Nodes::InfixOperation.new( ) ``` -## Testing +## Development -The Dummy application uses the gem so you can load the schema and run migrations there: +Run tests in this repository with `rake`. Migrations are exercised by running them in the dummy application. ``` cd test/dummy -RAILS_ENV=test rake db:migrate +rm -f db/schema.rb && RAILS_ENV=test rake db:drop db:create db:migrate ``` From 732f02922bde9c5848560ae09dccf489f4b6c5d4 Mon Sep 17 00:00:00 2001 From: Manfred Stienstra Date: Fri, 17 Oct 2025 10:21:55 +0200 Subject: [PATCH 2/3] Ignore vendor so RuboCop runs on CI. --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 9bac860..ebe5235 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,7 @@ AllCops: TargetRubyVersion: 3.3 Exclude: - test/dummy/db/schema.rb + - vendor/**/* Layout/LineLength: Max: 100 Metrics/BlockLength: From b002b5dccd192eb678f9edec0a5b51dc01dd8942 Mon Sep 17 00:00:00 2001 From: Manfred Stienstra Date: Fri, 17 Oct 2025 09:09:32 +0200 Subject: [PATCH 3/3] Add test workflow for running on GitHub. --- .github/workflows/test.yml | 36 ++++++++++++++++++++++++++++++++++ test/dummy/config/database.yml | 2 ++ 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fa7bb06 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +on: [push] +env: + # Sets the superuser username and password for PostgreSQL. + POSTGRES_USER: github + POSTGRES_PASSWORD: oiz5FeebOosh6aet +jobs: + build: + strategy: + matrix: + ruby_version: ["3.4", "3.3"] + runs-on: ubuntu-latest + services: + postgres: + image: postgres:17 + env: + # Default database that is created when the image is first started. + POSTGRES_DB: active_record_collation_test + # This is so dumb… + POSTGRES_USER: ${{ env.POSTGRES_USER }} + POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - uses: actions/checkout@v5 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true + - run: bundle exec rubocop + - run: cd test/dummy && rm -f db/schema.rb && RAILS_ENV=test bundle exec rake db:drop db:create db:migrate + - run: bundle exec rake test diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index 077f773..a572209 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -4,3 +4,5 @@ test: host: localhost pool: 16 database: active_record_collation_test + user: <%= ENV.fetch("POSTGRES_USER", nil) %> + password: <%= ENV.fetch("POSTGRES_PASSWORD", nil) %>