Commit 5b10f40

mo khan <mo@mokhan.ca>
2015-05-31 05:15:00
run bullet in tests to catch all N+1 errors.
1 parent a90742c
Changed files (4)
app
views
config
environments
app/views/programs/show.html.erb
@@ -1,6 +1,6 @@
 <div class="small-12 columns">
   <div class="row">
     <h1><%= link_to @program.name, program_path(@program) %></h1>
-    <%= render @program.workouts %>
+    <%= render @program.workouts.includes(exercise_workouts: :exercise) %>
   </div>
 </div>
config/environments/test.rb
@@ -41,4 +41,10 @@ Rails.application.configure do
 
   # Raises error for missing translations
   # config.action_view.raise_on_missing_translations = true
+
+  config.after_initialize do
+    Bullet.enable = true
+    Bullet.bullet_logger = true
+    Bullet.raise = true # raise an error if n+1 query occurs
+  end
 end
Gemfile
@@ -64,6 +64,7 @@ group :development, :test do
   gem 'capistrano-bundler', '~> 1.1', require: false
   gem 'capistrano-rbenv', '~> 2.0', require: false
   gem 'rails-erd'
+  gem 'bullet'
 end
 
 group :production do
Gemfile.lock
@@ -45,6 +45,9 @@ GEM
     binding_of_caller (0.7.2)
       debug_inspector (>= 0.0.1)
     builder (3.2.2)
+    bullet (4.14.7)
+      activesupport (>= 3.0.0)
+      uniform_notifier (~> 1.9.0)
     byebug (4.0.5)
       columnize (= 0.9.0)
     callsite (0.0.11)
@@ -292,6 +295,7 @@ GEM
     unf (0.1.4)
       unf_ext
     unf_ext (0.0.6)
+    uniform_notifier (1.9.0)
     virtus (1.0.5)
       axiom-types (~> 0.1)
       coercible (~> 1.0)
@@ -313,6 +317,7 @@ PLATFORMS
 
 DEPENDENCIES
   bcrypt (~> 3.1.7)
+  bullet
   byebug
   capistrano-bundler (~> 1.1)
   capistrano-rails