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 not allow adding apps that the site does not have' do | |
site = Site.gen # made while @user = User.gen | |
app1 = App.gen | |
app2 = App.gen | |
app3 = App.gen | |
site.apps << app1 | |
site.apps << app2 | |
site.save | |
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 PadrinoHelpers | |
require 'padrino-helpers' | |
include Padrino::Helpers::AssetTagHelpers | |
include Padrino::Helpers::TagHelpers | |
include Padrino::Helpers::OutputHelpers | |
end | |
# Foo had a #render method defined that was getting | |
# clobbered by OutputHelpers | |
class Foo |
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
# Transactional Fixtures Fix for DataMapper | |
# | |
# This prevents pooling limiting the db to one connection | |
# and allowing transactions to exist between different threads | |
# rack_test to selenium for example | |
module DataObjects | |
module Pooling | |
class Pool | |
alias orig_new new | |
def new |
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 AcceptableQuantityValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
return if value.nil? | |
order = Order.find(record[:order_id]) | |
currently_fulfilled = order.total_fulfilled | |
if record.new_record? | |
valid_fulfillment = order.quantity - currently_fulfilled | |
else | |
valid_fulfillment = order.quantity - (currently_fulfilled - record.quantity_was) |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click_link_or_button('Link Text') # Click either a link or a button | |
click('Button Value') |
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
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV) | |
require 'rubygems' | |
require 'spork' | |
Spork.prefork do | |
# Loading more in this block will cause your tests to run faster. However, | |
# if you change any configuration or code from libraries loaded here, you'll | |
# need to restart spork for it take effect. | |
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
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV) | |
require 'rubygems' | |
require 'spork' | |
Spork.prefork do | |
# Loading more in this block will cause your tests to run faster. However, | |
# if you change any configuration or code from libraries loaded here, you'll | |
# need to restart spork for it take effect. | |
require File.expand_path(File.dirname(__FILE__) + "/../config/boot") |
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
source :rubygems | |
# Project requirements | |
gem 'rake' | |
gem 'rack-flash' | |
gem 'thin' # or mongrel | |
# Component requirements | |
gem 'bcrypt-ruby', :require => "bcrypt" | |
gem 'compass' |
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
// jQuery Extended | |
var $ajax = $.ajax; | |
$.ajax = function(options){ | |
var options = $.extend({cache: false}, options || {}); | |
return $ajax(options); | |
} |
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
var dispatch = { | |
events: {}, | |
observe: function(action){ | |
this.events[action] = {}; | |
document.observe(action, function(ev){ | |
for(var x in dispatch.events[action]){ | |
if(ev.findElement(x)) return dispatch.events[action][x](ev); | |
} | |
}); |