1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Deprecated load_all_fixtures [#65]

* Use `fixtures :all` instead
This commit is contained in:
Ryan McGeary 2008-09-02 16:49:13 -04:00
parent c2e908e58b
commit 42d4de6e97
12 changed files with 20 additions and 30 deletions

View file

@ -48,7 +48,7 @@ So readable!
Quick macro tests for your ActiveRecord associations and validations:
class PostTest < Test::Unit::TestCase
load_all_fixtures
fixtures :all
should_belong_to :user
should_have_many :tags, :through => :taggings
@ -60,8 +60,6 @@ Quick macro tests for your ActiveRecord associations and validations:
end
class UserTest < Test::Unit::TestCase
load_all_fixtures
should_have_many :posts
should_not_allow_values_for :email, "blah", "b lah"

View file

@ -22,11 +22,10 @@ module ThoughtBot # :nodoc:
#
module Macros
# Loads all fixture files (<tt>test/fixtures/*.yml</tt>)
# Deprecated: Use <tt>fixtures :all</tt> instead
def load_all_fixtures
all_fixtures = Dir.glob(File.join(Test::Unit::TestCase.fixture_path, "*.yml")).collect do |f|
File.basename(f, '.yml').to_sym
end
fixtures *all_fixtures
warn "[DEPRECATION] load_all_fixtures is deprecated. Use `fixtures :all` instead."
fixtures :all
end
# Ensures that the model cannot be saved if one of the attributes listed is not present.

View file

@ -12,7 +12,7 @@ module ThoughtBot # :nodoc:
#
# Example:
# class UsersControllerTest < Test::Unit::TestCase
# load_all_fixtures
# fixtures :all
#
# def setup
# ...normal setup code...

View file

@ -5,7 +5,7 @@ require 'posts_controller'
class PostsController; def rescue_action(e) raise e end; end
class PostsControllerTest < Test::Unit::TestCase
load_all_fixtures
fixtures :all
def setup
@controller = PostsController.new
@ -25,14 +25,14 @@ class PostsControllerTest < Test::Unit::TestCase
resource.denied.actions = [:index, :show, :edit, :new, :create, :update, :destroy]
resource.denied.flash = /what/i
resource.denied.redirect = '"/"'
end
end
end
context "Logged in" do
setup do
@request.session[:logged_in] = true
end
should_be_restful do |resource|
resource.parent = :user

View file

@ -5,7 +5,7 @@ require 'users_controller'
class UsersController; def rescue_action(e) raise e end; end
class UsersControllerTest < Test::Unit::TestCase
load_all_fixtures
fixtures :all
def setup
@controller = UsersController.new
@ -21,16 +21,16 @@ class UsersControllerTest < Test::Unit::TestCase
resource.parent = []
resource.actions = [:index, :show, :new, :edit, :update, :create, :destroy]
resource.formats = [:html, :xml]
resource.create.params = { :name => "bob", :email => 'bob@bob.com', :age => 13, :ssn => "123456789"}
resource.update.params = { :name => "sue" }
resource.create.redirect = "user_url(@user)"
resource.update.redirect = "user_url(@user)"
resource.destroy.redirect = "users_url"
resource.create.flash = /created/i
resource.update.flash = /updated/i
resource.destroy.flash = /removed/i
resource.destroy.flash = /removed/i
end
end

View file

@ -1,11 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class AddressTest < Test::Unit::TestCase
load_all_fixtures
fixtures :all
should_belong_to :addressable
should_require_unique_attributes :title, :scoped_to => [:addressable_id, :addressable_type]
should_ensure_length_at_least :zip, 5
should_only_allow_numeric_values_for :zip
should_only_allow_numeric_values_for :zip
end

View file

@ -1,7 +1,6 @@
require File.dirname(__FILE__) + '/../test_helper'
class DogTest < Test::Unit::TestCase
load_all_fixtures
should_belong_to :user
should_belong_to :address
should_have_and_belong_to_many :fleas

View file

@ -1,7 +1,6 @@
require File.dirname(__FILE__) + '/../test_helper'
class FleaTest < Test::Unit::TestCase
load_all_fixtures
should_have_and_belong_to_many :dogs
end

View file

@ -1,13 +1,13 @@
require File.dirname(__FILE__) + '/../test_helper'
class PostTest < Test::Unit::TestCase
load_all_fixtures
fixtures :all
should_belong_to :user
should_belong_to :owner
should_have_many :tags, :through => :taggings
should_have_many :through_tags, :through => :taggings
should_require_unique_attributes :title
should_require_attributes :body, :message => /wtf/
should_require_attributes :title

View file

@ -1,11 +1,9 @@
require File.dirname(__FILE__) + '/../test_helper'
class TagTest < Test::Unit::TestCase
load_all_fixtures
should_have_many :taggings, :dependent => :destroy
should_have_many :posts
should_ensure_length_at_least :name, 2
should_protect_attributes :secret

View file

@ -1,8 +1,6 @@
require File.dirname(__FILE__) + '/../test_helper'
class TaggingTest < Test::Unit::TestCase
load_all_fixtures
should_belong_to :post
should_belong_to :tag
end

View file

@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../test_helper'
class UserTest < Test::Unit::TestCase
load_all_fixtures
fixtures :all
should_have_many :posts
should_have_many :dogs