summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-11-18 21:00:24 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-11-18 21:02:57 +0100
commit13e59b3aa1504154a90619069c963301e322904a (patch)
tree83a8e98f631071d1b74672aed6afc7178e69aa27
parentff2a3afe34d47e3880c7a91e570dd0d3f4d75373 (diff)
add journey: make realtime data optional (default to schedule data)1.10.1
Closes #25
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm3
-rw-r--r--t/02-registration.t30
-rw-r--r--templates/add_journey.html.ep8
3 files changed, 37 insertions, 4 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 3f6217b..f0f1879 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -800,6 +800,9 @@ sub add_journey_form {
}
}
+ $opt{rt_departure} //= $opt{sched_departure};
+ $opt{rt_arrival} //= $opt{sched_arrival};
+
for my $key (qw(dep_station arr_station cancelled comment)) {
$opt{$key} = $self->param($key);
}
diff --git a/t/02-registration.t b/t/02-registration.t
index ac7200a..0d324b0 100644
--- a/t/02-registration.t
+++ b/t/02-registration.t
@@ -267,5 +267,35 @@ $t->get_ok('/history/2018')->status_is(200)->content_like(qr{124 km})
->content_like(qr{Bei Abfahrt: 00:09 Stunden})
->content_like(qr{Bei Ankunft: 00:26 Stunden});
+$csrf_token
+ = $t->ua->get('/journey/add')->res->dom->at('input[name=csrf_token]')
+ ->attr('value');
+$t->post_ok(
+ '/journey/add' => form => {
+ csrf_token => $csrf_token,
+ action => 'save',
+ train => 'ICE 1',
+ dep_station => 'EE',
+ sched_departure => '17.11.2018 15:42',
+ rt_departure => '',
+ arr_station => 'BL',
+ sched_arrival => '17.11.2018 19:42',
+ rt_arrival => '',
+ }
+);
+$t->status_is(302)->header_is( location => '/journey/3' );
+
+$t->get_ok('/history/2018/11')->status_is(200)->content_like(qr{513 km})
+ ->content_like(qr{05:15 Stunden})->content_like(qr{nach Fahrplan: 04:58})
+ ->content_like(qr{00:00 Stunden})
+ ->content_like(qr{Bei Abfahrt: 00:09 Stunden})
+ ->content_like(qr{Bei Ankunft: 00:26 Stunden});
+
+$t->get_ok('/history/2018')->status_is(200)->content_like(qr{576 km})
+ ->content_like(qr{06:13 Stunden})->content_like(qr{nach Fahrplan: 05:56})
+ ->content_like(qr{00:00 Stunden})
+ ->content_like(qr{Bei Abfahrt: 00:09 Stunden})
+ ->content_like(qr{Bei Ankunft: 00:26 Stunden});
+
$t->app->pg->db->query('drop schema travelynx_test_02 cascade');
done_testing();
diff --git a/templates/add_journey.html.ep b/templates/add_journey.html.ep
index 02f30d5..58cd68b 100644
--- a/templates/add_journey.html.ep
+++ b/templates/add_journey.html.ep
@@ -58,8 +58,8 @@
<label for="sched_departure">Geplante Abfahrt</label>
</div>
<div class="input-field col s12">
- %= text_field 'rt_departure', id => 'rt_departure', class => 'validate', required => undef, pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]'
- <label for="rt_departure">Tatsächliche Abfahrt</label>
+ %= text_field 'rt_departure', id => 'rt_departure', class => 'validate', pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]'
+ <label for="rt_departure">Tatsächliche Abfahrt (wenn leer: pünktlich)</label>
</div>
</div>
<div class="row">
@@ -72,8 +72,8 @@
<label for="sched_arrival">Geplante Ankunft</label>
</div>
<div class="input-field col s12">
- %= text_field 'rt_arrival', id => 'rt_arrival', class => 'validate', required => undef, pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]'
- <label for="rt_arrival">Tatsächliche Ankunft</label>
+ %= text_field 'rt_arrival', id => 'rt_arrival', class => 'validate', pattern => '[0-9][0-9]?[.][0-9][0-9]?[.][0-9][0-9][0-9][0-9] +[0-9][0-9]:[0-9][0-9]'
+ <label for="rt_arrival">Tatsächliche Ankunft (wenn leer: pünktlich)</label>
</div>
</div>
<div class="row">