Skip to content

Instantly share code, notes, and snippets.

View ozzyaaron's full-sized avatar

Aaron Todd ozzyaaron

View GitHub Profile
Feature: Allocating bucket activities
As a user
I want to allocate activity paddocks in the bucket season to real seasons
So that costs are accounted properly
Background:
Given there is a farmer
And the farmer has a bucket season
And the farmer has a season called Winter
And the farmer has a season called Summer
require "rubygems"
require "awesome_print"
unless IRB.version.include?('DietRB')
IRB::Irb.class_eval do
def output_value
ap @context.last_value
end
end
else # MacRuby
def process_params_sort_key
# Remove the sort if someone is trying to forge it...
if params[:sort] && params[:sort].match(/(drop|=|--|;|'|")/)
debugger
send_exceptional(StandardError.new("Angelina Jolie in the house..."), "Params hacking detected")
params.delete(:sort)
end
end
@ozzyaaron
ozzyaaron / invoice.rb
Created October 7, 2011 07:39
Decorator?
class Invoice
attr_accessor :a, :b, :c, :name
def to_s
name
end
end
require File.dirname(__FILE__) + "/acceptance_helper"
describe "Creating an article" do
let(:user) { Factory(:user) }
context "as a user" do
before do
login_user(user)
# Integration testing
gem "capybara", "~> 1.0.0"
gem "steak", "~> 1.1.0"
gem "launchy", "~> 0.4.0"
gem "database_cleaner"
def contact_details=(contacts)
return if contacts.nil?
contacts = contacts.values if contacts.kind_of? Hash
self.class.transaction do
phone_numbers.destroy_all
email_addresses.destroy_all
contacts.each do |contact|
<a class="add_fields" href="#" onclick="add_fields(this, &quot;bookings&quot;, &quot;booking&quot;, &quot;&lt;div class=\'booking remove_fields_target\'&gt;\n&lt;div class=\'booking_header\'&gt;\n&lt;span class=\'title\'&gt;Trip &lt;\/span&gt;\n&lt;\/div&gt;\n\n&lt;input id=\&quot;booking_group_bookings_attributes_new_bookings_site_id\&quot; name=\&quot;booking_group[bookings_attributes][new_bookings][site_id]\&quot; type=\&quot;hidden\&quot; value=\&quot;100024\&quot; /&gt;\n&lt;input id=\&quot;booking_group_bookings_attributes_new_bookings_created_by\&quot; name=\&quot;booking_group[bookings_attributes][new_bookings][created_by]\&quot; type=\&quot;hidden\&quot; value=\&quot;100513\&quot; /&gt;\n&lt;input id=\&quot;booking_group_bookings_attributes_new_bookings_created_with_new_booking_group_centric_form\&quot; name=\&quot;booking_group[bookings_attributes][new_bookings][created_with_new_booking_group_centric_form]\&quot; type=\&quot;hidden\&quot; value=\&quot;1\&quot; /&gt;\n&lt;input id=\&quot;booking_grou
From Ubuntu
:~$ curl -v https://api.xero.com/api.xro/2.0/Contacts
* About to connect() to api.xero.com port 443 (#0)
* Trying 174.143.224.225... connected
* Connected to api.xero.com (174.143.224.225) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
def self.up
function_string = 'CREATE OR REPLACE FUNCTION searchable_number(v_input text)
RETURNS numeric AS $$
DECLARE v_numeric_value numeric DEFAULT NULL;
BEGIN
BEGIN
v_numeric_value := v_input::NUMERIC;
EXCEPTION WHEN OTHERS THEN
RAISE NOTICE \'Invalid numeric value: "%". Returning NULL.\', v_input;
RETURN NULL;