Repository navigation
QUAL-2627: Add CI matrix and Mongoid 8 compatibility #13
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| ruby: ['3.0', '3.2'] | ||
| mongoid: ['7_4', '8_0', '8_1'] | ||
| env: | ||
| BUNDLE_GEMFILE: gemfiles/mongoid_${{ matrix.mongoid }}.gemfile | ||
| CI: 'true' | ||
| services: | ||
| mongo: | ||
| image: mongo:7.0 | ||
| ports: | ||
| - 27017:27017 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: ${{ matrix.ruby }} | ||
| bundler-cache: true | ||
| - run: bundle exec rspec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,4 @@ tmp | |
| *.o | ||
| *.a | ||
| mkmf.log | ||
| gemfiles/*.gemfile.lock | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| source 'https://rubygems.org' | ||
|
|
||
| gem 'mongoid', '~> 7.4.0' | ||
|
|
||
| gemspec path: '..' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| source 'https://rubygems.org' | ||
|
|
||
| gem 'mongoid', '~> 8.0.0' | ||
|
|
||
| gemspec path: '..' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| source 'https://rubygems.org' | ||
|
|
||
| gem 'mongoid', '~> 8.1.0' | ||
|
|
||
| gemspec path: '..' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| module Mongoidal | ||
| VERSION = "0.2.6" | ||
| VERSION = "0.3.0" | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| require 'spec_helper' | ||
|
|
||
| class BulkParent | ||
| include Mongoid::Document | ||
| include Mongoidal::BulkSavable | ||
| field :name, type: String | ||
| embeds_many :kids, class_name: 'BulkKid' | ||
| end | ||
|
|
||
| class BulkKid | ||
| include Mongoid::Document | ||
| embedded_in :bulk_parent | ||
| field :name, type: String | ||
| end | ||
|
|
||
| describe Mongoidal::BulkSavable do | ||
| let(:parent) { BulkParent.create(name: 'Parent') } | ||
| let!(:kid1) { parent.kids.create(name: 'Kid 1') } | ||
| let!(:kid2) { parent.kids.create(name: 'Kid 2') } | ||
|
|
||
| # with no embeds given, every embeds_many relation is used | ||
| it 'updates, adds and flags deletes across embeds_many relations' do | ||
| to_delete = parent.bulk_assign( | ||
| 'name' => 'Renamed', | ||
| 'kids' => [ | ||
| { 'id' => kid1.id.to_s, 'name' => 'Kid 1b' }, | ||
| { 'id' => kid2.id.to_s, 'deleted' => true }, | ||
| { 'name' => 'Kid 3' } | ||
| ] | ||
| ) | ||
|
|
||
| expect(parent.name).to eq 'Renamed' | ||
| expect(parent.kids.map(&:name)).to match_array ['Kid 1b', 'Kid 2', 'Kid 3'] | ||
| expect(to_delete).to eq [kid2] | ||
| end | ||
|
|
||
| it 'accepts an explicit list of embeds' do | ||
| parent.bulk_assign({ kids: [{ id: kid1.id, name: 'Kid 1b' }] }, :kids) | ||
| expect(parent.kids.find(kid1.id).name).to eq 'Kid 1b' | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| require 'spec_helper' | ||
|
|
||
| class GidParent | ||
| include Mongoid::Document | ||
| include Mongoidal::Identification | ||
| field :name, type: String | ||
| embeds_many :kids, class_name: 'GidKid' | ||
| end | ||
|
|
||
| class GidKid | ||
| include Mongoid::Document | ||
| include Mongoidal::Identification | ||
| embedded_in :gid_parent | ||
| field :name, type: String | ||
| end | ||
|
|
||
| GlobalID.app = 'mongoidal' | ||
|
|
||
| describe Mongoidal::Identification do | ||
| let(:parent) { GidParent.create(name: 'Parent') } | ||
| let(:kid) { parent.kids.create(name: 'Kid') } | ||
|
|
||
| def locate(doc) | ||
| Mongoidal::Locator.new(GlobalID.parse(doc.to_global_id.to_s)).locate | ||
| end | ||
|
|
||
| it 'round trips a root document' do | ||
| expect(locate(parent)).to eq parent | ||
| end | ||
|
|
||
| it 'round trips an embedded document through its root' do | ||
| expect(locate(kid)).to eq kid | ||
| end | ||
|
|
||
| it 'rebuilds a destroyed embedded document from its attributes' do | ||
| kid.destroy | ||
| gid = kid.to_global_id.to_s | ||
| found = Mongoidal::Locator.new(GlobalID.parse(gid)).locate | ||
| expect(found.name).to eq 'Kid' | ||
| expect(found).to be_destroyed | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.