Don't monkey patch ActiveSupport.

It could have side effects (for example, a conflict after upgrading to
Rails 5).

Thanks @aitbw for the suggestion!
This commit is contained in:
Javier Martín
2018-07-02 18:26:54 +02:00
parent 4a559ed3cd
commit de0afe1621
3 changed files with 2 additions and 10 deletions

View File

@@ -1,10 +1,9 @@
require 'rails_helper'
require 'time_helper'
feature 'Officing Results' do
background do
freeze_time
travel_to Time.now # TODO: use `freeze_time` after migrating to Rails 5.
@poll_officer = create(:poll_officer)
@officer_assignment = create(:poll_officer_assignment, :final, officer: @poll_officer)
@poll = @officer_assignment.booth_assignment.poll

View File

@@ -18,6 +18,7 @@ RSpec.configure do |config|
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
config.include(CommonActions)
config.include(ActiveSupport::Testing::TimeHelpers)
config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end

View File

@@ -1,8 +0,0 @@
module ActiveSupport::Testing::TimeHelpers
# Copied from Rails 5.2. TODO: remove after migrating to Rails 5.
def freeze_time(&block)
travel_to Time.now, &block
end
end
include ActiveSupport::Testing::TimeHelpers