File tree Expand file tree Collapse file tree 3 files changed +37
-18
lines changed
Expand file tree Collapse file tree 3 files changed +37
-18
lines changed Original file line number Diff line number Diff line change 33require 'patches/atomic'
44require 'patches/big_decimal'
55require 'patches/db_commands'
6+ require 'patches/index_options'
67require 'patches/instrument'
78require 'patches/reorder'
89require 'patches/only_pluck_localized'
Original file line number Diff line number Diff line change 1- # Backport Mongoid 4 :touch option for #embedded_in to Mongoid 3.
1+ # Backport Mongoid 6 index options to Mongoid 3 and 4 .
22
33if Mongoid ::VERSION =~ /\A 3\. /
44
5- module Mongoid
6- module Indexes
7- module Validators
8-
9- module Options
5+ ::Mongoid ::Indexes ::Validators ::Options . send ( :remove_const , :VALID_OPTIONS )
6+ module Mongoid ::Indexes ::Validators ::Options
107 VALID_OPTIONS = [
118 :background ,
129 :database ,
@@ -30,17 +27,11 @@ module Options
3027 :collation
3128 ]
3229 end
33- end
34- end
35- end
3630
3731elsif Mongoid ::VERSION =~ /\A 4\. /
3832
39- module Mongoid
40- module Indexable
41- module Validators
42-
43- module Options
33+ ::Mongoid ::Indexable ::Validators ::Options . send ( :remove_const , :VALID_OPTIONS )
34+ module Mongoid ::Indexable ::Validators ::Options
4435 VALID_OPTIONS = [
4536 :background ,
4637 :database ,
@@ -65,7 +56,3 @@ module Options
6556 ]
6657 end
6758end
68- end
69- end
70-
71- end
Original file line number Diff line number Diff line change 1+ require "spec_helper"
2+
3+ if Mongoid ::VERSION =~ /\A [34]\. /
4+
5+ describe 'Index Valid Options' do
6+ let ( :mod ) { Mongoid ::VERSION =~ /\A 3\. / ? Mongoid ::Indexes ::Validators : Mongoid ::Indexable ::Validators }
7+ let ( :exp ) do
8+ [ :background ,
9+ :database ,
10+ :default_language ,
11+ :language_override ,
12+ :drop_dups ,
13+ :name ,
14+ :sparse ,
15+ :unique ,
16+ :max ,
17+ :min ,
18+ :bits ,
19+ :bucket_size ,
20+ :expire_after_seconds ,
21+ :weights ,
22+ :storage_engine ,
23+ :sphere_version ,
24+ :text_version ,
25+ :version ,
26+ :partial_filter_expression ,
27+ :collation ]
28+ end
29+ it { expect ( mod ::Options ::VALID_OPTIONS ) . to eq ( exp ) }
30+ end
31+ end
You can’t perform that action at this time.
0 commit comments