Permalink
Browse files

Deprecated load_all_fixtures [#65]

 * Use `fixtures :all` instead
  • Loading branch information...
1 parent c2e908e commit 42d4de6e9747dbc74ce1e6b086fbb5b1a924ddb3 @rmm5t rmm5t committed Sep 2, 2008
View
@@ -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"
@@ -22,11 +22,10 @@ module ActiveRecord # :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.
@@ -12,7 +12,7 @@ module Controller
#
# Example:
# class UsersControllerTest < Test::Unit::TestCase
- # load_all_fixtures
+ # fixtures :all
#
# def setup
# ...normal setup code...
@@ -5,7 +5,7 @@
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 @@ def setup
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
@@ -5,7 +5,7 @@
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 @@ def setup
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit 42d4de6

Please sign in to comment.