Skip to content

Commit

Permalink
Merge branch 'remove-delorean-gbp' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Jul 13, 2020
2 parents 2e46fb0 + 8959f3f commit 9ddefcf
Show file tree
Hide file tree
Showing 41 changed files with 209 additions and 229 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ group :test do
gem 'webmock', '~> 3.8.3'
gem 'coveralls', '~> 0.8.23', require: false
gem 'capybara', '~> 3.15.1'
gem 'delorean', '~> 2.1.0'
gem 'stripe-ruby-mock', git: 'https://github.com/stripe-ruby-mock/stripe-ruby-mock',
ref: '2c925fd'
gem('rails-controller-testing')
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ GEM
regexp_parser (~> 1.2)
xpath (~> 3.2)
charlock_holmes (0.7.7)
chronic (0.10.2)
coderay (1.1.2)
concurrent-ruby (1.1.6)
coveralls (0.8.23)
Expand All @@ -136,8 +135,6 @@ GEM
daemons (1.3.1)
dalli (2.7.10)
dante (0.2.0)
delorean (2.1.0)
chronic
diff-lcs (1.4.2)
docile (1.3.2)
dynamic_form (1.1.4)
Expand Down Expand Up @@ -422,7 +419,6 @@ DEPENDENCIES
charlock_holmes (~> 0.7.7)
coveralls (~> 0.8.23)
dalli (~> 2.7.0)
delorean (~> 2.1.0)
dynamic_form (~> 1.1.0)
exception_notification (~> 4.4.3)
factory_bot_rails (~> 5.2.0)
Expand Down
4 changes: 0 additions & 4 deletions Gemfile.rails_next.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ GEM
regexp_parser (~> 1.2)
xpath (~> 3.2)
charlock_holmes (0.7.7)
chronic (0.10.2)
coderay (1.1.2)
concurrent-ruby (1.1.6)
coveralls (0.8.23)
Expand All @@ -149,8 +148,6 @@ GEM
daemons (1.3.1)
dalli (2.7.10)
dante (0.2.0)
delorean (2.1.0)
chronic
diff-lcs (1.4.2)
docile (1.3.2)
dynamic_form (1.1.4)
Expand Down Expand Up @@ -438,7 +435,6 @@ DEPENDENCIES
charlock_holmes (~> 0.7.7)
coveralls (~> 0.8.23)
dalli (~> 2.7.0)
delorean (~> 2.1.0)
dynamic_form (~> 1.1.0)
exception_notification (~> 4.4.3)
factory_bot_rails (~> 5.2.0)
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/admin_comment_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

