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 CHANGED
@@ -6,7 +6,7 @@ require 'bundler/version'
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "fake_arel"
9
- s.version = "0.9.8"
9
+ s.version = "0.9.9"
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.author = "Grant Ammons"
12
12
  s.email = ["grant@pipelinedealsco.com"]
@@ -67,6 +67,10 @@ module Rails3Finders
67
67
  offset += options[:batch_size]
68
68
  end
69
69
  end
70
+
71
+ def self.fakearel_destroy
72
+ self.destroy_all(:id => self.scoped({}).select(:id).map(&:id))
73
+ end
70
74
  end
71
75
  end
72
76
  end
data/lib/fake_arel.rb CHANGED
@@ -9,7 +9,7 @@ require 'fake_arel/rails_3_finders'
9
9
  require 'fake_arel/calculations'
10
10
 
11
11
  module FakeArel
12
- VERSION = '0.9.8'
12
+ VERSION = '0.9.9'
13
13
  ActiveRecord::Base.send :include, Rails3Finders
14
14
  ActiveRecord::Base.send :include, WithScopeReplacement
15
15
  end
@@ -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
@@ -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: 43
4
+ hash: 41
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 8
10
- version: 0.9.8
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-04-14 00:00:00 -07:00
18
+ date: 2011-05-13 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: activerecord
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
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: hoe
34
+ requirement: *id001
35
+ name: activerecord
39
36
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
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
- version_requirements: *id002
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