Skip to content
Open
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
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
source 'https://rubygems.org'

gem 'rake'
gem 'mongoid', '~> 7'
gem 'mongoid', '~> 9'

group :test do
gem 'rspec', '~> 2'
gem 'rdoc'
gem 'database_cleaner'
gem 'database_cleaner-mongoid'
end
4 changes: 3 additions & 1 deletion lib/mongoid/taggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ module Mongoid::Taggable

# add callback to save tags index
after_save do |document|
document.class.save_tags_index! if document.tags_array_changed?
# Use previously_changed? as Mongoid 8.x+ updates attributes before after_save so changed? returns false here
# see: https://www.mongodb.com/docs/mongoid/8.1/release-notes/mongoid-8.0/#changeable-module-behavior-made-compatible-with-activemodel--dirty
document.class.save_tags_index! if document.tags_array_previously_changed?
end

# enable indexing as default
Expand Down
2 changes: 1 addition & 1 deletion mongoid_taggable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Gem::Specification.new do |g|
g.require_paths = ['lib']

g.add_runtime_dependency 'rake', '>= 0'
g.add_runtime_dependency 'mongoid', '~> 7'
g.add_runtime_dependency 'mongoid', '~> 9'
end
7 changes: 3 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
$: << File.expand_path("../../lib", __FILE__)

require 'database_cleaner'
require 'database_cleaner-mongoid'

RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner[:mongoid].strategy = :deletion
end

config.after(:each) do
DatabaseCleaner.clean
DatabaseCleaner[:mongoid].clean
end
end

require 'mongoid'
require 'mongoid_taggable'

Mongoid.load!("spec/mongoid.yml", :test)