factory_girl 4.5.0 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +25 -5
- data/Appraisals +11 -7
- data/CONTRIBUTING.md +44 -6
- data/GETTING_STARTED.md +175 -59
- data/Gemfile +5 -0
- data/Gemfile.lock +86 -63
- data/LICENSE +1 -1
- data/NEWS +12 -1
- data/README.md +21 -10
- data/Rakefile +1 -3
- data/factory_girl.gemspec +6 -14
- data/gemfiles/3.2.gemfile +4 -1
- data/gemfiles/3.2.gemfile.lock +84 -52
- data/gemfiles/4.0.gemfile +4 -1
- data/gemfiles/4.0.gemfile.lock +75 -49
- data/gemfiles/4.1.gemfile +4 -1
- data/gemfiles/4.1.gemfile.lock +78 -48
- data/gemfiles/4.2.gemfile +10 -0
- data/gemfiles/4.2.gemfile.lock +123 -0
- data/gemfiles/5.0.gemfile +10 -0
- data/gemfiles/5.0.gemfile.lock +126 -0
- data/lib/factory_girl.rb +13 -4
- data/lib/factory_girl/attribute/dynamic.rb +4 -1
- data/lib/factory_girl/attribute_assigner.rb +2 -2
- data/lib/factory_girl/configuration.rb +4 -0
- data/lib/factory_girl/decorator.rb +2 -2
- data/lib/factory_girl/decorator/class_key_hash.rb +2 -1
- data/lib/factory_girl/definition_proxy.rb +2 -2
- data/lib/factory_girl/evaluator.rb +4 -0
- data/lib/factory_girl/factory_runner.rb +7 -1
- data/lib/factory_girl/find_definitions.rb +1 -1
- data/lib/factory_girl/linter.rb +65 -14
- data/lib/factory_girl/strategy/stub.rb +25 -1
- data/lib/factory_girl/strategy_syntax_method_registrar.rb +4 -0
- data/lib/factory_girl/version.rb +1 -1
- metadata +26 -185
- data/features/find_definitions.feature +0 -75
- data/features/step_definitions/database_steps.rb +0 -9
- data/features/step_definitions/factory_girl_steps.rb +0 -36
- data/features/support/env.rb +0 -10
- data/features/support/factories.rb +0 -16
- data/gemfiles/3.1.gemfile +0 -7
- data/gemfiles/3.1.gemfile.lock +0 -91
- data/spec/acceptance/activesupport_instrumentation_spec.rb +0 -62
- data/spec/acceptance/aliases_spec.rb +0 -19
- data/spec/acceptance/attribute_aliases_spec.rb +0 -45
- data/spec/acceptance/attribute_existing_on_object_spec.rb +0 -68
- data/spec/acceptance/attributes_for_spec.rb +0 -97
- data/spec/acceptance/attributes_from_instance_spec.rb +0 -53
- data/spec/acceptance/attributes_ordered_spec.rb +0 -51
- data/spec/acceptance/build_list_spec.rb +0 -56
- data/spec/acceptance/build_spec.rb +0 -86
- data/spec/acceptance/build_stubbed_spec.rb +0 -161
- data/spec/acceptance/callbacks_spec.rb +0 -253
- data/spec/acceptance/create_list_spec.rb +0 -97
- data/spec/acceptance/create_pair_spec.rb +0 -32
- data/spec/acceptance/create_spec.rb +0 -116
- data/spec/acceptance/define_child_before_parent_spec.rb +0 -21
- data/spec/acceptance/defining_methods_inside_a_factory_spec.rb +0 -17
- data/spec/acceptance/definition_camel_string_spec.rb +0 -15
- data/spec/acceptance/definition_spec.rb +0 -21
- data/spec/acceptance/definition_without_block_spec.rb +0 -15
- data/spec/acceptance/global_initialize_with_spec.rb +0 -82
- data/spec/acceptance/global_to_create_spec.rb +0 -122
- data/spec/acceptance/initialize_with_spec.rb +0 -217
- data/spec/acceptance/keyed_by_class_spec.rb +0 -22
- data/spec/acceptance/lint_spec.rb +0 -65
- data/spec/acceptance/modify_factories_spec.rb +0 -184
- data/spec/acceptance/modify_inherited_spec.rb +0 -52
- data/spec/acceptance/nested_attributes_spec.rb +0 -32
- data/spec/acceptance/overrides_spec.rb +0 -61
- data/spec/acceptance/parent_spec.rb +0 -90
- data/spec/acceptance/private_attributes_spec.rb +0 -20
- data/spec/acceptance/register_strategies_spec.rb +0 -136
- data/spec/acceptance/sequence_context_spec.rb +0 -52
- data/spec/acceptance/sequence_spec.rb +0 -61
- data/spec/acceptance/skip_create_spec.rb +0 -19
- data/spec/acceptance/stub_spec.rb +0 -62
- data/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb +0 -51
- data/spec/acceptance/traits_spec.rb +0 -727
- data/spec/acceptance/transient_attributes_spec.rb +0 -151
- data/spec/factory_girl/aliases_spec.rb +0 -31
- data/spec/factory_girl/attribute/association_spec.rb +0 -28
- data/spec/factory_girl/attribute/dynamic_spec.rb +0 -52
- data/spec/factory_girl/attribute/sequence_spec.rb +0 -16
- data/spec/factory_girl/attribute/static_spec.rb +0 -19
- data/spec/factory_girl/attribute_list_spec.rb +0 -143
- data/spec/factory_girl/attribute_spec.rb +0 -16
- data/spec/factory_girl/callback_spec.rb +0 -41
- data/spec/factory_girl/declaration/implicit_spec.rb +0 -25
- data/spec/factory_girl/declaration_list_spec.rb +0 -67
- data/spec/factory_girl/definition_proxy_spec.rb +0 -215
- data/spec/factory_girl/definition_spec.rb +0 -64
- data/spec/factory_girl/disallows_duplicates_registry_spec.rb +0 -19
- data/spec/factory_girl/evaluator_class_definer_spec.rb +0 -77
- data/spec/factory_girl/factory_spec.rb +0 -259
- data/spec/factory_girl/find_definitions_spec.rb +0 -110
- data/spec/factory_girl/null_factory_spec.rb +0 -13
- data/spec/factory_girl/null_object_spec.rb +0 -22
- data/spec/factory_girl/registry_spec.rb +0 -68
- data/spec/factory_girl/sequence_spec.rb +0 -95
- data/spec/factory_girl/strategy/attributes_for_spec.rb +0 -18
- data/spec/factory_girl/strategy/build_spec.rb +0 -7
- data/spec/factory_girl/strategy/create_spec.rb +0 -25
- data/spec/factory_girl/strategy/stub_spec.rb +0 -38
- data/spec/factory_girl/strategy_calculator_spec.rb +0 -29
- data/spec/factory_girl_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -26
- data/spec/support/macros/define_constant.rb +0 -86
- data/spec/support/matchers/callback.rb +0 -9
- data/spec/support/matchers/declaration.rb +0 -83
- data/spec/support/matchers/delegate.rb +0 -44
- data/spec/support/matchers/trait.rb +0 -11
- data/spec/support/shared_examples/strategy.rb +0 -90
@@ -0,0 +1,10 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
6
|
+
gem "jdbc-sqlite3", :platforms => :jruby
|
7
|
+
gem "sqlite3", "~> 1.3.10", :platforms => :ruby
|
8
|
+
gem "activerecord", "~> 5.0.0.beta2"
|
9
|
+
|
10
|
+
gemspec :path => "../"
|
@@ -0,0 +1,126 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
factory_girl (4.7.0)
|
5
|
+
activesupport (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (5.0.0.beta2)
|
11
|
+
activesupport (= 5.0.0.beta2)
|
12
|
+
activerecord (5.0.0.beta2)
|
13
|
+
activemodel (= 5.0.0.beta2)
|
14
|
+
activesupport (= 5.0.0.beta2)
|
15
|
+
arel (~> 7.0)
|
16
|
+
activerecord-jdbc-adapter (1.3.19)
|
17
|
+
activerecord (>= 2.2)
|
18
|
+
activerecord-jdbcsqlite3-adapter (1.3.19)
|
19
|
+
activerecord-jdbc-adapter (~> 1.3.19)
|
20
|
+
jdbc-sqlite3 (>= 3.7.2, < 3.9)
|
21
|
+
activesupport (5.0.0.beta2)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
i18n (~> 0.7)
|
24
|
+
json (~> 1.7, >= 1.7.7)
|
25
|
+
method_source
|
26
|
+
minitest (~> 5.1)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
appraisal (2.1.0)
|
29
|
+
bundler
|
30
|
+
rake
|
31
|
+
thor (>= 0.14.0)
|
32
|
+
arel (7.0.0)
|
33
|
+
aruba (0.13.0)
|
34
|
+
childprocess (~> 0.5.6)
|
35
|
+
contracts (~> 0.9)
|
36
|
+
cucumber (>= 1.3.19)
|
37
|
+
ffi (~> 1.9.10)
|
38
|
+
rspec-expectations (>= 2.99)
|
39
|
+
thor (~> 0.19)
|
40
|
+
bourne (1.6.0)
|
41
|
+
mocha (~> 1.1)
|
42
|
+
builder (3.2.2)
|
43
|
+
childprocess (0.5.9)
|
44
|
+
ffi (~> 1.0, >= 1.0.11)
|
45
|
+
concurrent-ruby (1.0.0)
|
46
|
+
concurrent-ruby (1.0.0-java)
|
47
|
+
contracts (0.13.0)
|
48
|
+
cucumber (1.3.20)
|
49
|
+
builder (>= 2.1.2)
|
50
|
+
diff-lcs (>= 1.1.3)
|
51
|
+
gherkin (~> 2.12)
|
52
|
+
multi_json (>= 1.7.5, < 2.0)
|
53
|
+
multi_test (>= 0.1.2)
|
54
|
+
diff-lcs (1.2.5)
|
55
|
+
docile (1.1.5)
|
56
|
+
ffi (1.9.10)
|
57
|
+
ffi (1.9.10-java)
|
58
|
+
gherkin (2.12.2)
|
59
|
+
multi_json (~> 1.3)
|
60
|
+
gherkin (2.12.2-java)
|
61
|
+
multi_json (~> 1.3)
|
62
|
+
i18n (0.7.0)
|
63
|
+
jdbc-sqlite3 (3.8.11.2)
|
64
|
+
json (1.8.3)
|
65
|
+
json (1.8.3-java)
|
66
|
+
metaclass (0.0.4)
|
67
|
+
method_source (0.8.2)
|
68
|
+
minitest (5.8.4)
|
69
|
+
mocha (1.1.0)
|
70
|
+
metaclass (~> 0.0.1)
|
71
|
+
multi_json (1.11.2)
|
72
|
+
multi_test (0.1.2)
|
73
|
+
rake (10.5.0)
|
74
|
+
rspec (3.4.0)
|
75
|
+
rspec-core (~> 3.4.0)
|
76
|
+
rspec-expectations (~> 3.4.0)
|
77
|
+
rspec-mocks (~> 3.4.0)
|
78
|
+
rspec-core (3.4.2)
|
79
|
+
rspec-support (~> 3.4.0)
|
80
|
+
rspec-expectations (3.4.0)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.4.0)
|
83
|
+
rspec-its (1.2.0)
|
84
|
+
rspec-core (>= 3.0.0)
|
85
|
+
rspec-expectations (>= 3.0.0)
|
86
|
+
rspec-mocks (3.4.1)
|
87
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
+
rspec-support (~> 3.4.0)
|
89
|
+
rspec-support (3.4.1)
|
90
|
+
simplecov (0.11.2)
|
91
|
+
docile (~> 1.1.0)
|
92
|
+
json (~> 1.8)
|
93
|
+
simplecov-html (~> 0.10.0)
|
94
|
+
simplecov-html (0.10.0)
|
95
|
+
sqlite3 (1.3.11)
|
96
|
+
thor (0.19.1)
|
97
|
+
thread_safe (0.3.5)
|
98
|
+
thread_safe (0.3.5-java)
|
99
|
+
timecop (0.8.0)
|
100
|
+
tzinfo (1.2.2)
|
101
|
+
thread_safe (~> 0.1)
|
102
|
+
yard (0.8.7.6)
|
103
|
+
|
104
|
+
PLATFORMS
|
105
|
+
java
|
106
|
+
ruby
|
107
|
+
|
108
|
+
DEPENDENCIES
|
109
|
+
activerecord (~> 5.0.0.beta2)
|
110
|
+
activerecord-jdbcsqlite3-adapter
|
111
|
+
appraisal (~> 2.1.0)
|
112
|
+
aruba
|
113
|
+
bourne
|
114
|
+
cucumber (~> 1.3.15)
|
115
|
+
factory_girl!
|
116
|
+
jdbc-sqlite3
|
117
|
+
mocha (>= 0.12.8)
|
118
|
+
rspec (~> 3.0)
|
119
|
+
rspec-its (~> 1.0)
|
120
|
+
simplecov
|
121
|
+
sqlite3 (~> 1.3.10)
|
122
|
+
timecop
|
123
|
+
yard
|
124
|
+
|
125
|
+
BUNDLED WITH
|
126
|
+
1.11.2
|
data/lib/factory_girl.rb
CHANGED
@@ -55,14 +55,23 @@ module FactoryGirl
|
|
55
55
|
@configuration = nil
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
# Look for errors in factories and (optionally) their traits.
|
59
|
+
# Parameters:
|
60
|
+
# factories - which factories to lint; omit for all factories
|
61
|
+
# options:
|
62
|
+
# traits : true - to lint traits as well as factories
|
63
|
+
def self.lint(*args)
|
64
|
+
options = args.extract_options!
|
65
|
+
factories_to_lint = args[0] || FactoryGirl.factories
|
66
|
+
strategy = options[:traits] ? :factory_and_traits : :factory
|
67
|
+
Linter.new(factories_to_lint, strategy).lint!
|
60
68
|
end
|
61
69
|
|
62
70
|
class << self
|
63
71
|
delegate :factories, :sequences, :traits, :callbacks, :strategies, :callback_names,
|
64
|
-
:to_create, :skip_create, :initialize_with, :constructor,
|
65
|
-
:duplicate_attribute_assignment_from_initialize_with
|
72
|
+
:to_create, :skip_create, :initialize_with, :constructor,
|
73
|
+
:duplicate_attribute_assignment_from_initialize_with, :duplicate_attribute_assignment_from_initialize_with=,
|
74
|
+
:allow_class_lookup, :allow_class_lookup=, to: :configuration
|
66
75
|
end
|
67
76
|
|
68
77
|
def self.register_factory(factory)
|
@@ -11,7 +11,10 @@ module FactoryGirl
|
|
11
11
|
block = @block
|
12
12
|
|
13
13
|
-> {
|
14
|
-
value = block.arity
|
14
|
+
value = case block.arity
|
15
|
+
when 1, -1 then instance_exec(self, &block)
|
16
|
+
else instance_exec(&block)
|
17
|
+
end
|
15
18
|
raise SequenceAbuseError if FactoryGirl::Sequence === value
|
16
19
|
value
|
17
20
|
}
|
@@ -89,9 +89,9 @@ module FactoryGirl
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def alias_names_to_ignore
|
92
|
-
@attribute_list.non_ignored.
|
92
|
+
@attribute_list.non_ignored.flat_map do |attribute|
|
93
93
|
override_names.map { |override| attribute.name if attribute.alias_for?(override) && attribute.name != override && !ignored_attribute_names.include?(override) }
|
94
|
-
end.
|
94
|
+
end.compact
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -3,6 +3,8 @@ module FactoryGirl
|
|
3
3
|
class Configuration
|
4
4
|
attr_reader :factories, :sequences, :traits, :strategies, :callback_names
|
5
5
|
|
6
|
+
attr_accessor :allow_class_lookup
|
7
|
+
|
6
8
|
def initialize
|
7
9
|
@factories = Decorator::DisallowsDuplicatesRegistry.new(Registry.new('Factory'))
|
8
10
|
@sequences = Decorator::DisallowsDuplicatesRegistry.new(Registry.new('Sequence'))
|
@@ -11,6 +13,8 @@ module FactoryGirl
|
|
11
13
|
@callback_names = Set.new
|
12
14
|
@definition = Definition.new
|
13
15
|
|
16
|
+
@allow_class_lookup = true
|
17
|
+
|
14
18
|
to_create { |instance| instance.save! }
|
15
19
|
initialize_with { new }
|
16
20
|
end
|
@@ -18,7 +18,8 @@ module FactoryGirl
|
|
18
18
|
def symbolized_key(key)
|
19
19
|
if key.respond_to?(:to_sym)
|
20
20
|
key.to_sym
|
21
|
-
|
21
|
+
elsif FactoryGirl.allow_class_lookup
|
22
|
+
ActiveSupport::Deprecation.warn "Looking up factories by class is deprecated and will be removed in 5.0. Use symbols instead and set FactoryGirl.allow_class_lookup = false", caller
|
22
23
|
key.to_s.underscore.to_sym
|
23
24
|
end
|
24
25
|
end
|
@@ -54,7 +54,7 @@ module FactoryGirl
|
|
54
54
|
def ignore(&block)
|
55
55
|
ActiveSupport::Deprecation.warn "`#ignore` is deprecated and will be "\
|
56
56
|
"removed in 5.0. Please use `#transient` instead."
|
57
|
-
transient
|
57
|
+
transient(&block)
|
58
58
|
end
|
59
59
|
|
60
60
|
def transient(&block)
|
@@ -115,7 +115,7 @@ module FactoryGirl
|
|
115
115
|
# sequence(:email) { |n| "person#{n}@example.com" }
|
116
116
|
#
|
117
117
|
# factory :user do
|
118
|
-
# email { FactoryGirl.
|
118
|
+
# email { FactoryGirl.generate(:email) }
|
119
119
|
# end
|
120
120
|
#
|
121
121
|
# Except that no globally available sequence will be defined.
|
@@ -17,7 +17,13 @@ module FactoryGirl
|
|
17
17
|
factory = factory.with_traits(@traits)
|
18
18
|
end
|
19
19
|
|
20
|
-
instrumentation_payload = {
|
20
|
+
instrumentation_payload = {
|
21
|
+
name: @name,
|
22
|
+
strategy: runner_strategy,
|
23
|
+
traits: @traits,
|
24
|
+
overrides: @overrides,
|
25
|
+
factory: factory
|
26
|
+
}
|
21
27
|
|
22
28
|
ActiveSupport::Notifications.instrument('factory_girl.run_factory', instrumentation_payload) do
|
23
29
|
factory.run(runner_strategy, @overrides, &block)
|
@@ -2,7 +2,7 @@ module FactoryGirl
|
|
2
2
|
class << self
|
3
3
|
# An Array of strings specifying locations that should be searched for
|
4
4
|
# factory definitions. By default, factory_girl will attempt to require
|
5
|
-
# "factories,
|
5
|
+
# "factories", "test/factories" and "spec/factories". Only the first
|
6
6
|
# existing file will be loaded.
|
7
7
|
attr_accessor :definition_file_paths
|
8
8
|
end
|
data/lib/factory_girl/linter.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module FactoryGirl
|
2
2
|
class Linter
|
3
|
-
def self.lint!(factories_to_lint)
|
4
|
-
new(factories_to_lint).lint!
|
5
|
-
end
|
6
3
|
|
7
|
-
def initialize(factories_to_lint)
|
4
|
+
def initialize(factories_to_lint, linting_strategy)
|
8
5
|
@factories_to_lint = factories_to_lint
|
6
|
+
@linting_method = "lint_#{linting_strategy}"
|
9
7
|
@invalid_factories = calculate_invalid_factories
|
10
8
|
end
|
11
9
|
|
@@ -15,26 +13,79 @@ module FactoryGirl
|
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
|
-
private
|
19
|
-
|
20
16
|
attr_reader :factories_to_lint, :invalid_factories
|
17
|
+
private :factories_to_lint, :invalid_factories
|
18
|
+
|
19
|
+
private
|
21
20
|
|
22
21
|
def calculate_invalid_factories
|
23
|
-
factories_to_lint.
|
22
|
+
factories_to_lint.reduce(Hash.new([])) do |result, factory|
|
23
|
+
errors = send(@linting_method, factory)
|
24
|
+
result[factory] |= errors unless errors.empty?
|
25
|
+
result
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class FactoryError
|
30
|
+
def initialize(wrapped_error, factory)
|
31
|
+
@wrapped_error = wrapped_error
|
32
|
+
@factory = factory
|
33
|
+
end
|
34
|
+
|
35
|
+
def message
|
36
|
+
message = @wrapped_error.message
|
37
|
+
"* #{location} - #{message} (#{@wrapped_error.class.name})"
|
38
|
+
end
|
39
|
+
|
40
|
+
def location
|
41
|
+
@factory.name
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class FactoryTraitError < FactoryError
|
46
|
+
def initialize(wrapped_error, factory, trait_name)
|
47
|
+
super(wrapped_error, factory)
|
48
|
+
@trait_name = trait_name
|
49
|
+
end
|
50
|
+
|
51
|
+
def location
|
52
|
+
"#{@factory.name}+#{@trait_name}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def lint_factory(factory)
|
57
|
+
result = []
|
58
|
+
begin
|
59
|
+
FactoryGirl.create(factory.name)
|
60
|
+
rescue => error
|
61
|
+
result |= [FactoryError.new(error, factory)]
|
62
|
+
end
|
63
|
+
result
|
64
|
+
end
|
65
|
+
|
66
|
+
def lint_traits(factory)
|
67
|
+
result = []
|
68
|
+
factory.definition.defined_traits.map(&:name).each do |trait_name|
|
24
69
|
begin
|
25
|
-
FactoryGirl.create(factory.name)
|
70
|
+
FactoryGirl.create(factory.name, trait_name)
|
26
71
|
rescue => error
|
27
|
-
result
|
72
|
+
result |=
|
73
|
+
[FactoryTraitError.new(error, factory, trait_name)]
|
28
74
|
end
|
29
|
-
|
30
|
-
result
|
31
75
|
end
|
76
|
+
result
|
77
|
+
end
|
78
|
+
|
79
|
+
def lint_factory_and_traits(factory)
|
80
|
+
errors = lint_factory(factory)
|
81
|
+
errors |= lint_traits(factory)
|
82
|
+
errors
|
32
83
|
end
|
33
84
|
|
34
85
|
def error_message
|
35
|
-
lines = invalid_factories.map do |
|
36
|
-
|
37
|
-
end
|
86
|
+
lines = invalid_factories.map do |_factory, exceptions|
|
87
|
+
exceptions.map &:message
|
88
|
+
end.flatten
|
38
89
|
|
39
90
|
<<-ERROR_MESSAGE.strip
|
40
91
|
The following factories are invalid:
|
@@ -10,6 +10,7 @@ module FactoryGirl
|
|
10
10
|
def result(evaluation)
|
11
11
|
evaluation.object.tap do |instance|
|
12
12
|
stub_database_interaction_on_result(instance)
|
13
|
+
clear_changed_attributes_on_result(instance)
|
13
14
|
evaluation.notify(:after_stub, instance)
|
14
15
|
end
|
15
16
|
end
|
@@ -44,7 +45,7 @@ module FactoryGirl
|
|
44
45
|
raise "stubbed models are not allowed to access the database - #{self.class.to_s}#connection()"
|
45
46
|
end
|
46
47
|
|
47
|
-
def reload
|
48
|
+
def reload(*args)
|
48
49
|
raise "stubbed models are not allowed to access the database - #{self.class.to_s}#reload()"
|
49
50
|
end
|
50
51
|
|
@@ -55,6 +56,14 @@ module FactoryGirl
|
|
55
56
|
def update_column(*args)
|
56
57
|
raise "stubbed models are not allowed to access the database - #{self.class.to_s}#update_column(#{args.join(",")})"
|
57
58
|
end
|
59
|
+
|
60
|
+
def increment!(*args)
|
61
|
+
raise "stubbed models are not allowed to access the database - #{self.class}#increment!(#{args.join(',')})"
|
62
|
+
end
|
63
|
+
|
64
|
+
def decrement!(*args)
|
65
|
+
raise "stubbed models are not allowed to access the database - #{self.class}#decrement!(#{args.join(',')})"
|
66
|
+
end
|
58
67
|
end
|
59
68
|
|
60
69
|
created_at_missing_default = result_instance.respond_to?(:created_at) && !result_instance.created_at
|
@@ -68,6 +77,21 @@ module FactoryGirl
|
|
68
77
|
end
|
69
78
|
end
|
70
79
|
end
|
80
|
+
|
81
|
+
def clear_changed_attributes_on_result(result_instance)
|
82
|
+
unless result_instance.respond_to?(:clear_changes_information)
|
83
|
+
result_instance.extend ActiveModelDirtyBackport
|
84
|
+
end
|
85
|
+
|
86
|
+
result_instance.clear_changes_information
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
module ActiveModelDirtyBackport
|
91
|
+
def clear_changes_information
|
92
|
+
@previously_changed = ActiveSupport::HashWithIndifferentAccess.new
|
93
|
+
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
|
94
|
+
end
|
71
95
|
end
|
72
96
|
end
|
73
97
|
end
|