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 |
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) |
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 |
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 |
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/ |
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 |
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 |
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? |
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 'roleful' | |
@klass = Class.new do | |
attr_reader :role | |
def initialize(*role) | |
@role = role.empty? ? :null : role | |
end | |
include Roleful | |
end | |
user = @klass.new(:debugulator) |
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
# Works: | |
require 'test_helper' | |
class RootControllerTest < ActionController::TestCase | |
setup :activate_authlogic | |
context "A User" do | |
setup do |