Skip to content

Instantly share code, notes, and snippets.

View paulelliott's full-sized avatar

Paul Elliott paulelliott

View GitHub Profile
Here is the official response to JEA with regards to sharing email addresses.
As it turns out, they did not sell it after all.
Dear Mr. Elliott,
We saw your comment on Twitter and wanted to respond after we investigated.
JEA is part of city government and as such is subject to Government in the
Sunshine here in Florida. That means that when someone asks us for information
def javascript_confirm(answer)
page.evaluate_script 'window._confirm = window.confirm'
page.evaluate_script "window.confirm = function(x) { return #{answer} }"
yield
page.evaluate_script 'window._confirm && (window.confirm = window._confirm)'
page.evaluate_script 'window._confirm = null'
end
@paulelliott
paulelliott / guest_signs_in_spec.rb
Created July 7, 2010 04:00
Example rspec integration spec for a guest signing in.
require 'spec_helper'
context 'as a guest on the sign in page' do
#Make sure your factory generates a valid user for your authentication system
let(:user) { Factory(:user) }
#Browse to the homepage and click the Sign In link
before do
visit root_path
@paulelliott
paulelliott / integration_example_group.rb
Created July 7, 2010 03:32
RSpec Integration Example Group for Capybara
require 'action_dispatch'
require 'capybara/rails'
require 'capybara/dsl'
module RSpec::Rails
module IntegrationExampleGroup
extend ActiveSupport::Concern
include ActionDispatch::Integration::Runner
include RSpec::Rails::TestUnitAssertionAdapter
group :test do
gem "capybara", ">= 0.3.9"
gem "rspec-rails", ">= 2.0.0.beta.12"
end
@paulelliott
paulelliott / gist:833694
Created February 18, 2011 14:12
Proper Use of Fabricators - AR Model
class Model < ActiveRecord::Base
belongs_to :manufacturer
has_many :motorcycles
validates :name, presence: true, uniqueness: true
end
@paulelliott
paulelliott / gist:833687
Created February 18, 2011 14:04
Proper Use of Fabricators - AR classes
class Manufacturer < ActiveRecord::Base
has_many :models
validates_presence_of :name
end
class Model < ActiveRecord::Base
belongs_to :manufacturer
has_many :motorcycles
@paulelliott
paulelliott / gist:833708
Created February 18, 2011 14:25
Proper Use of Fabricators - Model Fabricator
Fabricator(:model) do
manufacturer!
name { Fabricate.sequence(:model_name) { |i| "Model #{i}" } }
end
@paulelliott
paulelliott / application.rb
Created February 28, 2011 02:42
mongoid generator
module YourApp
class Application < Rails::Application
config.generators do |g|
g.orm :mongoid
end
end
end
@paulelliott
paulelliott / comics_controller.rb
Created March 11, 2011 02:03
Merged create/update actions
class ComicsController < ApplicationController
respond_to :html
before_filter :authenticated
before_filter :authenticate_admin, except: :index
expose :comic
expose(:comics) do
User.find_by_username(params[:username]).try(:comics) || Comic.all
end