33 satır
1 KiB
Ruby
33 satır
1 KiB
Ruby
#---
|
|
# Excerpted from "Agile Web Development with Rails",
|
|
# published by The Pragmatic Bookshelf.
|
|
# Copyrights apply to this code. It may not be used to create training material,
|
|
# courses, books, articles, and the like. Contact us if you are in doubt.
|
|
# We make no guarantees that this code is fit for any purpose.
|
|
# Visit http://www.pragmaticprogrammer.com/titles/rails4 for more book information.
|
|
#---
|
|
ENV["RAILS_ENV"] = "test"
|
|
require File.expand_path('../../config/environment', __FILE__)
|
|
require 'rails/test_help'
|
|
|
|
class ActiveSupport::TestCase
|
|
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
#
|
|
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
# -- they do not yet inherit this setting
|
|
fixtures :all
|
|
# ...
|
|
|
|
# Add more helper methods to be used by all tests here...
|
|
def login_as(user)
|
|
session[:user_id] = users(user).id
|
|
end
|
|
|
|
def logout
|
|
session.delete :user_id
|
|
end
|
|
|
|
def setup
|
|
login_as :one if defined? session
|
|
end
|
|
end
|