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
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
# 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
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
# 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
#!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
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
Question.where(created_at: (15.days.ago)..(Time.now)) | |
.limit(limit) | |
.joins(:impressions) | |
.group("impressions.impressionable_id") |
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
# add to <tt>layout_helper.rb</tt>: | |
def rostra_page_title | |
case "#{controller_name}##{action_name}" | |
when "questions#show" then @question.title | |
when "questions#index" then | |
if params[:tag_search].present? | |
"Recent Questions" | |
else | |
"Recent Questions for tag #{params[:tag_search]}" | |
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
cache: [POST /conversation/questions/4/answers] invalidate, pass | |
Started POST "/conversation/questions/4/answers" for 127.0.0.1 at 2011-10-26 11:39:29 -0500 | |
Processing by Rostra::AnswersController#create as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"kMghcRVWRnEZHKdb5lE43qQ2uByACYLkcGLaR10Uvis=", "answer"=>{"user_id"=>"2164", "question_id"=>"4", "text"=>"<p>An answer</p>", "follow_by_email"=>"1"}, "commit"=>"Answer", "question_id"=>"4"} | |
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2164 LIMIT 1 | |
Role Load (0.7ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles"."id" = "roles_users"."role_id" WHERE "roles_users"."user_id" = 2164 AND "roles"."name" = 'super_admin' LIMIT 1 | |
Role Load (0.8ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles"."id" = "roles_users"."role_id" WHERE "roles_users"."user_id" = 2164 AND "roles"."name" = 'member' LIMIT 1 | |
Profile Load (0.4ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = 21 |