diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7a9c08e..678cdf3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: - { ruby: '4.0', mongoid: '9', mongodb: '8.0', bundler: default } env: MONGOID_VERSION: ${{ matrix.mongoid }} - COVERAGE: ${{ matrix.ruby == '4.0' && 'true' || 'false' }} + COVERAGE: ${{ (matrix.mongoid == '~> 3.1.0' || matrix.ruby == '4.0') && 'true' || 'false' }} services: mongodb: image: mongo:${{ matrix.mongodb }} @@ -43,12 +43,24 @@ jobs: bundler-cache: true - run: bundle exec rake spec - name: Report coverage to Coveralls - if: matrix.ruby == '4.0' + if: matrix.mongoid == '~> 3.1.0' || matrix.ruby == '4.0' uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} file: coverage/.resultset.json format: simplecov + parallel: true + flag-name: ruby-${{ matrix.ruby }} + + coverage: + needs: test + if: ${{ always() && needs.test.result == 'success' }} + runs-on: ubuntu-latest + steps: + - uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true lint: runs-on: ubuntu-22.04 diff --git a/CHANGELOG.md b/CHANGELOG.md index f3dde02..88c6af3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 0.9.0 (Next) +* [#68](https://github.com/mongoid/mongoid_fulltext/pull/68): Cover candidate-budget boundaries and standalone version loading, and combine coverage from actual legacy and modern drivers - [@dblock](https://github.com/dblock). * [#61](https://github.com/mongoid/mongoid_fulltext/pull/61): Support weighted fields with configurable maximum or summed field-score aggregation - [@dblock](https://github.com/dblock). * [#60](https://github.com/mongoid/mongoid_fulltext/pull/60): Extract ngram calculation and index-definition planning for maintainability without changing model APIs or search behavior - [@tomasc](https://github.com/tomasc), [@dblock](https://github.com/dblock). * [#59](https://github.com/mongoid/mongoid_fulltext/pull/59): Document and cover class-level indexing timeout options - [@dblock](https://github.com/dblock). diff --git a/Gemfile b/Gemfile index 48006aa..7983b31 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ group :test do gem 'database_cleaner', '~> 1.8' end gem 'rspec' - gem 'simplecov', '~> 0.22', require: false if ENV['COVERAGE'] == 'true' + gem 'simplecov', RUBY_VERSION < '2.5' ? '~> 0.16.0' : '~> 0.22', require: false if ENV['COVERAGE'] == 'true' end group :development do diff --git a/spec/mongoid/candidate_limits_spec.rb b/spec/mongoid/candidate_limits_spec.rb new file mode 100644 index 0000000..b0f1215 --- /dev/null +++ b/spec/mongoid/candidate_limits_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'Full-text candidate limits' do + it 'bounds initial candidates and continues with limited candidates for later ngrams' do + config = BasicArtwork.mongoid_fulltext_config.values.first + original = config[:max_candidate_set_size] + begin + config[:max_candidate_set_size] = 1 + artworks = 2.times.map { BasicArtwork.create!(title: 'alphabet beta') } + + results = BasicArtwork.fulltext_search('alphabet beta', max_results: 1, return_scores: true) + expect(results.length).to eq(1) + expect(artworks).to include(results.first.first) + expect(results.first.last).to be > 0 + ensure + config[:max_candidate_set_size] = original + end + end +end diff --git a/spec/version_spec.rb b/spec/version_spec.rb new file mode 100644 index 0000000..a750f27 --- /dev/null +++ b/spec/version_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe Mongoid::FullTextSearch do + it 'loads a standalone semantic version' do + stub_const('Mongoid::FullTextSearch', Module.new) + load File.expand_path('../lib/mongoid/full_text_search/version.rb', __dir__) + expect(Mongoid::FullTextSearch::VERSION).to match(/\A\d+\.\d+\.\d+\z/) + end +end