it 'collects comments by creation date' do
Comment.destroy_all
time_travel_to(1.month.ago)
travel_to(1.month.ago)
comment_1 = FactoryBot.create(:comment)
back_to_the_present
travel_back
comment_2 = FactoryBot.create(:comment)
get :index, session: { :user_id => admin_user.id }
expect(assigns[:comments]).to eq([comment_2, comment_1])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
subsequent follow up' do
# create a follow up
info_request = info_request_event.info_request
time_travel_to(info_request.date_response_required_by) do
travel_to(info_request.date_response_required_by) do
outgoing_message =
OutgoingMessage.new(:status => 'ready',
:message_type => 'followup',
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/admin_outgoing_message_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ def make_request(params = default_params)
end

it 'changes info_request#updated_at' do
time_travel_to(1.day.ago) { info_request }
travel_to(1.day.ago) { info_request }
expect { post :resend, params: { id: outgoing.id } }.
to change { info_request.reload.updated_at.to_date }.
from(1.day.ago.to_date).to(now.to_date)
from(1.day.ago.to_date).to(Time.zone.now.to_date)
end

it 'reopens closed requests to new responses' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,10 @@
user
end

let(:info_request) do
# so that embargoes are near expiry
time_travel_to(88.days.ago) do
FactoryBot.create(:info_request, user: pro_user)
end
end
let(:info_request) { FactoryBot.create(:info_request, user: pro_user) }

let(:embargo) do
# so that embargoes are near expiry
time_travel_to(88.days.ago) do
embargo = FactoryBot.create(:embargo, info_request: info_request)
embargo.
update_attribute(:publish_at, embargo.expiring_notification_at + 7.days)
embargo
end
FactoryBot.create(:expiring_embargo, info_request: info_request)
end

let(:embargo_expiry) { embargo.publish_at }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/statistics_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
it "uses the date of the first public request as the start_date" do
InfoRequest.destroy_all

time_travel_to(1.week.ago) do
travel_to(1.week.ago) do
FactoryBot.create(:embargoed_request)
FactoryBot.create(:hidden_request)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/alaveteli_pro/embargos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
embargo_duration { '3_months' }

factory :expiring_embargo do
publish_at { Time.zone.now + 3.days }
publish_at { 3.days.from_now.beginning_of_day }
end
end
end
4 changes: 2 additions & 2 deletions spec/helpers/alaveteli_pro/info_requests_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
subject { embargo_extension_options }

around do |example|
time_travel_to Time.utc(2020, 1, 2)
travel_to Time.utc(2020, 1, 2)
example.call
back_to_the_present
travel_back
end

it 'returns a list of expiry dates 3, 6 and 12 months into the future' do
Expand Down
24 changes: 12 additions & 12 deletions spec/helpers/info_request_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
context 'waiting_response' do

it 'returns a description' do
time_travel_to(Time.zone.parse('2014-12-31'))
travel_to(Time.zone.parse('2014-12-31'))

body_link = %Q(<a href="/body/#{ body.url_name }">#{ body.name }</a>)

Expand All @@ -55,7 +55,7 @@

expect(status_text(info_request)).to eq(expected)

back_to_the_present
travel_back
end

context 'the body is not subject to foi' do
Expand Down Expand Up @@ -83,7 +83,7 @@
end

it 'returns a description' do
time_travel_to(Time.zone.parse('2014-12-31'))
travel_to(Time.zone.parse('2014-12-31'))

allow(info_request).to receive(:calculate_status).and_return("waiting_response_overdue")
allow(info_request).to receive(:date_response_required_by).and_return(Time.zone.now)
Expand All @@ -100,15 +100,15 @@

expect(status_text(info_request)).to eq(expected)

back_to_the_present
travel_back
end

context 'the body is not subject to foi' do

it 'the description does not describe a legal obligation to reply' do
body.add_tag_if_not_already_present('foi_no')

time_travel_to(Time.zone.parse('2014-12-31'))
travel_to(Time.zone.parse('2014-12-31'))

allow(info_request).
to receive(:calculate_status).and_return("waiting_response_overdue")
Expand All @@ -128,7 +128,7 @@

expect(status_text(info_request)).to eq(expected)

back_to_the_present
travel_back
end

end
Expand All @@ -143,7 +143,7 @@
end

it 'returns a description for an internal request' do
time_travel_to(Time.zone.parse('2014-12-31'))
travel_to(Time.zone.parse('2014-12-31'))

allow(info_request).to receive(:calculate_status).and_return("waiting_response_very_overdue")
allow(info_request).to receive(:date_response_required_by).and_return(Time.zone.now)
Expand All @@ -163,15 +163,15 @@

expect(status_text(info_request)).to eq(expected)

back_to_the_present
travel_back
end

context 'the body is not subject to foi' do

it 'the description does not describe a legal obligation to reply' do
body.add_tag_if_not_already_present('foi_no')

time_travel_to(Time.zone.parse('2014-12-31'))
travel_to(Time.zone.parse('2014-12-31'))

allow(info_request).
to receive(:calculate_status).
Expand All @@ -196,13 +196,13 @@

expect(status_text(info_request)).to eq(expected)

back_to_the_present
travel_back
end

end

it 'does not add a followup link for external requests' do
time_travel_to(Time.zone.parse('2014-12-31'))
travel_to(Time.zone.parse('2014-12-31'))

body_link = %Q(<a href="/body/#{ body.url_name }">#{ body.name }</a>)

Expand All @@ -222,7 +222,7 @@

expect(status_text(info_request)).to eq(expected)

back_to_the_present
travel_back
end

end
Expand Down
8 changes: 4 additions & 4 deletions spec/integration/classify_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@
let(:classification) { 'waiting_response1' }

before do
time_travel_to(info_request.date_response_required_by + 2.days)
travel_to(info_request.date_response_required_by + 2.days)
end

after do
back_to_the_present
travel_back
end

it 'displays a thank you message post redirect' do
Expand All @@ -357,11 +357,11 @@
let(:classification) { 'waiting_response1' }

before do
time_travel_to(info_request.date_very_overdue_after + 2.days)
travel_to(info_request.date_very_overdue_after + 2.days)
end

after do
back_to_the_present
travel_back
end

it 'displays a thank you message post redirect' do
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/alaveteli_pro/metrics_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@

before do
# created before the report and shouldn't be included
time_travel_to(2.week.ago) {
travel_to(2.week.ago) {
FactoryBot.create(:embargoed_request, user: other_pro_user)
}

# created the week of the report and should be included
time_travel_to(1.week.ago) {
travel_to(1.week.ago) {
2.times { FactoryBot.create(:info_request, user: user) }
3.times { FactoryBot.create(:info_request, user: pro_user) }
FactoryBot.create(:info_request_batch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
subject = described_class.new(:path => test_path)
time = Time.zone.now.to_datetime

time_travel_to(time) do
travel_to(time) do
subject.record('key')
expect(subject.get('key').last).to be_within(1.second).of(time)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/alaveteli_rate_limiter/ip_rate_limiter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@
ip = '127.0.0.1'

purged = 10.days.ago
time_travel_to(purged) do
travel_to(purged) do
subject.record(ip)
end

time = Time.zone.now.to_datetime

time_travel_to(time) do
travel_to(time) do
subject.record!(ip)
expect(subject.records(ip)).not_to include(purged)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/alaveteli_rate_limiter/rate_limiter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@
id = '1'

purged = 10.days.ago
time_travel_to(purged) do
travel_to(purged) do
subject.record(id)
end

time = Time.zone.now.to_datetime

time_travel_to(time) do
travel_to(time) do
subject.record!(id)
expect(subject.records(id)).not_to include(purged)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/alaveteli_rate_limiter/window_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
describe '#include?' do

it 'returns true if an event is inside the window' do
time_travel_to(Time.zone.parse('2016-10-21')) do
travel_to(Time.zone.parse('2016-10-21')) do
subject = described_class.new(1, :day)
expect(subject.include?(10.minutes.ago)).to eq(true)
end
end

it 'returns false if the event is not inside the window' do
time_travel_to(Time.zone.parse('2016-10-21')) do
travel_to(Time.zone.parse('2016-10-21')) do
subject = described_class.new(1, :day)
expect(subject.include?(2.days.ago)).to eq(false)
end
Expand All @@ -72,7 +72,7 @@

it 'calculates the end of the window based on the attributes' do
time = Time.zone.parse('2016-10-21')
time_travel_to(time) do
travel_to(time) do
subject = described_class.new(1, :hour)
expect(subject.cutoff).to be_within(1.second).of(time - 1.hour)
end
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/user_stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
context "when passed a start date" do

before do
Delorean.time_travel_to "1 week ago"
travel_to 1.week.ago
FactoryBot.create(:user, :email => "test@example.com")
Delorean.back_to_the_present
travel_back
end

it "only returns data for signups created since the start date" do
Expand Down Expand Up @@ -69,7 +69,7 @@

describe ".count_dormant_users" do
before do
Delorean.time_travel_to(2.weeks.ago) do
travel_to(2.weeks.ago) do
requester = FactoryBot.create(:user, :email => "active@example.com")
commenter = FactoryBot.create(:user, :email => "commenter@example.com")
tracker = FactoryBot.create(:user, :email => "tracker@example.com")
Expand Down Expand Up @@ -103,7 +103,7 @@

describe ".unbanned_by_domain" do
before do
Delorean.time_travel_to(1.month.ago) do
travel_to(1.month.ago) do
@user1 = FactoryBot.create(:user, :email => "test@example.com")
@banned = FactoryBot.create(:user,
:email => "banned@example.com",
Expand Down

0 comments on commit 9ddefcf

Please sign in to comment.