mongoid-tags-arent-hard 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c07a5ad9f79751620008650dd735bf2901a4175
|
4
|
+
data.tar.gz: 6144978084a1704c7acdf8f07b2895d3f95b60cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d0b6ed31ce2833dc05c85fb0e572b6ff7664db0d03fe499a5ac72c61ba07cdc4103828db566ab0fb0cedcd1061f7fe6b79ef013a92dcf7eb7a69f595347ec7de
|
7
|
+
data.tar.gz: 7009e6674ce1405500b287d653d6a9b8de7e86194b09c88d223174ce40c2f9f21a8a4f39ae420671dcce68ed3a7e1280b7fdd203cc5f72ead3c1088a17c9b4d3
|
data/README.md
CHANGED
@@ -105,7 +105,8 @@ Again, notice that you can use either a string, an array, or a splatted list as
|
|
105
105
|
## Contributers
|
106
106
|
|
107
107
|
* Mark Bates
|
108
|
-
*
|
108
|
+
* Dave South
|
109
109
|
* Luke Bergen
|
110
|
-
*
|
111
|
-
* thomas morgan
|
110
|
+
* Carsten Block
|
111
|
+
* thomas morgan
|
112
|
+
* Laurent Arnoud
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Mongoid
|
2
2
|
module TagsArentHard
|
3
|
-
|
3
|
+
|
4
4
|
def self.included(klass)
|
5
5
|
klass.extend(ClassMethods)
|
6
6
|
end
|
7
7
|
|
8
8
|
module ClassMethods
|
9
|
-
|
9
|
+
|
10
10
|
def taggable_with(name, options = {})
|
11
11
|
options = {separator: Mongoid::TagsArentHard.config.separator, _name: name}.merge(options)
|
12
12
|
self.field(name, type: Mongoid::TagsArentHard::Tags, default: Mongoid::TagsArentHard::Tags.new([], options))
|
@@ -34,7 +34,7 @@ module Mongoid
|
|
34
34
|
end
|
35
35
|
|
36
36
|
self.class.send(:define_method, "all_#{name}") do
|
37
|
-
|
37
|
+
all.distinct(name.to_s)
|
38
38
|
end
|
39
39
|
|
40
40
|
|
@@ -6,12 +6,15 @@ class Foo
|
|
6
6
|
|
7
7
|
field :label
|
8
8
|
|
9
|
+
field :account, default: 'a'
|
10
|
+
default_scope ->{ where(account: 'a') }
|
11
|
+
|
9
12
|
taggable_with :tags
|
10
13
|
taggable_with :colors, separator: ";"
|
11
14
|
end
|
12
15
|
|
13
16
|
describe Mongoid::TagsArentHard do
|
14
|
-
|
17
|
+
|
15
18
|
let(:foo) { Foo.new }
|
16
19
|
|
17
20
|
{tags: ",", colors: ";"}.each do |_name, _separator|
|
@@ -32,11 +35,11 @@ describe Mongoid::TagsArentHard do
|
|
32
35
|
foo.send("#{_name}=", ["foo", "bar"])
|
33
36
|
foo.send(_name).should eql(["foo","bar"])
|
34
37
|
end
|
35
|
-
|
38
|
+
|
36
39
|
end
|
37
40
|
|
38
41
|
describe '#save' do
|
39
|
-
|
42
|
+
|
40
43
|
it "saves the #{_name} correctly" do
|
41
44
|
foo.send("#{_name}=", "foo#{_separator}bar")
|
42
45
|
foo.save!
|
@@ -47,7 +50,7 @@ describe Mongoid::TagsArentHard do
|
|
47
50
|
end
|
48
51
|
|
49
52
|
describe '+=' do
|
50
|
-
|
53
|
+
|
51
54
|
it "adds and replaces using a string" do
|
52
55
|
foo.send("#{_name}=", ["foo", "bar"])
|
53
56
|
foo.send(_name).should eql(["foo","bar"])
|
@@ -81,7 +84,7 @@ describe Mongoid::TagsArentHard do
|
|
81
84
|
end
|
82
85
|
|
83
86
|
describe 'changes' do
|
84
|
-
|
87
|
+
|
85
88
|
it "tracks changes correctly" do
|
86
89
|
foo.save!
|
87
90
|
foo.reload
|
@@ -93,6 +96,23 @@ describe Mongoid::TagsArentHard do
|
|
93
96
|
|
94
97
|
end
|
95
98
|
|
99
|
+
context "default scope" do
|
100
|
+
before(:each) do
|
101
|
+
@foo1 = Foo.create!(_name => "a#{_separator}b#{_separator}c", :account => 'b')
|
102
|
+
@foo2 = Foo.create!(_name => "b#{_separator}c#{_separator}f", :account => 'a')
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "all_#{_name}" do
|
106
|
+
it "returns tags per account scope" do
|
107
|
+
results = Foo.send("all_#{_name}")
|
108
|
+
results.length.should be(3)
|
109
|
+
results.should include 'b'
|
110
|
+
results.should include 'c'
|
111
|
+
results.should include 'f'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
96
116
|
context 'class scopes' do
|
97
117
|
|
98
118
|
before(:each) do
|
@@ -124,7 +144,7 @@ describe Mongoid::TagsArentHard do
|
|
124
144
|
end
|
125
145
|
|
126
146
|
describe "with_#{_name}" do
|
127
|
-
|
147
|
+
|
128
148
|
it "returns all models with a specific #{_name} (splatted)" do
|
129
149
|
results = Foo.send("with_#{_name}", "a")
|
130
150
|
results.should have(1).foo
|
@@ -150,7 +170,7 @@ describe Mongoid::TagsArentHard do
|
|
150
170
|
end
|
151
171
|
|
152
172
|
describe "with_any_#{_name}" do
|
153
|
-
|
173
|
+
|
154
174
|
it "returns all models with any #{_name} (splatted)" do
|
155
175
|
results = Foo.send("with_any_#{_name}", "a")
|
156
176
|
results.should have(1).foo
|
@@ -202,7 +222,7 @@ describe Mongoid::TagsArentHard do
|
|
202
222
|
end
|
203
223
|
|
204
224
|
describe "with_all_#{_name}" do
|
205
|
-
|
225
|
+
|
206
226
|
it "returns all models with all #{_name} (splatted)" do
|
207
227
|
results = Foo.send("with_all_#{_name}", "a")
|
208
228
|
results.should have(1).foo
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-tags-arent-hard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Mark Bates
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-07-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: mongoid
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.0.0
|
30
27
|
description: A tagging gem for Mongoid 3 that doesn't actually suck.
|
@@ -51,30 +48,30 @@ files:
|
|
51
48
|
- spec/tags_arent_hard/tags_spec.rb
|
52
49
|
homepage: ''
|
53
50
|
licenses: []
|
51
|
+
metadata: {}
|
54
52
|
post_install_message:
|
55
53
|
rdoc_options: []
|
56
54
|
require_paths:
|
57
55
|
- lib
|
58
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
57
|
requirements:
|
61
|
-
- -
|
58
|
+
- - '>='
|
62
59
|
- !ruby/object:Gem::Version
|
63
60
|
version: '0'
|
64
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
62
|
requirements:
|
67
|
-
- -
|
63
|
+
- - '>='
|
68
64
|
- !ruby/object:Gem::Version
|
69
65
|
version: '0'
|
70
66
|
requirements: []
|
71
67
|
rubyforge_project:
|
72
|
-
rubygems_version:
|
68
|
+
rubygems_version: 2.0.3
|
73
69
|
signing_key:
|
74
|
-
specification_version:
|
70
|
+
specification_version: 4
|
75
71
|
summary: A tagging gem for Mongoid 3 that doesn't actually suck.
|
76
72
|
test_files:
|
77
73
|
- spec/config.yml
|
78
74
|
- spec/spec_helper.rb
|
79
75
|
- spec/tags_arent_hard/tags_arent_hard_spec.rb
|
80
76
|
- spec/tags_arent_hard/tags_spec.rb
|
77
|
+
has_rdoc:
|