bullet 4.0.0 → 4.1.4

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.
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,6 @@ rescue LoadError
5
5
  # rails 2.3
6
6
  require 'initializer'
7
7
  end
8
- require 'active_record'
9
8
  require 'action_controller'
10
9
 
11
10
  module Rails
@@ -18,39 +17,45 @@ end
18
17
 
19
18
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
20
19
  require 'bullet'
20
+ extend Bullet::Dependency
21
21
  Bullet.enable = true
22
- ActiveRecord::Migration.verbose = false
23
22
 
24
23
  MODELS = File.join(File.dirname(__FILE__), "models")
25
24
  $LOAD_PATH.unshift(MODELS)
26
-
27
- # Autoload every model for the test suite that sits in spec/models.
28
- Dir[ File.join(MODELS, "*.rb") ].sort.each do |filename|
29
- name = File.basename(filename, ".rb")
30
- autoload name.camelize.to_sym, name
31
- end
32
-
33
25
  SUPPORT = File.join(File.dirname(__FILE__), "support")
34
- Dir[ File.join(SUPPORT, "*.rb") ].reject { |filename| filename =~ /mongo_seed.rb$/ }.sort.each { |file| require file }
26
+ Dir[ File.join(SUPPORT, "*.rb") ].reject { |filename| filename =~ /_seed.rb$/ }.sort.each { |file| require file }
35
27
 
36
28
  RSpec.configure do |config|
37
- config.before(:suite) do
38
- Support::SqliteSeed.setup_db
39
- Support::SqliteSeed.seed_db
40
- end
41
-
42
- config.after(:suite) do
43
- Support::SqliteSeed.teardown_db
44
- end
29
+ config.extend Bullet::Dependency
45
30
 
46
31
  config.filter_run :focus => true
47
32
  config.run_all_when_everything_filtered = true
48
33
  end
49
34
 
50
- begin
51
- require 'mongoid'
35
+ if active_record?
36
+ ActiveRecord::Migration.verbose = false
52
37
 
53
- # Autoload every model for the test suite that sits in spec/models.
38
+ # Autoload every active_record model for the test suite that sits in spec/models.
39
+ Dir[ File.join(MODELS, "*.rb") ].sort.each do |filename|
40
+ name = File.basename(filename, ".rb")
41
+ autoload name.camelize.to_sym, name
42
+ end
43
+ require File.join(SUPPORT, "sqlite_seed.rb")
44
+
45
+ RSpec.configure do |config|
46
+ config.before(:suite) do
47
+ Support::SqliteSeed.setup_db
48
+ Support::SqliteSeed.seed_db
49
+ end
50
+
51
+ config.after(:suite) do
52
+ Support::SqliteSeed.teardown_db
53
+ end
54
+ end
55
+ end
56
+
57
+ if mongoid?
58
+ # Autoload every mongoid model for the test suite that sits in spec/models.
54
59
  Dir[ File.join(MODELS, "mongoid", "*.rb") ].sort.each { |file| require file }
55
60
  require File.join(SUPPORT, "mongo_seed.rb")
56
61
 
@@ -64,5 +69,4 @@ begin
64
69
  Support::MongoSeed.teardown_db
65
70
  end
66
71
  end
67
- rescue LoadError
68
72
  end
@@ -29,11 +29,19 @@ module Support
29
29
  end
30
30
 
31
31
  def setup_db
32
- Mongoid.database = Mongo::Connection.new("localhost", 27017).db("bullet")
32
+ if Mongoid::VERSION =~ /\A2\.4/
33
+ Mongoid.configure do |config|
34
+ config.master = Mongo::Connection.new.db("bullet")
35
+ end
36
+ elsif Mongoid::VERSION =~ /\A3/
37
+ Mongoid.configure do |config|
38
+ config.connect_to("bullet")
39
+ end
40
+ end
33
41
  end
34
42
 
35
43
  def teardown_db
36
- Mongoid.database.collections.select {|c| c.name !~ /system/ }.map(&:drop)
44
+ Mongoid.purge!
37
45
  end
38
46
 
39
47
  extend self
data/test.sh ADDED
@@ -0,0 +1,4 @@
1
+ bundle && bundle exec rspec spec
2
+ BUNDLE_GEMFILE=Gemfile.rails-3.1.5 bundle && bundle exec rspec spec
3
+ BUNDLE_GEMFILE=Gemfile.rails-3.0.13 bundle && bundle exec rspec spec
4
+ BUNDLE_GEMFILE=Gemfile.rails-2.3.14 bundle && bundle exec rspec spec
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-09 00:00:00.000000000 Z
12
+ date: 2012-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: uniform_notifier
16
- requirement: &70311383422560 !ruby/object:Gem::Requirement
16
+ requirement: &70278160365200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70311383422560
24
+ version_requirements: *70278160365200
25
25
  description: A rails plugin to kill N+1 queries and unused eager loading.
26
26
  email:
27
27
  - flyerhzm@gmail.com
@@ -38,10 +38,10 @@ files:
38
38
  - Gemfile.lock
39
39
  - Gemfile.rails-2.3.14
40
40
  - Gemfile.rails-2.3.14.lock
41
- - Gemfile.rails-3.0.12
42
- - Gemfile.rails-3.0.12.lock
43
- - Gemfile.rails-3.1.4
44
- - Gemfile.rails-3.1.4.lock
41
+ - Gemfile.rails-3.0.13
42
+ - Gemfile.rails-3.0.13.lock
43
+ - Gemfile.rails-3.1.5
44
+ - Gemfile.rails-3.1.5.lock
45
45
  - Guardfile
46
46
  - Hacking.textile
47
47
  - MIT-LICENSE
@@ -54,6 +54,7 @@ files:
54
54
  - lib/bullet/active_record2.rb
55
55
  - lib/bullet/active_record3.rb
56
56
  - lib/bullet/active_record31.rb
57
+ - lib/bullet/dependency.rb
57
58
  - lib/bullet/detector.rb
58
59
  - lib/bullet/detector/association.rb
59
60
  - lib/bullet/detector/base.rb
@@ -62,7 +63,8 @@ files:
62
63
  - lib/bullet/detector/unused_eager_association.rb
63
64
  - lib/bullet/ext/object.rb
64
65
  - lib/bullet/ext/string.rb
65
- - lib/bullet/mongoid.rb
66
+ - lib/bullet/mongoid24.rb
67
+ - lib/bullet/mongoid3.rb
66
68
  - lib/bullet/notification.rb
67
69
  - lib/bullet/notification/base.rb
68
70
  - lib/bullet/notification/counter_cache.rb
@@ -134,7 +136,7 @@ files:
134
136
  - spec/support/rack_double.rb
135
137
  - spec/support/sqlite_seed.rb
136
138
  - tasks/bullet_tasks.rake
137
- - test.result
139
+ - test.sh
138
140
  homepage: http://github.com/flyerhzm/bullet
139
141
  licenses: []
140
142
  post_install_message:
@@ -149,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
151
  version: '0'
150
152
  segments:
151
153
  - 0
152
- hash: -3387566190207483190
154
+ hash: 107640970782381372
153
155
  required_rubygems_version: !ruby/object:Gem::Requirement
154
156
  none: false
155
157
  requirements:
@@ -158,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
160
  version: 1.3.6
159
161
  requirements: []
160
162
  rubyforge_project:
161
- rubygems_version: 1.8.15
163
+ rubygems_version: 1.8.17
162
164
  signing_key:
163
165
  specification_version: 3
164
166
  summary: A rails plugin to kill N+1 queries and unused eager loading.