Skip to content
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
44 changes: 30 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,22 @@ name: CI RSpec Test
on: [push, pull_request]

jobs:
rubocop:
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/checkout@v3
- name: Set up Ruby 3.4
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.4
bundler-cache: true
- name: Run RuboCop
run: bundle exec rubocop --parallel

build:
name: >-
${{ matrix.ruby }}
name: "${{ matrix.ruby }} mongoid-${{ matrix.mongoid }}"
env:
CI: true
TESTOPTS: -v
Expand All @@ -14,17 +27,24 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.7, 3.0, 3.1, 3.2]
mongoid: [7, 8]
ruby:
- ruby-2.7
- ruby-3.0
- ruby-3.1
- ruby-3.2
- ruby-3.3
- ruby-3.4
- ruby-4.0
mongoid: [8, 9]
experimental: [false]
include:
- ruby: 3.2
- ruby: ruby-3.2
mongoid: HEAD
experimental: true
- ruby: head
- ruby: ruby-head
mongoid: 7
experimental: true
- ruby: head
- ruby: ruby-head
mongoid: HEAD
experimental: true
- ruby: jruby
Expand All @@ -33,6 +53,9 @@ jobs:
- ruby: jruby-head
mongoid: 8
experimental: true
- ruby: truffleruby-head
mongoid: 7
experimental: true

steps:
- name: repo checkout
Expand All @@ -55,13 +78,6 @@ jobs:
env:
MONGOID_VERSION: ${{ matrix.mongoid }}

- name: rubocop
timeout-minutes: 5
run: bundle exec rubocop
continue-on-error: ${{ matrix.experimental }}
env:
MONGOID_VERSION: ${{ matrix.mongoid }}

- name: test
timeout-minutes: 10
run: bundle exec rake spec
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [#274](https://github.com/mongoid/mongoid-slug/pull/274): Added support for scoping slugs by multiple fields - [@mikekosulin](https://github.com/mikekosulin).
* [#279](https://github.com/mongoid/mongoid-slug/pull/279): Replace deprecated `__find_args__` with `Array#flatten` - [@samiFakhfakhScalingo](https://github.com/samiFakhfakhScalingo), [@aurelien-reeves-scalingo](https://github.com/aurelien-reeves-scalingo).
* Your contribution here.
* [#281](https://github.com/mongoid/mongoid-slug/pull/281): Add ruby 4.0 to the ci - [@aurelien-reeves-scalingo](https://github.com/aurelien-reeves-scalingo).

## 7.0.0 (2023/09/18)

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ end
gem 'danger', require: false
gem 'danger-changelog', require: false
gem 'danger-pr-comment', require: false
gem 'ostruct'
gem 'rake'
gem 'rspec'
gem 'rspec-its'
Expand Down
12 changes: 5 additions & 7 deletions lib/mongoid/slug/unique_slug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def regex_for_slug
end

def uniqueness_scope
if embedded?
parent_metadata = reflect_on_all_association(:embedded_in)[0]
return model._parent.send(parent_metadata.inverse_of || metadata.name)
end

# If slug_scope is present, we need to handle whether it's a single scope or multiple scopes.
if slug_scope
# We'll track individual scope results in an array.
Expand Down Expand Up @@ -190,13 +195,6 @@ def uniqueness_scope
return model.class
end

# The rest of your method remains unchanged, handling cases where slug_scope isn't defined.
# This is your existing logic for embedded models or deeper superclass retrieval.
if embedded?
parent_metadata = reflect_on_all_association(:embedded_in)[0]
return model._parent.send(parent_metadata.inverse_of || self.metadata.name)
end

# Unless embedded or slug scope, return the deepest document superclass.
appropriate_class = model.class
appropriate_class = appropriate_class.superclass while appropriate_class.superclass.include?(Mongoid::Document)
Expand Down
Loading