rails-ext 0.3.6 → 0.3.8

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.
Files changed (37) hide show
  1. data/.git/index +0 -0
  2. data/.git/logs/HEAD +4 -0
  3. data/.git/logs/refs/heads/master +4 -0
  4. data/.git/logs/refs/remotes/origin/master +3 -0
  5. data/.git/objects/02/12d2da342b1ab3c0e7a7f2770686a7bb5d7806 +0 -0
  6. data/.git/objects/05/38f41ddebf7fa8c71ebe99c5288d5e11c3fb86 +0 -0
  7. data/.git/objects/2c/b04524ccd690f1cb4345586ca9138f9615afd5 +0 -0
  8. data/.git/objects/35/0b6a89c8f9704cb4f1e037ea638e952a487017 +0 -0
  9. data/.git/objects/3b/da284efc6c07900db7dd00a9f3082d2c13d55e +0 -0
  10. data/.git/objects/3d/e882c2630c3cd215641a6c73ca83ad2d741b13 +0 -0
  11. data/.git/objects/43/6b9b73da4632657be4800b250741f37fdbb505 +0 -0
  12. data/.git/objects/55/45d0d521bb723db8feae0223fa838a183e38b7 +0 -0
  13. data/.git/objects/5d/c38b1f2d3893c8e41b05de2d121b525f888e5c +0 -0
  14. data/.git/objects/6a/02fd5698264a4165c46af5175a39f5b130de9c +0 -0
  15. data/.git/objects/83/fa8aa3ad64de1003adc5a1c7c31c3d98a7abf4 +0 -0
  16. data/.git/objects/84/bfc21516dfc947e9aa64a47000b46da2c801d9 +0 -0
  17. data/.git/objects/8f/53b7b2ab88b130763bc42b3ded7983d27bff7a +0 -0
  18. data/.git/objects/94/ba2c1a45bc1a8cf3625f4889c507b39c664576 +0 -0
  19. data/.git/objects/99/368683bd721c6c1b8db8eb1b468dffefa61a2e +0 -0
  20. data/.git/objects/af/33f2833588e40e441f8b1f4dd26d5c93488334 +0 -0
  21. data/.git/objects/b1/8a3c6bf39b910b9805973578074e6d6b692a4a +0 -0
  22. data/.git/objects/b4/343d9284a89e2971022f8d4acf7865d8341c6d +0 -0
  23. data/.git/objects/d8/bd32eafc1bcd962f7e2e1244071c921cd465fe +0 -0
  24. data/.git/objects/dc/0bcf757c5c24befef5c59eb7ec1589cfed184d +0 -0
  25. data/.git/objects/e0/7dd2a6b90bdde86477d621148f47bbba9e8427 +0 -0
  26. data/.git/objects/e3/153285548db5d39a615acbf0748cfa21e96ecb +0 -0
  27. data/.git/objects/f5/8ca6b23d3ab90715ea6ba514546a416e50064e +0 -0
  28. data/.git/objects/f8/9eb17d4ff10a745b70063cf5b8ff76ec66e102 +0 -0
  29. data/.git/refs/heads/master +1 -1
  30. data/.git/refs/remotes/origin/master +1 -1
  31. data/Rakefile +1 -1
  32. data/lib/mongo_mapper_ext/plugins/default_scope.rb +42 -6
  33. data/lib/rails_ext/active_support/micelaneous.rb +1 -1
  34. data/lib/rails_ext/asset_packager/action_view.rb +2 -1
  35. data/spec/mongo_mapper_ext/scope_spec.rb +118 -0
  36. metadata +28 -4
  37. data/spec/mongo_mapper_ext/default_scope_spec.rb +0 -62
data/.git/index CHANGED
Binary file
data/.git/logs/HEAD CHANGED
@@ -55,3 +55,7 @@ d4faaed37686ae3ce16b636defd37eeacb38470d 978c0ddb7dbecadce5fbc740347598999ccc822
55
55
  978c0ddb7dbecadce5fbc740347598999ccc8223 804a20e92f38623945cdb50ed8864d014632cf44 alex <alex@amac.local> 1269602049 +0300 commit: upd
56
56
  804a20e92f38623945cdb50ed8864d014632cf44 161cacdd64a4f135d805f5a2f23d006592b8c835 alex <alex@amac.local> 1269602071 +0300 commit: upd
57
57
  161cacdd64a4f135d805f5a2f23d006592b8c835 a3ece30fb5827ed20d26a75253bb4854f657055a alex <alex@amac.local> 1269602138 +0300 commit: upd
