From c384ff6732a1ea6a557befe1e0758aa531fa9193 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 25 Sep 2010 10:23:15 -0500 Subject: [PATCH] boosts go away when they should and user gets emailed --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 2 +- lib/Lacuna/RPC/Empire.pm | 2 +- t/Boosts.t | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 73997e29..8a36f48b 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -729,7 +729,7 @@ sub tick { } } unless ($still_enabled) { - if (!$self->empire->check_for_repeat_message('boosts_expired')) { + if (!$self->empire->check_for_repeat_message('boosts_expired')) { # because each planet could send the message $self->empire->send_predefined_message( tags => ['Alert'], filename => 'boosts_expired.txt', diff --git a/lib/Lacuna/RPC/Empire.pm b/lib/Lacuna/RPC/Empire.pm index 43b0b581..f965a80b 100644 --- a/lib/Lacuna/RPC/Empire.pm +++ b/lib/Lacuna/RPC/Empire.pm @@ -506,7 +506,7 @@ sub boost { my $start = DateTime->now; $start = $empire->$type if ($empire->$type > $start); $start->add(days=>7); - $empire->planets->update({needs_recalc=>1}); + $empire->planets->update({needs_recalc=>1, boost_enabled=>1}); $empire->$type($start); $empire->update; if ($empire->tutorial_stage ne 'turing') { diff --git a/t/Boosts.t b/t/Boosts.t index 95f91619..c6860dde 100644 --- a/t/Boosts.t +++ b/t/Boosts.t @@ -1,5 +1,5 @@ use lib '../lib'; -use Test::More tests => 2; +use Test::More tests => 4; use Test::Deep; use Data::Dumper; use 5.010; @@ -16,7 +16,13 @@ $tester->post('empire','boost_ore', [$session_id]); my $boosted = $tester->post('body','get_status', [$session_id, $home->id]); cmp_ok($boosted->{result}{empire}{essentia}, '<', $base->{result}{empire}{essentia}, 'essentia spent'); cmp_ok($boosted->{result}{body}{ore_hour}, '>', $base->{result}{ore_hour}, 'ore_hour increased'); - +$empire->discard_changes; +$empire->ore_boost(DateTime->now->subtract(seconds=>60)); +$empire->update; +my $unboosted = $tester->post('body','get_status', [$session_id, $home->id]); +cmp_ok($boosted->{result}{body}{ore_hour}, '>', $unboosted->{result}{body}{ore_hour}, 'ore_hour decreased'); +my $unboost_message_recieved = $empire->received_messages->search({subject =>'Boosts Have Expired'})->count; +ok($unboost_message_recieved, 'unboost message received'); END { $tester->cleanup; -- 2.51.2