Skip to content

Commit 4dfd46d

Browse files
prevent auto_reload from reloading factories that has just been reloaded (#98)
1 parent 6e0b9b3 commit 4dfd46d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### Tasks
44
* Documenting how to setup Factory Associations [PR 100](https://github.com/shakacode/cypress-on-rails/pull/100)
55

6+
### Fixed
7+
* keep track of factory manual reloads to prevent auto_reload from reloading again [PR 98](https://github.com/shakacode/cypress-on-rails/pull/98)
8+
69
## [1.12.0]
710
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.11.0...v1.12.0
811

lib/cypress_on_rails/smart_factory_wrapper.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def build_list(*args)
8080
end
8181

8282
def reload
83+
@latest_mtime = current_latest_mtime
8384
logger.info 'Loading Factories'
8485
factory.reload
8586
files.each do |file|
@@ -105,14 +106,16 @@ def logger
105106
CypressOnRails.configuration.logger
106107
end
107108

109+
def current_latest_mtime
110+
files.map{|file| @file_system.mtime(file) }.max
111+
end
112+
108113
def auto_reload
109-
current_latest_mtime = files.map{|file| @file_system.mtime(file) }.max
110-
return unless should_reload?(current_latest_mtime)
111-
@latest_mtime = current_latest_mtime
114+
return unless should_reload?
112115
reload
113116
end
114117

115-
def should_reload?(current_latest_mtime)
118+
def should_reload?
116119
@always_reload || @latest_mtime.nil? || @latest_mtime < current_latest_mtime
117120
end
118121
end

0 commit comments

Comments
 (0)