Skip to content

Commit

Permalink
[ci] Add 'bullet' gem and its configuration
Browse files Browse the repository at this point in the history
In test environment we enable bullet log, without raising exceptions.
In development environment we enable bullet log and messages in browser.
  • Loading branch information
DavidKang committed Dec 9, 2016
1 parent 887c402 commit 7af0aad
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/api/Gemfile
Expand Up @@ -133,6 +133,8 @@ group :development, :test do
gem 'poltergeist'
# to launch browser in test
gem 'launchy'
# to find n+1 queries
gem 'bullet'
end

# Gems used only for assets and not required in production environments by default.
Expand Down
5 changes: 5 additions & 0 deletions src/api/Gemfile.lock
Expand Up @@ -52,6 +52,9 @@ GEM
arel (7.1.1)
ast (2.3.0)
builder (3.2.2)
bullet (5.4.2)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.10.0)
capybara (2.10.1)
addressable
mime-types (>= 1.16)
Expand Down Expand Up @@ -326,6 +329,7 @@ GEM
unicorn-rails (2.2.1)
rack
unicorn
uniform_notifier (1.10.0)
vcr (3.0.3)
voight_kampff (1.1.1)
rack (>= 1.4, < 3.0)
Expand All @@ -350,6 +354,7 @@ DEPENDENCIES
activemodel-serializers-xml
acts_as_list
acts_as_tree
bullet
bundler
capybara_minitest_spec
chunky_png
Expand Down
8 changes: 8 additions & 0 deletions src/api/config/environments/development.rb
Expand Up @@ -52,6 +52,14 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker

# Bullet configuration
config.after_initialize do
Bullet.enable = true
Bullet.bullet_logger = true
Bullet.console = true
Bullet.add_footer = true
end
end

CONFIG['extended_backend_log'] = true
Expand Down
7 changes: 7 additions & 0 deletions src/api/config/environments/test.rb
Expand Up @@ -51,6 +51,13 @@
config.secret_key_base = '92b2ed725cb4d68cc5fbf86d6ba204f1dec4172086ee7eac8f083fb62ef34057f1b770e0722ade7b298837be7399c6152938627e7d15aca5fcda7a4faef91fc7'
# rubocop:enable Metrics/LineLength

# Bullet configuration
config.after_initialize do
Bullet.enable = true
Bullet.bullet_logger = true
Bullet.raise = false # raise an error if n+1 query occurs
end

# TODO: This shouldn't be needed when we switch to RSpec completely
config.action_dispatch.rescue_responses.merge!('ActionController::InvalidAuthenticityToken' => 950 )
end
Expand Down
12 changes: 12 additions & 0 deletions src/api/spec/rails_helper.rb
Expand Up @@ -26,6 +26,18 @@
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")

# Wrap each test in Bullet api.
if Bullet.enable?
config.before(:each) do
Bullet.start_request
end

config.after(:each) do
Bullet.perform_out_of_channel_notifications if Bullet.notification?
Bullet.end_request
end
end
end

# support test coverage
Expand Down

0 comments on commit 7af0aad

Please sign in to comment.