58
+ a3ece30fb5827ed20d26a75253bb4854f657055a 0538f41ddebf7fa8c71ebe99c5288d5e11c3fb86 alex <alex@amac.local> 1269866636 +0400 commit: upd
59
+ 0538f41ddebf7fa8c71ebe99c5288d5e11c3fb86 6a02fd5698264a4165c46af5175a39f5b130de9c alex <alex@amac.local> 1269956190 +0400 commit: update mongo scope
60
+ 6a02fd5698264a4165c46af5175a39f5b130de9c 8f53b7b2ab88b130763bc42b3ded7983d27bff7a alex <alex@amac.local> 1269956206 +0400 commit: update mongo scope
61
+ 8f53b7b2ab88b130763bc42b3ded7983d27bff7a b4343d9284a89e2971022f8d4acf7865d8341c6d alex <alex@amac.local> 1270054079 +0400 commit: upd
@@ -55,3 +55,7 @@ d4faaed37686ae3ce16b636defd37eeacb38470d 978c0ddb7dbecadce5fbc740347598999ccc822
55
55
  978c0ddb7dbecadce5fbc740347598999ccc8223 804a20e92f38623945cdb50ed8864d014632cf44 alex <alex@amac.local> 1269602049 +0300 commit: upd
56
56
  804a20e92f38623945cdb50ed8864d014632cf44 161cacdd64a4f135d805f5a2f23d006592b8c835 alex <alex@amac.local> 1269602071 +0300 commit: upd
57
57
  161cacdd64a4f135d805f5a2f23d006592b8c835 a3ece30fb5827ed20d26a75253bb4854f657055a alex <alex@amac.local> 1269602138 +0300 commit: upd
58
+ a3ece30fb5827ed20d26a75253bb4854f657055a 0538f41ddebf7fa8c71ebe99c5288d5e11c3fb86 alex <alex@amac.local> 1269866636 +0400 commit: upd
59
+ 0538f41ddebf7fa8c71ebe99c5288d5e11c3fb86 6a02fd5698264a4165c46af5175a39f5b130de9c alex <alex@amac.local> 1269956190 +0400 commit: update mongo scope
60
+ 6a02fd5698264a4165c46af5175a39f5b130de9c 8f53b7b2ab88b130763bc42b3ded7983d27bff7a alex <alex@amac.local> 1269956206 +0400 commit: update mongo scope
61
+ 8f53b7b2ab88b130763bc42b3ded7983d27bff7a b4343d9284a89e2971022f8d4acf7865d8341c6d alex <alex@amac.local> 1270054079 +0400 commit: upd
@@ -42,3 +42,6 @@ f9cf98993bf7067d5b45b0f06dc36fdedba5ffcf 3b354d07a5bb5780eeffa4c12968214b1edb8b2
42
42
  3a95e5465ca8d93ae2f53d1a77b0215a10f18021 d4faaed37686ae3ce16b636defd37eeacb38470d alex <alex@amac.local> 1269316281 +0300 update by push
43
43
  d4faaed37686ae3ce16b636defd37eeacb38470d 161cacdd64a4f135d805f5a2f23d006592b8c835 alex <alex@amac.local> 1269602079 +0300 update by push
44
44
  161cacdd64a4f135d805f5a2f23d006592b8c835 a3ece30fb5827ed20d26a75253bb4854f657055a alex <alex@amac.local> 1269602143 +0300 update by push
45
+ a3ece30fb5827ed20d26a75253bb4854f657055a 0538f41ddebf7fa8c71ebe99c5288d5e11c3fb86 alex <alex@amac.local> 1269866645 +0400 update by push
46
+ 0538f41ddebf7fa8c71ebe99c5288d5e11c3fb86 6a02fd5698264a4165c46af5175a39f5b130de9c alex <alex@amac.local> 1269956196 +0400 update by push
47
+ 6a02fd5698264a4165c46af5175a39f5b130de9c b4343d9284a89e2971022f8d4acf7865d8341c6d alex <alex@amac.local> 1270054087 +0400 update by push
@@ -1 +1 @@
1
- a3ece30fb5827ed20d26a75253bb4854f657055a
1
+ b4343d9284a89e2971022f8d4acf7865d8341c6d
@@ -1 +1 @@
1
- a3ece30fb5827ed20d26a75253bb4854f657055a
1
+ b4343d9284a89e2971022f8d4acf7865d8341c6d
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ require 'fileutils'
18
18
 
19
19
  spec = Gem::Specification.new do |s|
20
20
  s.name = "rails-ext"
21
- s.version = "0.3.6"
21
+ s.version = "0.3.8"
22
22
  s.summary = "Set of common Ruby on Rails extensions"
23
23
  s.description = "Set of common Ruby on Rails extensions"
24
24
  s.author = "Alexey Petrushin"
@@ -3,11 +3,6 @@ module MongoMapper
3
3
  module DefaultScope
4
4
 
5
5
  module ClassMethods
6
- def default_scope options = nil, &block
7
- options.should! :be_a, [NilClass, Hash]
8
- self.write_inheritable_attribute(:default_scope, (options || block))
9
- end
10
-
11
6
  def find_one options = {}
12
7
  super default_scope_options.merge(options)
13
8
  end
@@ -20,10 +15,45 @@ module MongoMapper
20
15
  super default_scope_options.merge(options)
21
16
  end
22
17
 
18
+ def with_exclusive_scope options = {}, &block
19
+ Thread.current['mm_with_exclusive_scope'].should! :be_nil
20
+
21
+ before = Thread.current['mm_with_exclusive_scope']
22
+ begin
23
+ Thread.current['mm_with_exclusive_scope'] = options
24
+ block.call if block
25
+ ensure
26
+ Thread.current['mm_with_exclusive_scope'] = before
27
+ end
28
+ end
29
+
30
+ def with_scope options = {}, &block
31
+ Thread.current['mm_with_exclusive_scope'].should! :be_nil
32
+
33
+ before = Thread.current['mm_with_scope']
34
+ begin
35
+ options = before.merge options if before
36
+ Thread.current['mm_with_scope'] = options
37
+ block.call if block
38
+ ensure
39
+ Thread.current['mm_with_scope'] = before
40
+ end
41
+ end
42
+
23
43
  protected
44
+ def default_scope options = nil, &block
45
+ options.should! :be_a, [NilClass, Hash]
46
+ self.write_inheritable_attribute(:default_scope, (options || block))
47
+ end
48
+
49
+ private
24
50
  def default_scope_options
25
51
  default_scope = self.read_inheritable_attribute(:default_scope)
26
- if default_scope
52
+
53
+ exclusive_options = Thread.current['mm_with_exclusive_scope']
54
+ return exclusive_options if exclusive_options
55
+
56
+ options = if default_scope
27
57
  if default_scope.respond_to? :call
28
58
  default_scope.call self
29
59
  else
@@ -32,6 +62,12 @@ module MongoMapper
32
62
  else
33
63
  {}
34
64
  end
65
+
66
+ if scope_options = Thread.current['mm_with_scope']
67
+ options = options.merge scope_options
68
+ end
69
+
70
+ options
35
71
  end
36
72
  end
37
73
 
@@ -1,4 +1,4 @@
1
- STRONG_NAME = /\A[a-zA-Z_][a-zA-Z_0-9]*\Z/
1
+ STRONG_NAME = /\A[a-z_][a-z_0-9]*\Z/
2
2
 
3
3
  ActiveSupport::CoreExtensions::Module.class_eval do
4
4
  def model_name
@@ -8,6 +8,7 @@ ActionView::Base.class_eval do
8
8
  end
9
9
 
10
10
  protected
11
+ # TODO3 cache it
11
12
  def merged_packages thetype, package_names
12
13
  found_packages = {}
13
14
 
@@ -22,7 +23,7 @@ ActionView::Base.class_eval do
22
23
  end
23
24
  end
24
25
 
25
- found_packages.size.should! :==, package_names.size
26
+ package_names.each{|name| found_packages.should! :include, name.to_s}
26
27
 
27
28
  if AssetPackager.merge_environments.include? Rails.env
28
29
  found_packages.collect do |name, files|
