Skip to content
Browse files

Merge branch 'release/v0.23'

  • Loading branch information...
2 parents 2d506f8 + f71a9fe commit 345d6dbd1a93af3ac90654a23d18de29ccc42357 @szabgab committed Nov 20, 2011
Showing with 50 additions and 21 deletions.
  1. +6 −0 Changes
  2. +8 −7 MANIFEST.SKIP
  3. +1 −1 lib/Dwimmer.pm
  4. +9 −3 lib/Dwimmer/Admin.pm
  5. +1 −1 lib/Dwimmer/Client.pm
  6. +1 −1 lib/Dwimmer/Tools.pm
  7. +4 −2 script/dwimmer_setup.pl
  8. +17 −2 t/003_client.t
  9. +0 −1 t/015_polls.t
  10. +3 −3 t/lib/Dwimmer/Test.pm
View
6 Changes
@@ -1,5 +1,11 @@
Changes to the Dwimmer system. See http://dwimmer.org/
+v0.23 2011.11.20
+
+ - Eliminate duplicate files from distribution
+ - Fix a syntax typo (alanhaggai)
+ - Allow only lower case usernames (#5)
+
v0.22 2011.11.20
- Move the site checking to the 'before' hook to eliminate duplication.
View
15 MANIFEST.SKIP
@@ -45,16 +45,17 @@ MYMETA\.(?:yml|yaml|json)$
.gitignore
\bdb\b
\blog\b
-\bpolls\b
+^logs\b
+^polls\b
SETUP.bat
# copied to the share/ directory
-#^public\b
-#^schema\b
-#^views\b
-#^environments\b
-#^bin\n
-#^config.yml
+^public\b
+^schema\b
+^views\b
+^environments\b
+^bin\n
+^config.yml
# need to include the share directory as well as apparently
View
2 lib/Dwimmer.pm
@@ -3,7 +3,7 @@ use Dancer ':syntax';
use 5.008005;
-our $VERSION = '0.22';
+our $VERSION = '0.23';
use Data::Dumper qw(Dumper);
use Dwimmer::DB;
View
12 lib/Dwimmer/Admin.pm
@@ -3,7 +3,7 @@ use Dancer ':syntax';
use 5.008005;
-our $VERSION = '0.22';
+our $VERSION = '0.23';
use Data::Dumper qw(Dumper);
use Email::Valid ();
@@ -203,7 +203,7 @@ get '/get_user.json' => sub {
return to_json { error => 'no_id' } if not defined $id;
my $db = _get_db();
my $user = $db->resultset('User')->find($id);
- return to_json { error => 'no_such_user' } if not defined $id;
+ return to_json { error => 'no_such_user' } if not defined $user;
my @fields = qw(id name email fname lname verified register_ts);
my %data = map { $_ => $user->$_ } @fields;
return to_json \%data;
@@ -246,9 +246,14 @@ post '/register' => sub {
sub register_user {
my %args = @_;
- # validate
$args{email} = lc $args{email};
+ # for now we force the username to be lower case.
+ # later we might allow mixed case usernames but we still want to
+ # make sure the lower case versions are unique
+ $args{uname} = lc $args{uname};
+
+ # validate
my $db = _get_db();
if ( length $args{uname} < 2 or $args{uname} =~ /[^\w.-]/ ) {
return 'invalid_username';
@@ -261,6 +266,7 @@ sub register_user {
if ($user) {
return 'email_used';
}
+
if ( length $args{pw1} < 5 ) {
return 'short_password';
}
View
2 lib/Dwimmer/Client.pm
@@ -8,7 +8,7 @@ has host => ( is => 'ro', isa => 'Str', required => 1 );
has mech => ( is => 'rw', isa => 'WWW::Mechanize', default => sub { WWW::Mechanize->new } );
-our $VERSION = '0.22';
+our $VERSION = '0.23';
# get_user parameters can be id => 1
View
2 lib/Dwimmer/Tools.pm
@@ -9,7 +9,7 @@ use YAML;
use Dwimmer::DB;
-our $VERSION = '0.22';
+our $VERSION = '0.23';
our $SCHEMA_VERSION = 1;
View
6 script/dwimmer_setup.pl
@@ -72,9 +72,11 @@
my $dist_dir;
# When we are in the development environment (have .git) set this to the root directory
-# When we are in the installation environment (have Makefile.PL) set this to the root directory
-if (grep { -e File::Spec->catdir(dirname(dirname abs_path($0)) , $_) } ('.git', 'Makefile.PL')) {
+# When we are in the installation environment (have Makefile.PL) set this to the share/ subdirectory
+if (-e File::Spec->catdir(dirname(dirname abs_path($0)) , '.git') ) {
$dist_dir = dirname(dirname abs_path($0))
+} elsif (-e File::Spec->catdir(dirname(dirname abs_path($0)) , 'Makefile.PL') ) {
+ $dist_dir = File::Spec->catdir( dirname(dirname abs_path($0)), 'share' );
} else {
$dist_dir = File::ShareDir::dist_dir('Dwimmer');
}
View
19 t/003_client.t
@@ -18,7 +18,7 @@ plan( skip_all => 'Unsupported OS' ) if not $run;
my $url = "http://localhost:$ENV{DWIMMER_PORT}";
-plan( tests => 49 );
+plan( tests => 51 );
my @pages = (
{},
@@ -95,6 +95,13 @@ cmp_deeply(
'show user details'
);
+is_deeply(
+ $admin->get_user( id => 2 ),
+ { error => 'no_such_user',
+ },
+ 'asking for not existing user'
+);
+
is_deeply( $admin->add_user( %{ $users[0] } ), { error => 'invalid_verify' }, 'no verify field provided' );
$users[0]{verify} = 'abc';
is_deeply( $admin->add_user( %{ $users[0] } ), { error => 'invalid_verify' }, 'really invalid verify field provided' );
@@ -108,12 +115,18 @@ is_deeply(
'try to add user with same mail after ucfirst'
);
+diag('email is case insensitive and saves as lower case');
$users[0]{email} = uc $users[0]{email};
is_deeply( $admin->add_user( %{ $users[0] } ), { error => 'email_used' }, 'try to add user with same mail after uc' );
$users[0]{email} = 'test2@dwimmer.org';
$users[0]{pw1} = $users[0]{pw2} = $users[0]{password};
-is_deeply( $admin->add_user( %{ $users[0] } ), { success => 1 }, 'add user with same mail' );
+is_deeply( $admin->add_user( %{ $users[0] } ), { success => 1 }, 'add user with different mail' );
+
+my %usr = %{ $users[0] };
+$usr{uname} = uc $usr{uname};
+$usr{email} = 'test3@dwimmer.org';
+is_deeply( $admin->add_user( %usr ), { error => 'username_taken' }, 'add user with same username in different case' );
is_deeply(
$admin->list_users,
@@ -150,6 +163,8 @@ cmp_deeply(
'show user details'
);
+
+
cmp_deeply(
$admin->get_pages,
{ rows => [
View
1 t/015_polls.t
@@ -14,7 +14,6 @@ eval "use Test::More";
eval "use Test::Deep";
require Test::WWW::Mechanize;
plan( skip_all => 'Unsupported OS' ) if not $run;
-plan( skip_all => 'temporary skip' );
my $url = "http://localhost:$ENV{DWIMMER_PORT}";
View
6 t/lib/Dwimmer/Test.pm
@@ -39,10 +39,10 @@ sub start {
my $root = File::Spec->catdir( $dir, 'dwimmer' );
system
- "$^X -Ilib script/dwimmer_setup.pl --root $root --email $admin_mail --password $password";
+ "$^X -Ilib script/dwimmer_setup.pl --root $root --email $admin_mail --password $password" and die $!;
- mkdir "$root/polls";
- copy("t/files/testing-polls.json", "$root/polls");
+ mkdir "$root/polls" or die $!;
+ copy("t/files/testing-polls.json", "$root/polls") or die $!;
if ( $^O =~ /win32/i ) {

0 comments on commit 345d6db

Please sign in to comment.
Something went wrong with that request. Please try again.