Class: TestData::WarnsIfDatabaseIsNewerThanDump
- Inherits:
-
Object
- Object
- TestData::WarnsIfDatabaseIsNewerThanDump
- Defined in:
- lib/test_data/warns_if_database_is_newer_than_dump.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize ⇒ WarnsIfDatabaseIsNewerThanDump
constructor
A new instance of WarnsIfDatabaseIsNewerThanDump.
Constructor Details
#initialize ⇒ WarnsIfDatabaseIsNewerThanDump
Returns a new instance of WarnsIfDatabaseIsNewerThanDump.
3 4 5 6 7 |
# File 'lib/test_data/warns_if_database_is_newer_than_dump.rb', line 3 def initialize @config = TestData.config @determines_when_sql_dump_was_made = DeterminesWhenSqlDumpWasMade.new @determines_databases_associated_dump_time = DeterminesDatabasesAssociatedDumpTime.new end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/test_data/warns_if_database_is_newer_than_dump.rb', line 9 def call return unless Rails.env.test_data? sql_dumped_at = @determines_when_sql_dump_was_made.call database_dumped_at = @determines_databases_associated_dump_time.call if database_dumped_at.present? && sql_dumped_at.present? && database_dumped_at > sql_dumped_at TestData.log.warn <<~MSG Your local test_data database '#{@config.database_name}' is associated with a SQL dump that was NEWER than the current dumps located in '#{File.dirname(@config.data_dump_path)}': SQL Dump: #{sql_dumped_at.localtime} Database: #{database_dumped_at.localtime} If you're not intentionally resetting your local test_data database to an earlier version, you may want to take a closer look before taking any destructive actions. MSG end end |