Skip to content

Instantly share code, notes, and snippets.

@joelind
joelind / ability_spec.rb
Created March 10, 2012 18:06
Simple scheme for unit testing cancan abilities
require 'spec_helper'
describe Ability do
let(:district) { Factory :district }
let(:root) { Factory :root_user }
let(:admin) { Factory :admin_user, district: district }
let(:other_admin_in_district) { Factory :admin_user, district: district }
let(:admin_in_other_district) { Factory :admin_user }
let(:contributor) { Factory :contributor_user, district: district }
let(:contributor_in_other_district) { Factory :contributor_user }
@joelind
joelind / gist:3518875
Created August 29, 2012 20:59
Count yer queries!
module QueryTracer
def self.benchmark(benchmark_name = '')
count = 0
duration = 0
counts = {}
counts.default = 0
callback = lambda{|namespace, started, ended, identifier, payload|
unless 'SCHEMA' == payload[:name]
duration += (ended - started)
2012-10-12T18:09:45+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/kgio-2.7.4/lib/kgio.rb:21:in `require': libruby.so.1.9: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/1.9.1/gems/kgio-2.7.4/lib/kgio_ext.so (LoadError)
select * from tims;
a | b
---+---
t | t
t | f
t |
|
f | f
(5 rows)
POST /admin/v1/accounts HTTP/1.1
User-Agent: Faraday v0.9.1
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Content-Length: 478
Host: qa-api.ea.autodesk.com
category=paid&corporate_account_name=Account+3daeed5b-44e1-4110-83e5-a610176413f6&corporate_account_number=Account+3daeed5b-44e1-4110-83e5-a610176413f6&display_name=Account+3daeed5b-44e1-4110-83e5-a610176413f6&email=joe.lind%2Bc2e2c02f-11e2-4291-aa82-27b7741e70ae%40autodesk.com&end_date=2021-01-01&name=Account+3daeed5b-44e1-4110-83e5-a610176413f6&price_model=enterprise_unlimited&project_exports_enabled=true&service_types=field&start_date=2001-01-01&user_exports_enabled=true