fake_arel 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/fake_arel.gemspec +1 -1
- data/lib/fake_arel/rails_3_finders.rb +4 -0
- data/lib/fake_arel.rb +1 -1
- data/spec/fake_arel_spec.rb +15 -0
- data/spec/fixtures/reply.rb +10 -0
- data/spec/test.db +0 -0
- metadata +12 -12
data/fake_arel.gemspec
CHANGED
data/lib/fake_arel.rb
CHANGED
data/spec/fake_arel_spec.rb
CHANGED
@@ -224,6 +224,21 @@ describe "Fake Arel" do
|
|
224
224
|
end
|
225
225
|
end
|
226
226
|
end
|
227
|
+
|
228
|
+
describe "fakearel_destroy" do
|
229
|
+
it "should destroy within a scope" do
|
230
|
+
$before_destroy_called = false
|
231
|
+
$after_destroy_called = false
|
232
|
+
replies = Reply.where(:id => [1,2])
|
233
|
+
replies.fakearel_destroy
|
234
|
+
Reply.where(:id => [1,2]).should == []
|
235
|
+
Reply.first.id.should == 3
|
236
|
+
$before_destroy_called.should == true
|
237
|
+
$after_destroy_called.should == true
|
238
|
+
$before_destroy_called = false
|
239
|
+
$after_destroy_called = false
|
240
|
+
end
|
241
|
+
end
|
227
242
|
end
|
228
243
|
|
229
244
|
describe "NameScope bug" do
|
data/spec/fixtures/reply.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class Reply < ActiveRecord::Base
|
2
|
+
attr_accessor :before_destroy_called, :after_destroy_called
|
3
|
+
|
2
4
|
belongs_to :topic, :include => [:replies]
|
3
5
|
|
4
6
|
named_scope :recent, where('replies.created_at > ?', 15.minutes.ago)
|
@@ -38,4 +40,12 @@ class Reply < ActiveRecord::Base
|
|
38
40
|
self.all
|
39
41
|
end
|
40
42
|
end
|
43
|
+
|
44
|
+
def before_destroy
|
45
|
+
$before_destroy_called = true
|
46
|
+
end
|
47
|
+
|
48
|
+
def after_destroy
|
49
|
+
$after_destroy_called = true
|
50
|
+
end
|
41
51
|
end
|
data/spec/test.db
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_arel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 41
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 9
|
10
|
+
version: 0.9.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Grant Ammons
|
@@ -15,13 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-13 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
26
24
|
requirements:
|
27
25
|
- - ">="
|
@@ -33,11 +31,11 @@ dependencies:
|
|
33
31
|
- 5
|
34
32
|
version: 2.3.5
|
35
33
|
type: :runtime
|
36
|
-
|
37
|
-
|
38
|
-
name: hoe
|
34
|
+
requirement: *id001
|
35
|
+
name: activerecord
|
39
36
|
prerelease: false
|
40
|
-
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
@@ -49,7 +47,9 @@ dependencies:
|
|
49
47
|
- 4
|
50
48
|
version: 2.9.4
|
51
49
|
type: :development
|
52
|
-
|
50
|
+
requirement: *id002
|
51
|
+
name: hoe
|
52
|
+
prerelease: false
|
53
53
|
description: |-
|
54
54
|
* Tired of waiting for Rails 3 and its new super-sweet query interface? Try fake_arel!
|
55
55
|
|