@@ -0,0 +1,118 @@
1
+ require 'spec'
2
+ require 'ruby_ext'
3
+ require "#{File.dirname __FILE__}/../../lib/mongo_mapper_ext/plugins/default_scope"
4
+ require "mongo_mapper"
5
+
6
+ describe "MongoMapper Default Scope" do
7
+ before :all do
8
+ MongoMapper.database = 'test'
9
+ end
10
+
11
+ before :each do
12
+ class ::ScopeSample
13
+ include MongoMapper::Document
14
+ plugin MongoMapper::Plugins::DefaultScope
15
+
16
+ key :name, String
17
+ end
18
+
19
+ ScopeSample.delete_all
20
+ ScopeSample.create! :name => 'a'
21
+ ScopeSample.create! :name => 'b'
22
+ end
23
+
24
+ after :each do
25
+ Object.send :remove_const, :ScopeSample if Object.const_defined? :ScopeSample
26
+ end
27
+
28
+ it "should not affect objects without default_scope" do
29
+ ScopeSample.count.should == 2
30
+ ScopeSample.all.count.should == 2
31
+ end
32
+
33
+ it "default_scope" do
34
+ ScopeSample.send :default_scope, :name => 'a'
35
+ ScopeSample.count.should == 1
36
+ ScopeSample.all.count.should == 1
37
+ ScopeSample.first.name.should == 'a'
38
+ end
39
+
40
+ it "default_scope as block" do
41
+ ScopeSample.send :default_scope do
42
+ {:name => 'a'}
43
+ end
44
+ ScopeSample.count.should == 1
45
+ ScopeSample.all.count.should == 1
46
+ ScopeSample.first.name.should == 'a'
47
+ end
48
+
49
+ it "default_scope should be inherited" do
50
+ ScopeSample.send :default_scope, :name => 'a'
51
+ class ScopeSampleAncestor < ScopeSample
52
+ end
53
+
54
+ ScopeSampleAncestor.count.should == 1
55
+ ScopeSampleAncestor.all.count.should == 1
56
+ ScopeSampleAncestor.first.name.should == 'a'
57
+ end
58
+
59
+ it "ancestors should be able to override default_scope" do
60
+ ScopeSample.send :default_scope, :name => 'a'
61
+ class ScopeSampleAncestor2 < ScopeSample
62
+ default_scope :name => 'b'
63
+ end
64
+
65
+ ScopeSampleAncestor2.count.should == 1
66
+ ScopeSampleAncestor2.all.count.should == 1
67
+ ScopeSampleAncestor2.first.name.should == 'b'
68
+ end
69
+
70
+ it "shouldn't allow to nest with_exclusive_scope" do
71
+ lambda{
72
+ ScopeSample.with_exclusive_scope do
73
+ ScopeSample.with_exclusive_scope{}
74
+ end
75
+ }.should raise_error(AssertionError)
76
+
77
+ lambda{
78
+ ScopeSample.with_exclusive_scope do
79
+ ScopeSample.with_scope{}
80
+ end
81
+ }.should raise_error(AssertionError)
82
+ end
83
+
84
+ it "with_exclusive_scope should clear other scopes" do
85
+ ScopeSample.send :default_scope, :name => 'a'
86
+
87
+ ScopeSample.with_scope :name => 'a' do
88
+ ScopeSample.with_exclusive_scope :name => 'b' do
89
+ ScopeSample.count.should == 1
90
+ ScopeSample.first.name.should == 'b'
91
+ end
92
+ end
93
+ end
94
+
95
+ it "with_scope" do
96
+ ScopeSample.with_scope :name => 'a' do
97
+ ScopeSample.count.should == 1
98
+ ScopeSample.first.name.should == 'a'
99
+ end
100
+ end
101
+
102
+ it "with scope should merge scope" do
103
+ ScopeSample.class_eval do
104
+ key :name2, String
105
+ key :name3, String
106
+ default_scope :name => 'a'
107
+ end
108
+ ScopeSample.create! :name => 'a', :name2 => 'a2', :name3 => 'a3'
109
+ ScopeSample.create! :name => 'b', :name2 => 'b2', :name3 => 'b3'
110
+
111
+ ScopeSample.with_scope :name2 => 'a2' do
112
+ ScopeSample.with_scope :name3 => 'a3' do
113
+ ScopeSample.count.should == 1
114
+ ScopeSample.first.name2.should == 'a2'
115
+ end
116
+ end
117
+ end
118
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 6
9
- version: 0.3.6
8
+ - 8
9
+ version: 0.3.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alexey Petrushin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-26 00:00:00 +03:00
17
+ date: 2010-03-31 00:00:00 +04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -65,9 +65,11 @@ files:
65
65
  - .git/objects/00/e06caeaae19732437b0181b5dbdf916c2c59e3
66
66
  - .git/objects/00/e127e49ab0f08a8190bf5a95777c972603de9a
67
67
  - .git/objects/00/fd8045e0953bb11a521248dc27d4af2336c6d5
68
+ - .git/objects/02/12d2da342b1ab3c0e7a7f2770686a7bb5d7806
68
69
  - .git/objects/02/469b717b4bd61ad27a3fe664ce0646a8325399
69
70
  - .git/objects/03/9e318355ab5ab32c3b6bc634d3d8e64f444ef8
70
71
  - .git/objects/04/cd62e7f8158fe54d21e6f63617c43b593b8b59
72
+ - .git/objects/05/38f41ddebf7fa8c71ebe99c5288d5e11c3fb86
71
73
  - .git/objects/05/9bdc20ed12957701f4b3931e2b1779de7adccf
