Skip to content

Instantly share code, notes, and snippets.

@daxadax
Created October 30, 2015 13:54
Show Gist options
  • Save daxadax/c0e8b6bea0a17c76ef97 to your computer and use it in GitHub Desktop.
Save daxadax/c0e8b6bea0a17c76ef97 to your computer and use it in GitHub Desktop.
describe 'database performance' do
before { @sql_calls = 0 }
after { ActiveSupport::Notifications.unsubscribe(@subscription) }
it 'makes a minimum of db queries' do
@subscription = ActiveSupport::Notifications.subscribe('sql.active_record') do |event|
@sql_calls += 1
end
get :index, attributes.merge(format: :json)
expect(@sql_calls).to be < 25
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment