This file contains hidden or 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
# https://rails.lighthouseapp.com/projects/8994/tickets/4743-session-cookie-breaks-if-used-with-custom-cookie-in-rails-238 | |
# http://gist.github.com/431811 | |
if Rails.version == '2.3.8' | |
class RackRailsCookieHeaderHack | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
status, headers, body = @app.call(env) |
This file contains hidden or 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
# https://rspec.lighthouseapp.com/projects/16211/tickets/305 | |
require 'singleton' | |
module NegativeExpectationsHelper | |
class State | |
include Singleton | |
def is_negative? | |
@negative === true |
This file contains hidden or 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
Given %r`a guest(?: user)? named "([^\"]+)" for the "([^\"]+)" store$` do |login, uri| | |
store = Store.find_by_slug!(uri) | |
User.make(:guest, :login => login, :store => store) | |
end | |
Given %r`not logged in$` do | |
s = UserSession.destroy | |
end | |
Given %r`(?:log|am logged) in as "([^\"]+)"$` do |login| |
This file contains hidden or 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
gem 'ruby-debug', :group => [:test, :cucumber, :development] | |
gem 'email_spec', :group => [:test, :cucumber], :require => 'email_spec' | |
group :test do | |
gem 'rspec-rails', '>= 1.3.2' | |
end | |
group :cucumber do | |
gem 'cucumber-rails', '>=0.3.1' | |
gem 'database_cleaner', '>=0.5.0' |
This file contains hidden or 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
# an example of composition using value classes | |
class Person < ActiveRecord::Base | |
# "gender" (string) column will use Gender value class | |
# to represent it instead of string | |
composed_of :gender | |
end | |
This file contains hidden or 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
ErrorDocument 503 /system/maintenance.html | |
RewriteCond %{REQUEST_URI} !.(css|gif|jpg|png)$ | |
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f | |
RewriteCond %{SCRIPT_FILENAME} !maintenance.html | |
RewriteRule ^.*$ - [redirect=503,last] |
This file contains hidden or 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
<?php | |
$revcaptcha = md5($_SERVER['REMOTE_ADDR'] . 'random_salt'); | |
function check_revcaptcha($key1, $key2, $revcaptcha) { | |
if ($_POST[$key1] == '' && $_POST[$key2] == $revcaptcha) { | |
unset( $_POST[$key1] ); | |
unset( $_POST[$key2] ); | |
return true; | |
} else { | |
return false; |
This file contains hidden or 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
# usage: | |
# field_labeled('Select your address').should have_option("Home Address") | |
Spec::Matchers.define :have_option do |expected| | |
def options_for(select_field) | |
select_field.options.map(&:inner_text) | |
end | |
match do |select_field| | |
raise "Field is not a SelectField" unless select_field.kind_of?(Webrat::SelectField) | |
options_for(select_field).include?(expected) |
This file contains hidden or 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
SELECT @old_domain:='stage.example.com'; | |
SELECT @new_domain:='www.example.com'; | |
UPDATE wp_postmeta SET | |
meta_value=REPLACE(meta_value, @old_domain, @new_domain); | |
UPDATE wp_posts SET | |
post_content=REPLACE(post_content, @old_domain, @new_domain), | |
post_excerpt=REPLACE(post_excerpt, @old_domain, @new_domain), | |
guid=REPLACE(guid, @old_domain, @new_domain); |
This file contains hidden or 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
# Use an instance for the top-level form_for | |
form_for @parent do |f| | |
# Always use a symbol to access the nested association from f.object | |
f.fields_for :child do |fc| | |
# generates: params[:parent][:child_attributes][:field] | |
end | |
# Optionally, provide an instance as a *second* argument | |
f.fields_for :relative, (@other_parent or Person.new) do |fr| |