aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorlouise <louise>2009-10-13 09:25:56 +0000
committerlouise <louise>2009-10-13 09:25:56 +0000
commit43da2c622a6b95e39b197c93fc1456961ea74369 (patch)
treee971ac7c159a1a467c5bd904e2b0b87fad92f553 /t
parent79584cfa97b6923870415537ecc1b04630670698 (diff)
Add some functions for figuring out if a user has accepted new T&Cs
Diffstat (limited to 't')
-rwxr-xr-xt/Problems.t50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/Problems.t b/t/Problems.t
new file mode 100755
index 000000000..8a5c828e3
--- /dev/null
+++ b/t/Problems.t
@@ -0,0 +1,50 @@
+#!/usr/bin/perl -w
+#
+# Problem.t:
+# Tests for the Problem functions
+#
+# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
+# Email: louise@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: Problems.t,v 1.1 2009-10-13 09:25:56 louise Exp $
+#
+
+use strict;
+use warnings;
+use Test::More tests => 6;
+use Test::Exception;
+
+use FindBin;
+use lib "$FindBin::Bin";
+use lib "$FindBin::Bin/../perllib";
+use lib "$FindBin::Bin/../../perllib";
+
+use Problems;
+
+sub test_update_user_notified_data_sharing() {
+
+ my $update = {created => 1256947200};
+ my $notification_start = 1256947201;
+ my $accepted = Problems::update_user_notified_data_sharing($update, $notification_start);
+ ok($accepted == 0, 'update_user_notified_data_sharing returns false for an update created before the notification started to be displayed');
+ $notification_start = 1256947199;
+ $accepted = Problems::update_user_notified_data_sharing($update, $notification_start);
+ ok($accepted == 1, 'update_user_notified_data_sharing returns true for a problem created after the notification started to be displayed');
+ return 1;
+}
+
+sub test_user_notified_data_sharing() {
+
+ my $problem = {time => 1256947200};
+ my $notification_start = 1256947201;
+ my $accepted = Problems::user_notified_data_sharing($problem, $notification_start);
+ ok($accepted == 0, 'user_notified_data_sharing returns false for a problem created before the notification started to be displayed');
+ $notification_start = 1256947199;
+ $accepted = Problems::user_notified_data_sharing($problem, $notification_start);
+ ok($accepted == 1, 'user_notified_data_sharing returns true for a problem created after the notification started to be displayed');
+ return 1;
+}
+
+ok(test_user_notified_data_sharing() == 1, 'Ran all tests for user_notified_data_sharing ');
+ok(test_update_user_notified_data_sharing() == 1, 'Ran all tests for update_user_notified_data_sharing');
+