mongoid-tags-arent-hard 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -8,12 +8,13 @@ module Mongoid
|
|
8
8
|
module ClassMethods
|
9
9
|
|
10
10
|
def taggable_with(name, options = {})
|
11
|
-
options = {separator: Mongoid::TagsArentHard.config.separator}.merge(options)
|
11
|
+
options = {separator: Mongoid::TagsArentHard.config.separator, _name: name}.merge(options)
|
12
12
|
self.field(name, type: Array, default: [])
|
13
13
|
self.class_eval do
|
14
14
|
define_method(name) do
|
15
15
|
val = super()
|
16
16
|
unless val.is_a?(Mongoid::TagsArentHard::Tags)
|
17
|
+
options.merge!(owner: self)
|
17
18
|
val = Mongoid::TagsArentHard::Tags.new(val, options)
|
18
19
|
self.send("#{name}=", val)
|
19
20
|
end
|
@@ -21,6 +22,7 @@ module Mongoid
|
|
21
22
|
end
|
22
23
|
define_method("#{name}=") do |val|
|
23
24
|
unless val.is_a?(Mongoid::TagsArentHard::Tags)
|
25
|
+
options.merge!(owner: self)
|
24
26
|
val = Mongoid::TagsArentHard::Tags.new(val, options)
|
25
27
|
end
|
26
28
|
super(val)
|
@@ -78,6 +78,19 @@ describe Mongoid::TagsArentHard do
|
|
78
78
|
|
79
79
|
end
|
80
80
|
|
81
|
+
describe 'changes' do
|
82
|
+
|
83
|
+
it "tracks changes correctly" do
|
84
|
+
foo.save!
|
85
|
+
foo.reload
|
86
|
+
foo.send("#{_name}=", [])
|
87
|
+
foo.send(_name) << ["foo", "bar"]
|
88
|
+
changes = foo.changes
|
89
|
+
changes[_name.to_s].should eql([[], ["foo", "bar"]])
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
81
94
|
context 'class scopes' do
|
82
95
|
|
83
96
|
before(:each) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-tags-arent-hard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|