View logged_in_as.rb
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
# Doesn't work when user arg is a reference to variable in an outer context | |
class Test::Unit::TestCase | |
def self.logged_in_as(user, &block) | |
context "logged in as #{user}" do | |
setup do | |
UserSession.create(user) | |
end | |
merge_block(&block) if block_given? |
View should_accept_nested_attributes_for.rb
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 Test::Unit::TestCase | |
# Assert that the model accepts nested attributes for the given +associations+ | |
# | |
# Example: | |
# should_accept_nested_attributes_for :orders | |
# | |
def self.should_accept_nested_attributes_for(*associations) | |
associations.each do |association| | |
should "accept nested attributes for #{association}" do |
View link_to.rb
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
# Extension to #link_to to automagically accept an ActiveRecord instance. | |
# Accepts an optional <tt>:with_icon => true</tt> which will add AR instance's icon as a background image and set the appropriate css classes. | |
# | |
# ==== Examples: | |
# <tt>link_to(@user) => link_to(@user.to_s, user_path(@user))</tt> | |
# <tt>link_to(@user) { 'User Foo' } => link_to('User Foo', user_path(@user))</tt> | |
def link_to(*args, &block) | |
if args.first.kind_of?(ActiveRecord::Base) | |
record = args.first | |
name = block_given? ? capture(&block) : record.to_s |
View authlogic-2.1.3 test failure.txt
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
$ rake | |
(in /<snip>/authlogic-2.1.3) | |
All dependencies seem to be installed. | |
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I"lib:test" "/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/acts_as_authentic_test/base_test.rb" "test/acts_as_authentic_test/email_test.rb" "test/acts_as_authentic_test/logged_in_status_test.rb" "test/acts_as_authentic_test/login_test.rb" "test/acts_as_authentic_test/magic_columns_test.rb" "test/acts_as_authentic_test/password_test.rb" "test/acts_as_authentic_test/perishable_token_test.rb" "test/acts_as_authentic_test/persistence_token_test.rb" "test/acts_as_authentic_test/restful_authentication_test.rb" "test/acts_as_authentic_test/session_maintenance_test.rb" "test/acts_as_authentic_test/single_access_test.rb" "test/authenticates_many_test.rb" "test/crypto_provider_test/aes256_test.rb" "test/crypto_provider_test/bcrypt_test.rb" "test/crypto_provider_test/sha1_test.rb" "test/crypto_provider_test/sha256_test.rb" "test/crypto_provider_test/ |
View authlogic-2.1.1 -> authlogic-2.1.3 test failures.rb
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
require 'test_helper' | |
class UserSessionTest < ActiveSupport::TestCase | |
setup :activate_authlogic | |
context "A Participant" do | |
setup do | |
@participant = Factory(:participant) | |
assert @participant.password.present? | |
end |
View hoptoad gem generator failure.txt
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
$ script/generate hoptoad --api-key 9<snip>4 | |
/<snip>/vendor/gems/thoughtbot-paperclip-2.3.1/lib/paperclip.rb:47: warning: already initialized constant VERSION | |
** Erubis 2.6.5 | |
exists lib/tasks | |
create lib/tasks/hoptoad_notifier_tasks.rake | |
insert | |
Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier| | |
$: << File.join(vendored_notifier, 'lib') | |
end |
View i18n_controller.rb
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 I18nController < ApplicationController | |
caches_page :show | |
# Renders HTTP cacheable JSON encoded dictionary of translation strings for requested locale and currently selected locale | |
def show | |
@locale = params[:locale].to_sym | |
raise ActiveRecord::RecordNotFound unless I18n.selectable_locales.include?(@locale) | |
respond_to do |format| | |
format.js do | |
@strings = I18n.t('javascript', :locale => @locale) |
View application_controller.rb
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 ApplicationController < ActionController::Base | |
# alias_method :rescue_action_locally, :rescue_action_in_public # Uncomment to test in development environment. | |
def render_optional_error_file(status_code) | |
request.format = 'html' # Force html format so that requests to the likes of /foo/bar.png result in an HTML error page. | |
render :template => 'errors/http_error', :status => status_code, :locals => {:status_code => status_code} | |
end | |
end |
View active_record_extensions.rb
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
module ActiveRecordExtensions | |
module ClassExtensions | |
# Returns +Array+ of all +ActiveRecord+ model classes | |
def models | |
Dir.glob(Rails.root.join('app', 'models', '**', '*rb')).each do |model| | |
ActiveSupport::Dependencies::Loadable.require_or_load model | |
end | |
Object.subclasses_of ActiveRecord::Base |
View identify_mimetypes_middleware.rb
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
# Adobe Flash fails to pass the correct mime-type when POSTing files. | |
# This piece of middleware is used to correctify the matter | |
# | |
# N.B. Requires `file` command so will probably only work on POSIX systems | |
# | |
# To use add this to an initializer: | |
# ActionController::Dispatcher.middleware.insert_after(ActionController::ParamsParser, IdentifyMimetypesMiddleware, /^(Adobe|Shockwave) Flash/) | |
require 'rack/utils' |