mongoid-clerk 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +5 -4
- data/lib/clerk/logger.rb +6 -1
- data/lib/clerk/version.rb +1 -1
- data/spec/mongoid-clerk/logger_spec.rb +35 -0
- data/spec/spec_helper.rb +2 -2
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -46,12 +46,13 @@ example model:
|
|
46
46
|
|
47
47
|
end
|
48
48
|
|
49
|
+
## Testing
|
49
50
|
|
51
|
+
Start foreman and run the tests with `rake`
|
50
52
|
|
51
53
|
## Contributing
|
52
54
|
|
53
55
|
1. Fork it
|
54
|
-
2.
|
55
|
-
3.
|
56
|
-
4.
|
57
|
-
5. Create new Pull Request
|
56
|
+
2. Fix it
|
57
|
+
3. Push it
|
58
|
+
4. Pullreq it
|
data/lib/clerk/logger.rb
CHANGED
@@ -4,7 +4,12 @@ module Clerk::Logger
|
|
4
4
|
module ClassMethods
|
5
5
|
|
6
6
|
def default_fields
|
7
|
-
@default_fields ||=
|
7
|
+
@default_fields ||=
|
8
|
+
if superclass.respond_to?(:default_fields)
|
9
|
+
superclass.default_fields.dup
|
10
|
+
else
|
11
|
+
{}
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
15
|
def clerk_always_include(*new_default_fields)
|
data/lib/clerk/version.rb
CHANGED
@@ -6,11 +6,19 @@ class MongoidDocumentWithClerk
|
|
6
6
|
|
7
7
|
field :name
|
8
8
|
field :address
|
9
|
+
field :phone
|
9
10
|
|
10
11
|
clerk_always_include :name, :address => :place
|
11
12
|
|
12
13
|
end
|
13
14
|
|
15
|
+
class InheritedMongoidDocumentWithClerk < MongoidDocumentWithClerk
|
16
|
+
end
|
17
|
+
|
18
|
+
class InheritedOverriddenMongoidDocumentWithClerk < MongoidDocumentWithClerk
|
19
|
+
clerk_always_include :phone => :tel
|
20
|
+
end
|
21
|
+
|
14
22
|
describe MongoidDocumentWithClerk do
|
15
23
|
|
16
24
|
context "class methods" do
|
@@ -89,3 +97,30 @@ describe MongoidDocumentWithClerk do
|
|
89
97
|
end
|
90
98
|
|
91
99
|
end
|
100
|
+
|
101
|
+
describe InheritedMongoidDocumentWithClerk do
|
102
|
+
|
103
|
+
describe "inherited default fields" do
|
104
|
+
subject { InheritedMongoidDocumentWithClerk.default_fields }
|
105
|
+
|
106
|
+
it "should contain the field mapping" do
|
107
|
+
should == {:name => :name, :address => :place}
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
describe InheritedOverriddenMongoidDocumentWithClerk do
|
116
|
+
|
117
|
+
describe "inherited default fields" do
|
118
|
+
subject { InheritedOverriddenMongoidDocumentWithClerk.default_fields }
|
119
|
+
|
120
|
+
it "should contain the field mapping with additions" do
|
121
|
+
should == {:name => :name, :address => :place, :phone => :tel}
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,11 +5,12 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
5
5
|
|
6
6
|
require 'active_support/all'
|
7
7
|
require 'mongoid'
|
8
|
-
require 'mongo'
|
9
8
|
require 'uri'
|
10
9
|
require 'mongoid-rspec'
|
11
10
|
|
11
|
+
|
12
12
|
mongoid_config = YAML.load_file(File.join(File.dirname(__FILE__),"mongoid.yml"))['test']
|
13
|
+
|
13
14
|
Mongoid.configure do |config|
|
14
15
|
if !mongoid_config['uri'].blank?
|
15
16
|
config.master = Mongo::Connection.from_uri(mongoid_config['uri']).db(mongoid_config['uri'].split('/').last)
|
@@ -18,7 +19,6 @@ Mongoid.configure do |config|
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
22
|
RSpec.configure do |config|
|
23
23
|
config.mock_with :rspec
|
24
24
|
config.include Mongoid::Matchers
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-clerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-08-
|
12
|
+
date: 2012-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|