mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Get aliases working
This commit is contained in:
parent
2c04d53635
commit
105e892dd2
1 changed files with 11 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue