From 105e892dd211410884d825ca115757113b2394cc Mon Sep 17 00:00:00 2001 From: Joshua Clayton Date: Fri, 16 Dec 2011 12:13:59 -0500 Subject: [PATCH] Get aliases working --- lib/factory_girl/attribute_assigner.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/factory_girl/attribute_assigner.rb b/lib/factory_girl/attribute_assigner.rb index 9e67c27..8930246 100644 --- a/lib/factory_girl/attribute_assigner.rb +++ b/lib/factory_girl/attribute_assigner.rb @@ -42,8 +42,7 @@ module FactoryGirl end def attribute_names_to_assign - override_names = @evaluator.__overrides.keys - non_ignored_attribute_names + override_names - ignored_attribute_names + (non_ignored_attribute_names + override_names - ignored_attribute_names - aliases_to_ignore) end def non_ignored_attribute_names @@ -57,5 +56,15 @@ module FactoryGirl def association_names @attribute_list.select(&:association?).map(&:name) end + + def override_names + @evaluator.__overrides.keys + end + + def aliases_to_ignore + @attribute_list.reject(&:ignored).map do |attribute| + override_names.map {|o| attribute.name if attribute.alias_for?(o) && attribute.name != o } + end.flatten.compact + end end end