mongoid_monkey 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/mongoid_monkey.rb +1 -0
- data/lib/patches/embedded_touch.rb +37 -0
- data/lib/version.rb +1 -1
- data/spec/unit/atomic/mongoid3_style/atomic/add_to_set_spec.rb +266 -266
- data/spec/unit/atomic/mongoid3_style/atomic/bit_spec.rb +92 -92
- data/spec/unit/atomic/mongoid3_style/atomic/inc_spec.rb +137 -137
- data/spec/unit/atomic/mongoid3_style/atomic/pop_spec.rb +115 -115
- data/spec/unit/atomic/mongoid3_style/atomic/pull_all_spec.rb +81 -81
- data/spec/unit/atomic/mongoid3_style/atomic/pull_spec.rb +84 -84
- data/spec/unit/atomic/mongoid3_style/atomic/push_all_spec.rb +81 -81
- data/spec/unit/atomic/mongoid3_style/atomic/push_spec.rb +81 -81
- data/spec/unit/atomic/mongoid3_style/atomic/rename_spec.rb +46 -46
- data/spec/unit/atomic/mongoid3_style/atomic/sets_spec.rb +158 -158
- data/spec/unit/atomic/mongoid3_style/atomic/unset_spec.rb +69 -69
- data/spec/unit/atomic/mongoid3_style/atomic_spec.rb +220 -220
- data/spec/unit/atomic/mongoid4_style/incrementable_spec.rb +232 -232
- data/spec/unit/atomic/mongoid4_style/logical_spec.rb +262 -262
- data/spec/unit/atomic/mongoid4_style/poppable_spec.rb +139 -139
- data/spec/unit/atomic/mongoid4_style/pullable_spec.rb +172 -172
- data/spec/unit/atomic/mongoid4_style/pushable_spec.rb +159 -159
- data/spec/unit/atomic/mongoid4_style/renamable_spec.rb +139 -139
- data/spec/unit/atomic/mongoid4_style/unsettable_spec.rb +28 -28
- data/spec/unit/embedded_touch_spec.rb +52 -0
- data/spec/unit/{only_pluck_localized.rb → only_pluck_localized_spec.rb} +0 -0
- metadata +7 -4
@@ -1,28 +1,28 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
if Mongoid::VERSION =~ /\A3\./
|
4
|
-
|
5
|
-
describe "A document loaded from rails" do
|
6
|
-
before(:all) do
|
7
|
-
require 'mongoid/railties/document'
|
8
|
-
end
|
9
|
-
|
10
|
-
after(:all) do
|
11
|
-
Mongoid::Document.class_eval do
|
12
|
-
undef _destroy
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it "defines a _destroy method" do
|
17
|
-
expect(Person.new).to respond_to(:_destroy)
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#_destroy" do
|
21
|
-
|
22
|
-
it "always returns false" do
|
23
|
-
expect(Person.new._destroy).to be false
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if Mongoid::VERSION =~ /\A3\./
|
4
|
+
|
5
|
+
describe "A document loaded from rails" do
|
6
|
+
before(:all) do
|
7
|
+
require 'mongoid/railties/document'
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
Mongoid::Document.class_eval do
|
12
|
+
undef _destroy
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "defines a _destroy method" do
|
17
|
+
expect(Person.new).to respond_to(:_destroy)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#_destroy" do
|
21
|
+
|
22
|
+
it "always returns false" do
|
23
|
+
expect(Person.new._destroy).to be false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
if Mongoid::VERSION =~ /\A3\./
|
4
|
+
|
5
|
+
class Edit
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps::Updated
|
8
|
+
embedded_in :wiki_page, touch: true
|
9
|
+
end
|
10
|
+
|
11
|
+
class WikiPage
|
12
|
+
include Mongoid::Document
|
13
|
+
include Mongoid::Timestamps
|
14
|
+
|
15
|
+
field :title, type: String
|
16
|
+
|
17
|
+
embeds_many :edits, validate: false
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Mongoid::Relations::Embedded::In do
|
21
|
+
|
22
|
+
describe ".valid_options" do
|
23
|
+
|
24
|
+
it "returns the valid options" do
|
25
|
+
expect(described_class.valid_options).to eq([ :autobuild, :cyclic, :polymorphic, :touch ])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Mongoid::Relations::Touchable do
|
31
|
+
|
32
|
+
context "when the relation is a parent of an embedded doc" do
|
33
|
+
|
34
|
+
let(:page) do
|
35
|
+
WikiPage.create(title: "test")
|
36
|
+
end
|
37
|
+
|
38
|
+
let!(:edit) do
|
39
|
+
page.edits.create
|
40
|
+
end
|
41
|
+
|
42
|
+
before do
|
43
|
+
page.unset(:updated_at)
|
44
|
+
edit.touch
|
45
|
+
end
|
46
|
+
|
47
|
+
it "touches the parent document" do
|
48
|
+
expect(page.updated_at).to be_within(5).of(Time.now)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_monkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- johnnyshields
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/patches/atomic.rb
|
67
67
|
- lib/patches/big_decimal.rb
|
68
68
|
- lib/patches/db_commands.rb
|
69
|
+
- lib/patches/embedded_touch.rb
|
69
70
|
- lib/patches/instrument.rb
|
70
71
|
- lib/patches/only_pluck_localized.rb
|
71
72
|
- lib/patches/reorder.rb
|
@@ -110,8 +111,9 @@ files:
|
|
110
111
|
- spec/unit/db_commands/mongoid4_tasks_spec.rb
|
111
112
|
- spec/unit/db_commands/moped_database_spec.rb
|
112
113
|
- spec/unit/db_commands/moped_indexes_spec.rb
|
114
|
+
- spec/unit/embedded_touch_spec.rb
|
113
115
|
- spec/unit/instrument_spec.rb
|
114
|
-
- spec/unit/
|
116
|
+
- spec/unit/only_pluck_localized_spec.rb
|
115
117
|
- spec/unit/reorder_spec.rb
|
116
118
|
homepage: https://github.com/johnnyshields/mongoid_monkey
|
117
119
|
licenses:
|
@@ -178,6 +180,7 @@ test_files:
|
|
178
180
|
- spec/unit/db_commands/mongoid4_tasks_spec.rb
|
179
181
|
- spec/unit/db_commands/moped_database_spec.rb
|
180
182
|
- spec/unit/db_commands/moped_indexes_spec.rb
|
183
|
+
- spec/unit/embedded_touch_spec.rb
|
181
184
|
- spec/unit/instrument_spec.rb
|
182
|
-
- spec/unit/
|
185
|
+
- spec/unit/only_pluck_localized_spec.rb
|
183
186
|
- spec/unit/reorder_spec.rb
|