diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ed4bde..84be99c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ### Tasks * Documenting how to setup Factory Associations [PR 100](https://github.com/shakacode/cypress-on-rails/pull/100) +### Fixed +* keep track of factory manual reloads to prevent auto_reload from reloading again [PR 98](https://github.com/shakacode/cypress-on-rails/pull/98) + ## [1.12.0] [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.11.0...v1.12.0 diff --git a/lib/cypress_on_rails/smart_factory_wrapper.rb b/lib/cypress_on_rails/smart_factory_wrapper.rb index cbaab29..b8fb882 100644 --- a/lib/cypress_on_rails/smart_factory_wrapper.rb +++ b/lib/cypress_on_rails/smart_factory_wrapper.rb @@ -80,6 +80,7 @@ def build_list(*args) end def reload + @latest_mtime = current_latest_mtime logger.info 'Loading Factories' factory.reload files.each do |file| @@ -105,14 +106,16 @@ def logger CypressOnRails.configuration.logger end + def current_latest_mtime + files.map{|file| @file_system.mtime(file) }.max + end + def auto_reload - current_latest_mtime = files.map{|file| @file_system.mtime(file) }.max - return unless should_reload?(current_latest_mtime) - @latest_mtime = current_latest_mtime + return unless should_reload? reload end - def should_reload?(current_latest_mtime) + def should_reload? @always_reload || @latest_mtime.nil? || @latest_mtime < current_latest_mtime end end