factory_girl 2.0.0.beta4 → 2.0.0.beta5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 => attributes_find) or
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
- value = convert_association_string_to_instance(association.factory, value)
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
@@ -1,4 +1,4 @@
1
1
  module FactoryGirl
2
- VERSION = "2.0.0.beta4"
2
+ VERSION = "2.0.0.beta5"
3
3
  end
4
4
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: factory_girl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 2.0.0.beta4
5
+ version: 2.0.0.beta5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Joe Ferris