72
74
  - .git/objects/06/c2384aa5f8b5614038b48a726d1d4f98a00f3b
73
75
  - .git/objects/06/c3225bad9d5b80e7b3bde79ff3c2da591722bf
@@ -150,6 +152,7 @@ files:
150
152
  - .git/objects/2b/0fbe9a4022a4a112d2fa583f79dc6221ef2baf
151
153
  - .git/objects/2c/21f9d1b567c0d8f3d74e71b38beee67a53afdc
152
154
  - .git/objects/2c/633c11fb72405c6646493bc6c4d8c4fed0b9a6
155
+ - .git/objects/2c/b04524ccd690f1cb4345586ca9138f9615afd5
153
156
  - .git/objects/2d/043376f1bc26b2dad3e79fc72ea14341ea437d
154
157
  - .git/objects/2e/3e3fc8e46949a9b944da3c36207c444aa2c9b7
155
158
  - .git/objects/2e/f02adc5485c579d75dfacf7034b20760f2fdf4
@@ -159,6 +162,7 @@ files:
159
162
  - .git/objects/31/de78f3710d86d0a5f494eb93405f497d8238fe
160
163
  - .git/objects/33/9755448515fb77f691d6197bd65d5b5d53fc24
161
164
  - .git/objects/34/e6093e9cd6ecc08b1a1834418e83bb277e8887
165
+ - .git/objects/35/0b6a89c8f9704cb4f1e037ea638e952a487017
162
166
  - .git/objects/35/a5ef969e9dd65a06260954e2b66f7a7f107568
163
167
  - .git/objects/35/d78424bc393bb5acc12c52c031129aa3ceb8c5
164
168
  - .git/objects/36/66d56066f3aeb0f9fc342de42f25e298341a61
@@ -173,9 +177,11 @@ files:
173
177
  - .git/objects/3a/ff2a7bfdf3a677812899ede62d084369c7c5f4
174
178
  - .git/objects/3b/354d07a5bb5780eeffa4c12968214b1edb8b24
175
179
  - .git/objects/3b/cebd028c4b8312b2c36b14eddb57836c328a67
180
+ - .git/objects/3b/da284efc6c07900db7dd00a9f3082d2c13d55e
176
181
  - .git/objects/3c/994e760012127915c1494a073cea51ef3b43e8
177
182
  - .git/objects/3d/5b84167d35cb75647f38a6d475a452ba3c6178
178
183
  - .git/objects/3d/ce52a15f01f1a8f99e65d148341bea71065129
184
+ - .git/objects/3d/e882c2630c3cd215641a6c73ca83ad2d741b13
179
185
  - .git/objects/3e/c0da65fe2e572ad31203f9412baa09dfdf49d3
180
186
  - .git/objects/3e/cc8b7e1c4837559b36939612408b4d9def8fac
181
187
  - .git/objects/3e/f23cf310c5eebac930a19d36a0561dd362d3ee
@@ -184,6 +190,7 @@ files:
184
190
  - .git/objects/40/215c0554202fc46dc2fca94ed21e2920ce1e84
185
191
  - .git/objects/40/7adfb7f6188b0bb0b88cf9391943e1aaa32374
186
192
  - .git/objects/40/b5d1a81a061ce0e2f315b7e741ec70e0defe1d
193
+ - .git/objects/43/6b9b73da4632657be4800b250741f37fdbb505
187
194
  - .git/objects/44/c96e2a778dcc62c10b3c329ab0211115a9f546
188
195
  - .git/objects/46/3353505eed0c799d05f025788437decbabafec
189
196
  - .git/objects/46/d12e0420cd6341a2720730cc45703fc835efb6
@@ -219,6 +226,7 @@ files:
219
226
  - .git/objects/53/b8187421c09e55e44b8d6fb3c4cd7feb0a51b2
220
227
  - .git/objects/54/713b018cb71a95e3f10510ea96b9f103ef0255
221
228
  - .git/objects/55/0dd68cd7e6918dd1473d609e8cafcde8f89009
229
+ - .git/objects/55/45d0d521bb723db8feae0223fa838a183e38b7
222
230
  - .git/objects/55/6c13b26b6cecd286427a7f16c60c86c7df7885
223
231
  - .git/objects/55/d1f1efc344266d472094b1fd2f247b97de1c8b
224
232
  - .git/objects/56/b49aebdec66032571751e38f82d3ce550ccddf
@@ -231,6 +239,7 @@ files:
231
239
  - .git/objects/5a/c5589c8e02ab34cd516e172250c80d4ded5ce6
232
240
  - .git/objects/5c/95be85f2a2a984454fed4941a5ae00062634c5
233
241
  - .git/objects/5c/d7e89f2b29ed92fd51e2c6b2ee74db376d17d7
242
+ - .git/objects/5d/c38b1f2d3893c8e41b05de2d121b525f888e5c
234
243
  - .git/objects/5f/483b0c41645f8882f549c1c6d0274bb592140a
235
244
  - .git/objects/60/74f4e0c668417e06938cb77640240e9c2b6e0e
236
245
  - .git/objects/60/a42d757f842f6ce1a27284630ffd3deb867857
@@ -254,6 +263,7 @@ files:
254
263
  - .git/objects/68/a8fc1e77fc27530430b55046609ee80cd9b2ad
255
264
  - .git/objects/69/02e8cbb5ad325c33b6abaac081d1df35d16202
256
265
  - .git/objects/69/ad159f329112a498fcc47c4943f4d9b59af1cc
266
+ - .git/objects/6a/02fd5698264a4165c46af5175a39f5b130de9c
257
267
  - .git/objects/6a/2daaf6529a3841c7fd39683d9bcec79b48f79e
258
268
  - .git/objects/6a/90d6784ac3b6580ef470dac68c2d93c276d6a7
259
269
  - .git/objects/6a/cdfb69624140a67634b65ab8230cc5e0ffd543
@@ -300,6 +310,8 @@ files:
300
310
  - .git/objects/82/03c2c6cdd29e1e20e88fbb81e63b7ea1ec2899
301
311
  - .git/objects/83/6f33959bcf517b9952aefb3fdfdd7ff3c1f207
302
312
  - .git/objects/83/acf31cf1fc7e0e97878d11b2f5c1172bf2d0b2
313
+ - .git/objects/83/fa8aa3ad64de1003adc5a1c7c31c3d98a7abf4
314
+ - .git/objects/84/bfc21516dfc947e9aa64a47000b46da2c801d9
303
315
  - .git/objects/85/eee9f4c1a6f710ed87bf28a0531275777f8848
304
316
  - .git/objects/85/fd531f7352ad8f5ac030eed2204a662dd10a66
305
317
  - .git/objects/86/23de615f686de621ca23cbbff6a07885101df9
@@ -317,6 +329,7 @@ files:
317
329
  - .git/objects/8e/3cfb391de711b5fecfbdf2860fa37b019e8036
318
330
  - .git/objects/8e/69b6cf3ec8b49270091b4a206ccf326679dc20
319
331
  - .git/objects/8e/a47de58a27dd343b3ecd3dd5e0fab88e268a72
332
+ - .git/objects/8f/53b7b2ab88b130763bc42b3ded7983d27bff7a
320
333
  - .git/objects/8f/5465ea782955ad019122d92a0f162945339f8e
321
334
  - .git/objects/90/57dd59aea225dd8f4b1dfa3e10c6096671fab9
322
335
  - .git/objects/90/5fe8a081a30b8d3d198590c434e8d0e3b0a4a2
@@ -329,6 +342,7 @@ files:
329
342
  - .git/objects/93/f9a6b596879347290cde161b03052bb22021de
330
343
  - .git/objects/94/72f3ac9e890231482aadd774bdc1c9ba742497
331
344
  - .git/objects/94/afd196cc89d60f0a06d4cad619eaa79921a9ae
345
+ - .git/objects/94/ba2c1a45bc1a8cf3625f4889c507b39c664576
332
346
  - .git/objects/95/a9d4abd8363e64d221e0f7d47ae69cb055ea7b
333
347
  - .git/objects/96/47afbafd293f6994316b2cc0d3e813c1878f87
334
348
  - .git/objects/96/48a1590ab953b7ec3bc9d06e460c0004962b77
@@ -338,6 +352,7 @@ files:
338
352
  - .git/objects/97/8c0ddb7dbecadce5fbc740347598999ccc8223
339
353
  - .git/objects/98/6915a151ae2adb8f8e81e11038f7a1ca731bbc
340
354
  - .git/objects/98/8bfa77097695a4771be8e01d0aabd1a01c62fa
355
+ - .git/objects/99/368683bd721c6c1b8db8eb1b468dffefa61a2e
341
356
  - .git/objects/99/8afa58b56034f5458b4aef2b8255daa53a5bb1
342
357
  - .git/objects/99/a23df6dd9c448928b25f2e749871c6fc696a32
343
358
  - .git/objects/9a/ef8f9aacfa5609934eac4de71d9440a23b1b9f
@@ -379,17 +394,20 @@ files:
379
394
  - .git/objects/ad/66aac16165dd71456e4488069248d6f10ebb8f
