Skip to content

Commit

Permalink
Added code coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Sep 7, 2024
1 parent caf7889 commit 1d67515
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 11 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ jobs:
run: bundle exec rspec
- name: Run examples
run: bundle exec ruby examples/feed.rb
- name: Report Coverage
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true

upload-coverage:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Upload Code Coverage Report
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
coverage
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [#44](https://github.com/mongoid/mongoid-scroll/pull/44): Drop support for Mogoid 5 and Mongo Ruby Driver - [@dblock](https://github.com/dblock).
* [#45](https://github.com/mongoid/mongoid-scroll/pull/45): Add support for Mogoid 9 - [@dblock](https://github.com/dblock).
* [#46](https://github.com/mongoid/mongoid-scroll/pull/46): Upgrade RuboCop to 1.66.1 - [@dblock](https://github.com/dblock).
* [#47](https://github.com/mongoid/mongoid-scroll/pull/47): Add code coverage - [@dblock](https://github.com/dblock).
* Your contribution here.

### 1.0.1 (2023/03/15)
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ end

group :development, :test do
gem 'bundler'
gem 'coveralls_reborn', require: false
gem 'database_cleaner', '~> 1.8.5'
gem 'faker'
gem 'mongoid-danger', '~> 0.2.0', require: false
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

[![Gem Version](https://badge.fury.io/rb/mongoid-scroll.svg)](https://badge.fury.io/rb/mongoid-scroll)
[![Build Status](https://github.com/mongoid/mongoid-scroll/actions/workflows/ci.yml/badge.svg)](https://github.com/mongoid/mongoid-scroll/actions/workflows/ci.yml)
[![Dependency Status](https://gemnasium.com/mongoid/mongoid-scroll.svg)](https://gemnasium.com/mongoid/mongoid-scroll)
[![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid-scroll/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid-scroll?branch=master)
[![Code Climate](https://codeclimate.com/github/mongoid/mongoid-scroll.svg)](https://codeclimate.com/github/mongoid/mongoid-scroll)

Mongoid extension that enables infinite scrolling for `Mongoid::Criteria` and `Mongo::Collection::View`.
Expand Down
1 change: 0 additions & 1 deletion examples/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require 'faker'

Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5?
Mongoid.connect_to 'mongoid_scroll_demo'
Mongoid.purge!

Expand Down
1 change: 0 additions & 1 deletion lib/mongoid-scroll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
I18n.load_path << File.join(File.dirname(__FILE__), 'config', 'locales', 'en.yml')

require 'mongoid'
require 'mongoid-compatibility'
require 'mongoid/scroll/version'
require 'mongoid/scroll/errors'
require 'mongoid/scroll/base_cursor'
Expand Down
6 changes: 1 addition & 5 deletions lib/mongoid/scroll/base_cursor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ def criteria
mongo_value = value.class.mongoize(value) if value
cursor_criteria = { field_name => { compare_direction => mongo_value } } if mongo_value
tiebreak_criteria = { field_name => mongo_value, :_id => { tiebreak_compare_direction => tiebreak_id } } if mongo_value && tiebreak_id
cursor_selector = if Mongoid::Compatibility::Version.mongoid6_or_newer?
Mongoid::Criteria::Queryable::Selector.new
else
Origin::Selector.new
end
cursor_selector = Mongoid::Criteria::Queryable::Selector.new
cursor_selector['$or'] = [cursor_criteria, tiebreak_criteria].compact if cursor_criteria || tiebreak_criteria
cursor_selector.__evolve_object_id__
end
Expand Down
1 change: 0 additions & 1 deletion mongoid-scroll.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ Gem::Specification.new do |s|
s.summary = 'Mongoid extensions to enable infinite scroll.'
s.add_dependency 'i18n'
s.add_dependency 'mongoid', '>= 6.0'
s.add_dependency 'mongoid-compatibility'
s.metadata['rubygems_mfa_required'] = 'true'
end
7 changes: 6 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))

require 'coveralls'
Coveralls.wear! do
add_filter 'spec'
end

require 'rubygems'
require 'rspec'
require 'rspec/its'
Expand All @@ -20,7 +25,7 @@
RSpec.configure do |config|
config.before :all do
Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5_or_newer?
Mongo::Logger.logger.level = Logger::INFO
end
config.before do
DatabaseCleaner.clean
Expand Down
2 changes: 1 addition & 1 deletion spec/support/feed/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Item
embeds_many :embedded_items, class_name: 'Feed::EmbeddedItem'

publisher_options = { class_name: 'Feed::Publisher' }
publisher_options[:optional] = true if Mongoid::Compatibility::Version.mongoid6_or_newer?
publisher_options[:optional] = true
belongs_to :publisher, publisher_options
end
end

0 comments on commit 1d67515

Please sign in to comment.