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 EncodingFixer | |
ENCODING_TO_ENTITY = { | |
"\222" => "’", | |
"\223" => "“", | |
"\224" => "”", | |
"\205" => "…", | |
"\226" => "–", | |
"\227" => "—" | |
} |
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
#!bash | |
# | |
# bash completion support for core Git. | |
# | |
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> | |
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
# Distributed under the GNU General Public License, version 2.0. | |
# | |
# The contained completion routines provide support for completing: | |
# |
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
# Having trouble getting nested factories working. Is this not supported? Seems like it would be. | |
# | |
# The associations are definitely setup correctly in the models: | |
# A campaign has_many :placements and a placement has_many :deliveries | |
# | |
@campaign = Factory(:campaign, :placements => [ | |
Factory(:placement, :agency_rate => 3.00, :deliveries => [ | |
Factory(:delivery, :quantity => 600), | |
Factory(:delivery, :quantity => 100) | |
]), |
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
Background: Analyst logged in and viewing campaigns # features/campaigns.feature:6 | |
Given campaign "ABC001" has ordered "50_000" and so far billed: # features/step_definitions/custom_steps.rb:25 | |
| posting period | billable total | billed total | | |
| Jun 2009 | 10_000 | 10_000 | | |
| Jul 2009 | 15_000 | 15_000 | | |
| Aug 2009 | 20_000 | 20_000 | | |
And campaign "ABC002" has ordered "250_000" and so far billed: # features/step_definitions/custom_steps.rb:25 | |
| posting period | billable total | billed total | | |
| Jun 2009 | 100_000 | 100_000 | | |
| Jul 2009 | 50_000 | 50_000 | |
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
# Any idea why this works: | |
named_scope :delivering_during, lambda { all(:include => {:campaign_billables => [:posting_period] }) } | |
# but this: | |
named_scope :delivering_during, all(:include => {:campaign_billables => [:posting_period] }) | |
# raises "TypeError (Symbol as array index)" |
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
describe "AFTER CREATE apply_member_role" do | |
it "should apply the role of 'user' to the newly created user" do | |
user = Factory(:user) | |
user.role?('member').should be_true | |
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
Factory.define :user do |f| | |
f.sequence(:email) { |n| "foo#{n}@example.com" } | |
f.email_confirmation { |u| u.email } | |
f.password "password" | |
f.password_confirmation { |u| u.password } | |
end | |
Factory.define :super_admin, :parent => :user do |f| | |
f.after_create { |user| user.roles << Role.find_or_create_by_name('super_admin') } | |
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
# in spec helper | |
class User | |
def role?(role) | |
true | |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<head> | |
<style> | |
.contenta {margin-top: 25px;} | |
.contenta h1 {color: #333; font-weight: normal; border-bottom: 1px solid #bbb; margin: 25px 0px; padding-bottom: 7px;} | |
.contenta h2 {color: #777; font-weight: normal; margin: 20px 0px 0px 2px;} | |
</style> |
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
Dewey.authentication :client, :email => 'your-email', :password => 'your-pass' | |
id = Dewey.put(File.new('example.txt'), 'My Second Upload') | |
puts id # => in my case returned: document:1DDxIGsmK3wIJpdJC-qGK4y-R8onzDrBPm89y7BbO_Zg | |
original = Dewey.get(id) | |
puts original.inspect # => nil |