Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

List and load prerequisites. create database for testing

  • Loading branch information...
commit 177a107f9666011cef3f95392e87e8801abf5dac 1 parent 906723f
@szabgab authored
View
17 Makefile.PL
@@ -12,9 +12,20 @@ WriteMakefile(
: ()),
PL_FILES => {},
PREREQ_PM => {
- 'Test::More' => 0,
- 'YAML' => 0,
- 'Dancer' => 1.3060,
+ 'Dancer' => 1.3060,
+ 'Data::Dumper' => 0,
+ 'DBIx::Class' => 0,
+ 'DBIx::Class::Schema' => 0,
+ 'DBIx::RunSQL' => 0,
+ 'Email::Valid' => 0,
+ 'File::Spec' => 0,
+ 'Getopt::Long' => 0,
+ 'MIME::Lite' => 0,
+ 'Pod::Usage' => 0,
+ 'String::Random' => 0,
+ 'Template' => 0,
+ 'Test::More' => 0,
+ 'YAML' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Dwimmer-*' },
View
6 config.yml
@@ -26,7 +26,7 @@ engines:
encoding: 'utf8'
# start_tag: '[%'
# end_tag: '%]'
-dwimmer:
- json: /home/gabor/dwimmer.json
- dbfile: /home/gabor/work/Dwimmer/db/dwimmer.db
+#dwimmer:
+# json: /home/gabor/dwimmer.json
+# dbfile: /home/gabor/work/Dwimmer/db/dwimmer.db
session: YAML
View
4 lib/Dwimmer.pm
@@ -4,6 +4,8 @@ use Dancer ':syntax';
our $VERSION = '0.01';
use Data::Dumper;
+use Email::Valid;
+use MIME::Lite;
use String::Random;
use Dwimmer::DB;
@@ -173,7 +175,7 @@ get '/edit_this_page' => sub {
###### helper methods
sub _get_db {
- my $dbfile = config->{dwimmer}{dbfile};
+ my $dbfile = path(config->{appdir}, 'db', 'dwimmer.db');
Dwimmer::DB->connect("dbi:SQLite:dbname=$dbfile", '', '');
};
View
7 script/dwimmer_setup.pl
@@ -15,15 +15,18 @@
GetOptions(\%opt,
'email=s',
'password=s',
+ 'root=s',
);
usage() if not $opt{email};
die 'Invalid e-mail' if not Email::Valid->address($opt{email});
usage() if not $opt{password};
die 'Password needs to be 6 characters' if length $opt{password} < 6;
+usage() if not $opt{root};
+
my $sql = File::Spec->catfile('share', 'schema', 'dwimmer.sql');
-my $dbfile = get_dbfile();
+my $dbfile = "$opt{root}/db/dwimmer.db"; #get_dbfile();
die "Database file '$dbfile' already exists\n" if -e $dbfile;
DBIx::RunSQL->create(
@@ -60,5 +63,7 @@ =head1 SYNOPSIS
--password PASSWORD of administrator
+ --root ROOT path to the root of the installation
+
=cut
View
40 t/003_admin.t
@@ -0,0 +1,40 @@
+use Test::More;
+use strict;
+use warnings;
+
+use Cwd qw(abs_path);
+use File::Basename qw(dirname);
+
+plan tests => 2;
+
+
+my $root = dirname dirname abs_path($0);
+#diag $root;
+
+#use Dancer qw(config);
+#use Dwimmer;
+#diag config->{appdir};
+
+my $password = 'dwimmer';
+
+# TODO do this in a temporary directory!
+mkdir "$root/db";
+unlink "$root/db/dwimmer.db";
+system "$^X script/dwimmer_setup.pl --root $root --email test\@dwimmer.org --password $password";
+
+
+use Dwimmer;
+use Dancer::Test;
+
+{
+ my $r = dancer_response GET => '/';
+ is $r->{status}, 200, '/ ok';
+ like $r->{content}, qr{/login}, '/login';
+}
+
+# {
+ # my $r = dancer_response POST => '/login', username => 'admin', password => $password;
+# }
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.