This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Unit test | |
test "should create record" do | |
plan = Fabricate(:free_plan) | |
account = Fabricate(:account, :agents => [ Fabricate.build(:agent) ]) | |
Fabricate.build(:free_subscription, :plan => plan, :account => account) | |
assert account.valid?, "Account was invalid\n#{account.errors.to_yaml}" | |
end | |
# Fabricators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order < ActiveRecord::Base | |
belongs_to :order_type | |
has_many :contacts | |
def delivered | |
self.contacts.length | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CompanyDocument < ActiveRecord::Base | |
has_many :documents, :as => :document_references, :dependent => :destroy | |
accepts_nested_attributes_for :documents, :allow_destroy => true, :reject_if => proc { |attributes| attributes['document'].blank? && attributes['_destroy'] == '0' } | |
end | |
class Document < ActiveRecord::Base | |
belongs_to :document_references, :polymorphic => true | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Email model | |
class EmailAddress < ActiveRecord::Base | |
belongs_to :emailable, :polymorhpic => true | |
validates_presence_of :address | |
validates_format_of :address, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i | |
attr_accessible :address, :location | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MacBook-Pro:turnstile-stable(1m|master) $ cap newrelic:notice_deployment -Snewrelic_desc="This is a test" | |
* executing `newrelic:notice_deployment' | |
* Getting log of changes for New Relic Deployment details | |
** Error creating New Relic deployment (undefined local variable or method `source' for #<Capistrano::Configuration::Namespaces::Namespace:0x0000010148e110>) | |
** /Users/james/.rvm/gems/ruby-1.9.2-p0@turnstile-stable/gems/capistrano-2.6.0/lib/capistrano/configuration/namespaces.rb:188:in `method_missing' | |
** /Users/james/.rvm/gems/ruby-1.9.2-p0@turnstile-stable/gems/newrelic_rpm-3.1.0/lib/new_relic/recipes.rb:28:in `block (3 levels) in <top (required)>' | |
** /Users/james/.rvm/gems/ruby-1.9.2-p0@turnstile-stable/gems/capistrano-2.6.0/lib/capistrano/configuration/execution.rb:139:in `instance_eval' | |
** /Users/james/.rvm/gems/ruby-1.9.2-p0@turnstile-stable/gems/capistrano-2.6.0/lib/capistrano/configuration/execution.rb:139:in `invoke_task_directly' | |
** /Users/james/.rvm/gems/ruby-1.9.2-p0@turnstile-stable/g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def manage_thing(args={}) | |
args.each do |action, object| | |
case action | |
when :create | |
# create code | |
when :remove | |
# removal code | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example: | |
def example(class) | |
class.constantize.all | |
end | |
# Calling it: | |
example('person') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "should save latlng in db" do | |
@venue = Fabricate(:venue) | |
expect { Venue.find_address(@venue.id) }.to change(@venue, :latlng).to([51.5339146, 0.7840745000000001]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## lib/test/test.rb | |
require 'lib/test/app/models/card' | |
require 'lib/test/exts/user' | |
## lib/test/exts/user.rb | |
module Test | |
module User | |
module ClassMethods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- Helpful things to keep in your <head/> | |
// Brian Blakely, 360i | |
// http://twitter.com/brianblakely/ | |
--> | |
<head> | |
<!-- Disable automatic DNS prefetching. | |
OlderNewer