380
395
  - .git/objects/ae/536c345aad67cee8ce167dc91006263e63885f
381
396
  - .git/objects/ae/f24b73cf47992cde67e6b07544872df9bb2530
397
+ - .git/objects/af/33f2833588e40e441f8b1f4dd26d5c93488334
382
398
  - .git/objects/b0/2c48116db702256abf27fab4236c84bd2d2dbc
383
399
  - .git/objects/b0/2d1be335e81533c7385970b28ea3b2a0ac5436
384
400
  - .git/objects/b0/39fcd38009980eb74d6bcef22d11e02639a530
385
401
  - .git/objects/b0/426bd4d76304278e6af43ce2d708ad26335514
386
402
  - .git/objects/b1/0d2b27582bb0d779efe6e17c45aaa671d32f3a
387
403
  - .git/objects/b1/2623653bc803aeab5b77efdc72f79fb8f9c80e
404
+ - .git/objects/b1/8a3c6bf39b910b9805973578074e6d6b692a4a
388
405
  - .git/objects/b2/99ac9d0ac730461d7610161b99ee4191c7c2b8
389
406
  - .git/objects/b2/cd852090540d0b2450b901397edd924d8c0ba9
390
407
  - .git/objects/b3/c029798d5af50b4ab725aee6cf66ee11c4ff7a
391
408
  - .git/objects/b4/0345153922bfcdbbc4785cc3146e9e7c60dbbd
392
409
  - .git/objects/b4/228251babf3a84ac181d462fdd383816bd23b8
410
+ - .git/objects/b4/343d9284a89e2971022f8d4acf7865d8341c6d
393
411
  - .git/objects/b4/eb909dd819bf870d2445bddc0d7f00678b11b6
394
412
  - .git/objects/b5/15828bb32356501aa81bb4e808ea5d7d77f068
395
413
  - .git/objects/b5/33c1c1bca9eae5b7e75c639fff8ec2c2f9fea1
@@ -451,10 +469,12 @@ files:
451
469
  - .git/objects/d6/ff7949e59f44649d35e95ed0240ead0ce94077
452
470
  - .git/objects/d7/a33fe1ff44a661941d742270c3299a862689ca
453
471
  - .git/objects/d7/dc82a39bd4d292230a212479dc4c0d7786474d
472
+ - .git/objects/d8/bd32eafc1bcd962f7e2e1244071c921cd465fe
454
473
  - .git/objects/d9/0981681872c639fc00eb95ffa9dc17ad9f9599
455
474
  - .git/objects/db/64f75586d2786dd374615d935889e185f26fab
456
475
  - .git/objects/db/951c9a303fba608e0066e2aa68c3b7d8d9aea6
457
476
  - .git/objects/db/d962bcfbb85c6da46c868594983f3cda9fcad8
477
+ - .git/objects/dc/0bcf757c5c24befef5c59eb7ec1589cfed184d
458
478
  - .git/objects/dc/773412a3a73c02f34edfaeadc89473cfe61c40
459
479
  - .git/objects/dc/d404a6183c1b2160add042127ada7ff83c9b7c
460
480
  - .git/objects/dc/e1fc65f9462792558151feab3fa64abf3a229f
@@ -464,11 +484,13 @@ files:
464
484
  - .git/objects/de/57906fbec41c830adf724743fd20dba762acab
465
485
  - .git/objects/df/f63029f32b25c2bf18d0f3f4e7907daa7c1bca
466
486
  - .git/objects/e0/444cc3908c5096319636ca42c403a78deda3f9
487
+ - .git/objects/e0/7dd2a6b90bdde86477d621148f47bbba9e8427
467
488
  - .git/objects/e0/d8e7ab5a565d95d44f2a9a6246be6003a3de7b
468
489
  - .git/objects/e1/0c4f3ec5729fd4d2580d74e96a0489644a041a
469
490
  - .git/objects/e1/323977dc6cda25967e6ec6166430c2c0f08e32
470
491
  - .git/objects/e2/bc2615d3aa154bba2897c562a15ed19136d518
471
492
  - .git/objects/e2/c37248908c561be703c405e237fbf0c743977a
493
+ - .git/objects/e3/153285548db5d39a615acbf0748cfa21e96ecb
472
494
  - .git/objects/e3/771a0d9f7b7be0df4f1ad709b7d6e0fe6536a9
473
495
  - .git/objects/e3/a7cacb84225125a2bc91b42394e7de7de7b205
474
496
  - .git/objects/e3/c22b30641292e851811969cbc0f9ceb5b1ac05
