aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAlexey Muranov <alexey.muranov@gmail.com>2011-12-29 16:36:00 +0100
committerAlexey Muranov <alexey.muranov@gmail.com>2011-12-30 10:34:02 +0100
commitb52d9d0ff585f3131e26317542df2971a667d319 (patch)
tree455644926a02390e85c29b3895856205df0d2609 /activerecord
parent7162ea2a0c75f270eab37217d1daa0268e258e71 (diff)
downloadrails-b52d9d0ff585f3131e26317542df2971a667d319.tar.gz
rails-b52d9d0ff585f3131e26317542df2971a667d319.tar.bz2
rails-b52d9d0ff585f3131e26317542df2971a667d319.zip
Fixes for TestFixtures::setup_fixture_accessors
Renamed "fixture_name" to "accessor_name" and made fixture names in the form "admin/users" be used as the key for the hashes @fixture_cache and @loaded_fixtures. Previously the variable "fixture_name" here was getting a value of the form "admin_user", and this value was then used as the hash key.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/fixtures.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 77e38e8efd..c59c00f424 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -511,8 +511,7 @@ module ActiveRecord
def initialize(connection, fixture_name, class_name, fixture_path)
@connection = connection
@fixture_path = fixture_path
- @name = fixture_name.tr('/', '_') # preserve fixture base name
- # TODO: see how it is used and if the substitution can be avoided
+ @name = fixture_name
@class_name = class_name
@fixtures = ActiveSupport::OrderedHash.new
@@ -790,9 +789,9 @@ module ActiveRecord
fixture_names = Array.wrap(fixture_names || fixture_table_names)
methods = Module.new do
fixture_names.each do |fixture_name|
- fixture_name = fixture_name.to_s.tr('./', '_') # TODO: use fixture_name variable for only one form of fixture names ("admin/users" for example)
+ accessor_name = fixture_name.tr('/', '_').to_sym
- define_method(fixture_name) do |*fixtures|
+ define_method(accessor_name) do |*fixtures|
force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload
@fixture_cache[fixture_name] ||= {}
@@ -805,13 +804,13 @@ module ActiveRecord
@fixture_cache[fixture_name][fixture] ||= @loaded_fixtures[fixture_name][fixture.to_s].find
end
else
- raise StandardError, "No fixture with name '#{fixture}' found for table '#{fixture_name}'"
+ raise StandardError, "No entry named '#{fixture}' found for fixture collection '#{fixture_name}'"
end
end
instances.size == 1 ? instances.first : instances
end
- private fixture_name
+ private accessor_name
end
end
include methods