mongoid 8.0.13 → 8.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/spec_helper.rb CHANGED
@@ -28,6 +28,14 @@ def database_id_alt
28
28
  "mongoid_test_alt"
29
29
  end
30
30
 
31
+ def test_model(name: 'TestModel', &block)
32
+ Class.new.tap do |klass|
33
+ klass.define_singleton_method(:name) { name.to_s }
34
+ klass.include Mongoid::Document
35
+ klass.class_eval(&block) if block_given?
36
+ end
37
+ end
38
+
31
39
  begin
32
40
  require 'mrss/cluster_config'
33
41
  require 'support/client_registry'
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DeleteAllAccount
4
+ include Mongoid::Document
5
+
6
+ has_many :items, class_name: 'DeleteAllItem', foreign_key: :account_id, inverse_of: :account,
7
+ scope: -> { where(:state.in => %w[draft open]) }
8
+ has_many :scoped_items, class_name: 'DeleteAllScopedItem', foreign_key: :account_id, inverse_of: :account
9
+ has_and_belongs_to_many :tags, class_name: 'DeleteAllTag', inverse_of: nil
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DeleteAllItem
4
+ include Mongoid::Document
5
+
6
+ field :state, type: String
7
+
8
+ belongs_to :account, class_name: 'DeleteAllAccount', inverse_of: :items
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DeleteAllScopedItem
4
+ include Mongoid::Document
5
+
6
+ field :state, type: String
7
+
8
+ belongs_to :account, class_name: 'DeleteAllAccount', inverse_of: :scoped_items
9
+
10
+ default_scope -> { where(:state.in => %w[draft open]) }
11
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DeleteAllTag
4
+ include Mongoid::Document
5
+
6
+ field :state, type: String
7
+ end