@@ -507,12 +529,14 @@ files:
507
529
  - .git/objects/f3/7784042bc99c16c02fd104dda82aafa42d4c9c
508
530
  - .git/objects/f4/2863a866b6cd3bb09d0482052cbf2da7fb4e5a
509
531
  - .git/objects/f4/2bc1aaa21ccdaa1bc0cfa8efb982b09b7eebb1
532
+ - .git/objects/f5/8ca6b23d3ab90715ea6ba514546a416e50064e
510
533
  - .git/objects/f5/91a5c39e03e2102c9101db957b48c8c76e194c
511
534
  - .git/objects/f6/0fd8c2582e0f7688877f12f78ddb97a291046c
512
535
  - .git/objects/f6/3ad03a8daa1602df63aab3838947c18fa63797
513
536
  - .git/objects/f6/b9bcda0a6940c634c0ac0d6ac626028927e1da
514
537
  - .git/objects/f7/32b167a61d8db0328f0196af00b55147ebf756
515
538
  - .git/objects/f7/b177b2c6b25dd886d23d6be87bcf802af9b513
539
+ - .git/objects/f8/9eb17d4ff10a745b70063cf5b8ff76ec66e102
516
540
  - .git/objects/f9/8d0f95460a7a3f63ab4c08ad5508fd32d1b5c2
517
541
  - .git/objects/f9/cf98993bf7067d5b45b0f06dc36fdedba5ffcf
518
542
  - .git/objects/f9/ef6dd08a60dec5d5e4e7a9b08f693ebf76da39
@@ -595,10 +619,10 @@ files:
595
619
  - lib/rails_ext/micelaneous/rails_require.rb
596
620
  - lib/rails_ext/micelaneous/safe_hash.rb
597
621
  - lib/rails_ext/micelaneous.rb
598
- - spec/mongo_mapper_ext/default_scope_spec.rb
599
622
  - spec/mongo_mapper_ext/micelaneous_plugin_spec.rb
600
623
  - spec/mongo_mapper_ext/micelaneous_spec.rb
601
624
  - spec/mongo_mapper_ext/mongo_mapper_migration_spec.rb
625
+ - spec/mongo_mapper_ext/scope_spec.rb
602
626
  - spec/rails_ext/safe_hash_spec.rb
603
627
  - spec/spec.opts
604
628
  - public/rails_ext/rails_ext.css
@@ -1,62 +0,0 @@
1
- require 'spec'
2
- require 'ruby_ext'
3
- require "#{File.dirname __FILE__}/../../lib/mongo_mapper_ext/plugins/default_scope"
4
- require "mongo_mapper"
5
-
6
- describe "MongoMapper Default Scope" do
7
- before :all do
8
- class ::DSBase
9
- include MongoMapper::Document
10
- plugin MongoMapper::Plugins::DefaultScope
11
-
12
- key :name, String
13
- end
14
-
15
- class ::ObjectWithoutDefaultScope < DSBase
16
- end
17
-
18
- class ::ObjectWithDefaultScope < DSBase
19
- default_scope :name => 'special'
20
- end
21
-
22
- class ::ObjectWithDynamicDefaultScope < DSBase
23
- default_scope do
24
- {:name => 'special'}
25
- end
26
- end
27
-
28
- class ::DefaultScopeInheritance < ObjectWithDefaultScope
29
- end
30
-
31
- MongoMapper.database = 'test'
32
- end
33
-
34
- after :all do
35
- %w{DSBase ObjectWithoutDefaultScope ObjectWithDefaultScope DefaultScopeInheritance ObjectWithDynamicDefaultScope}.each do |obj_name|
36
- Object.send :remove_const, obj_name if Object.const_defined? obj_name
37
- end
38
- end
39
-
40
- before :each do
41
- DSBase.delete_all
42
- DSBase.create! :name => 'general'
43
- DSBase.create! :name => 'special'
44
- end
45
-
46
- it "should not affect objects without default_scope" do
47
- ObjectWithoutDefaultScope.count.should == 2
48
- ObjectWithoutDefaultScope.all.count.should == 2
49
- end
50
-
51
- it "static default scope" do
52
- ObjectWithDefaultScope.count.should == 1
53
- ObjectWithDefaultScope.all.count.should == 1
54
- ObjectWithDefaultScope.first.name.should == 'special'
55
- end
56
-
57
- it "dynamic default scope" do
58
- ObjectWithDynamicDefaultScope.count.should == 1
59
- ObjectWithDynamicDefaultScope.all.count.should == 1
60
- ObjectWithDynamicDefaultScope.first.name.should == 'special'
61
- end
62
- end