bullet 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -168,6 +168,8 @@ after(:each)
168
168
  end
169
169
  </code></pre>
170
170
 
171
+ Don't forget enabling bullet in test environment.
172
+
171
173
  ****************************************************************************
172
174
 
173
175
  h2. Links
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.1
1
+ 1.7.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bullet}
8
- s.version = "1.7.1"
8
+ s.version = "1.7.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Richard Huang"]
12
- s.date = %q{2009-11-13}
12
+ s.date = %q{2009-11-26}
13
13
  s.description = %q{The Bullet plugin is designed to help you increase your application's performance by reducing the number of queries it makes. It will watch your queries while you develop your application and notify you when you should add eager loading (N+1 queries) or when you're using eager loading that isn't necessary.}
14
14
  s.email = %q{flyerhzm@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/bullet/notification.rb",
31
31
  "lib/bulletware.rb",
32
32
  "rails/init.rb",
33
+ "spec/bullet/association_for_chris_spec.rb",
33
34
  "spec/bullet/association_spec.rb",
34
35
  "spec/bullet/counter_spec.rb",
35
36
  "spec/spec.opts",
@@ -42,9 +43,10 @@ Gem::Specification.new do |s|
42
43
  s.rubygems_version = %q{1.3.5}
43
44
  s.summary = %q{A plugin to kill N+1 queries and unused eager loading}
44
45
  s.test_files = [
45
- "spec/spec_helper.rb",
46
+ "spec/bullet/association_for_chris_spec.rb",
47
+ "spec/bullet/association_spec.rb",
46
48
  "spec/bullet/counter_spec.rb",
47
- "spec/bullet/association_spec.rb"
49
+ "spec/spec_helper.rb"
48
50
  ]
49
51
 
50
52
  if s.respond_to? :specification_version then
@@ -26,8 +26,6 @@ module Bullet
26
26
  def process(request, response, method = :perform_action, *arguments)
27
27
  Bullet.start_request
28
28
  response = origin_process(request, response, method = :perform_action, *arguments)
29
- puts response.body
30
- puts response.headers
31
29
 
32
30
  if Bullet.notification?
33
31
  if response.headers["type"] and response.headers["type"].include? 'text/html' and response.body =~ %r{<html.*</html>}m
@@ -0,0 +1,94 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
4
+ # This test is just used for http://github.com/flyerhzm/bullet/issues/#issue/14
5
+ describe Bullet::Association, 'for chris' do
6
+
7
+ def setup_db
8
+ ActiveRecord::Schema.define(:version => 1) do
9
+ create_table :locations do |t|
10
+ t.column :name, :string
11
+ end
12
+
13
+ create_table :hotels do |t|
14
+ t.column :name, :string
15
+ t.column :location_id, :integer
16
+ end
17
+
18
+ create_table :deals do |t|
19
+ t.column :name, :string
20
+ t.column :hotel_id, :integer
21
+ end
22
+ end
23
+ end
24
+
25
+ def teardown_db
26
+ ActiveRecord::Base.connection.tables.each do |table|
27
+ ActiveRecord::Base.connection.drop_table(table)
28
+ end
29
+ end
30
+
31
+ class Location < ActiveRecord::Base
32
+ has_many :hotels
33
+ end
34
+
35
+ class Hotel < ActiveRecord::Base
36
+ belongs_to :location
37
+ has_many :deals
38
+ end
39
+
40
+ class Deal < ActiveRecord::Base
41
+ belongs_to :hotel
42
+ has_one :location, :through => :hotel
43
+ end
44
+
45
+ before(:all) do
46
+ setup_db
47
+
48
+ location1 = Location.create(:name => "location1")
49
+ location2 = Location.create(:name => "location2")
50
+
51
+ hotel1 = location1.hotels.create(:name => "hotel1")
52
+ hotel2 = location1.hotels.create(:name => "hotel2")
53
+ hotel3 = location2.hotels.create(:name => "hotel3")
54
+ hotel4 = location2.hotels.create(:name => "hotel4")
55
+
56
+ deal1 = hotel1.deals.create(:name => "deal1")
57
+ deal2 = hotel2.deals.create(:name => "deal2")
58
+ deal3 = hotel3.deals.create(:name => "deal3")
59
+ deal4 = hotel4.deals.create(:name => "deal4")
60
+ end
61
+
62
+ after(:all) do
63
+ teardown_db
64
+ end
65
+
66
+ before(:each) do
67
+ Bullet::Association.start_request
68
+ end
69
+
70
+ after(:each) do
71
+ Bullet::Association.end_request
72
+ end
73
+
74
+ it "should detect unpreload association from deal to hotel" do
75
+ Deal.find(:all).each do |deal|
76
+ deal.hotel.location.name
77
+ end
78
+ Bullet::Association.should be_detecting_unpreloaded_association_for(Deal, :hotel)
79
+ end
80
+
81
+ it "should detect unpreload association from hotel to location" do
82
+ Deal.find(:all, :include => :hotel).each do |deal|
83
+ deal.hotel.location.name
84
+ end
85
+ Bullet::Association.should be_detecting_unpreloaded_association_for(Hotel, :location)
86
+ end
87
+
88
+ it "should not detect unpreload association" do
89
+ Deal.find(:all, :include => {:hotel => :location}).each do |deal|
90
+ deal.hotel.location.name
91
+ end
92
+ Bullet::Association.should_not be_has_unused_preload_associations
93
+ end
94
+ end
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: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-13 00:00:00 +08:00
12
+ date: 2009-11-26 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -36,6 +36,7 @@ files:
36
36
  - lib/bullet/notification.rb
37
37
  - lib/bulletware.rb
38
38
  - rails/init.rb
39
+ - spec/bullet/association_for_chris_spec.rb
39
40
  - spec/bullet/association_spec.rb
40
41
  - spec/bullet/counter_spec.rb
41
42
  - spec/spec.opts
@@ -70,6 +71,7 @@ signing_key:
70
71
  specification_version: 3
71
72
  summary: A plugin to kill N+1 queries and unused eager loading
72
73
  test_files:
73
- - spec/spec_helper.rb
74
- - spec/bullet/counter_spec.rb
74
+ - spec/bullet/association_for_chris_spec.rb
75
75
  - spec/bullet/association_spec.rb
76
+ - spec/bullet/counter_spec.rb
77
+ - spec/spec_helper.rb