factory_girl 2.0.0.beta4 → 2.0.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
data/features/support/test.db
CHANGED
Binary file
|
@@ -5,13 +5,8 @@ module FactoryGirlStepHelpers
|
|
5
5
|
return if value.blank?
|
6
6
|
factory = FactoryGirl.factory_by_name(factory_name)
|
7
7
|
attributes = convert_human_hash_to_attribute_hash({attribute => value.strip}, factory.associations)
|
8
|
-
attributes_find = {}
|
9
|
-
attributes.each do |k, v|
|
10
|
-
k = "#{k}_id" if v.is_a? ActiveRecord::Base
|
11
|
-
attributes_find[k] = v
|
12
|
-
end
|
13
8
|
model_class = factory.build_class
|
14
|
-
model_class.find(:first, :conditions =>
|
9
|
+
model_class.find(:first, :conditions => attributes) or
|
15
10
|
FactoryGirl.create(factory_name, attributes)
|
16
11
|
end
|
17
12
|
|
@@ -19,7 +14,9 @@ module FactoryGirlStepHelpers
|
|
19
14
|
human_hash.inject({}) do |attribute_hash, (human_key, value)|
|
20
15
|
key = human_key.downcase.gsub(' ', '_').to_sym
|
21
16
|
if association = associations.detect {|association| association.name == key }
|
22
|
-
|
17
|
+
association_instance = convert_association_string_to_instance(association.factory, value)
|
18
|
+
key = "#{key}_id"
|
19
|
+
value = association_instance.id if association_instance
|
23
20
|
end
|
24
21
|
attribute_hash.merge(key => value)
|
25
22
|
end
|
data/lib/factory_girl/version.rb
CHANGED