Showing 3 changed files with 70 additions and 1 deletions
BIN
xt/basic_enc.db
Binary file not shown.
+36
xt/basic_enc.t
... ...
@@ -0,0 +1,36 @@
1
+use Test::More 'no_plan';
2
+
3
+use FindBin;
4
+use utf8;
5
+use lib "$FindBin::Bin/../mojo/lib";
6
+use lib "$FindBin::Bin/../lib";
7
+use lib "$FindBin::Bin/../extlib/lib/perl5";
8
+use Encode qw/encode decode/;
9
+
10
+use Test::Mojo;
11
+
12
+# Test DB
13
+$ENV{GITPREP_DB_FILE} = "$FindBin::Bin/basic_enc.db";
14
+
15
+# Test Repository home
16
+$ENV{GITPREP_REP_HOME} = "$FindBin::Bin/../../gitprep_t_rep_home";
17
+
18
+$ENV{GITPREP_NO_MYCONFIG} = 1;
19
+
20
+use Gitprep;
21
+
22
+my $app = Gitprep->new;
23
+my $t = Test::Mojo->new($app);
24
+
25
+my $user = 'kimoto';
26
+my $project = 'gitprep_t';
27
+
28
+# For perl 5.8
29
+{
30
+  no warnings 'redefine';
31
+  sub note { print STDERR "# $_[0]\n" unless $ENV{HARNESS_ACTIVE} }
32
+}
33
+
34
+# Encoding(EUC-jp)
35
+$t->get_ok("/$user/$project/blob/ed7b91659762fa612563f0595f3faca6aecfcfa0/euc-jp.txt");
36
+$t->content_like(qr/あああ/);
+34 -1
xt/user.t
... ...
@@ -20,7 +20,6 @@ my $rep_home = $ENV{GITPREP_REP_HOME} = "$FindBin::Bin/user";
20 20
 
21 21
 $ENV{GITPREP_NO_MYCONFIG} = 1;
22 22
 
23
-
24 23
 use Gitprep;
25 24
 
26 25
 # For perl 5.8
... ...
@@ -607,3 +606,37 @@ note 'Private repository and collaborator';
607 606
   $t->get_ok("/kimoto/t1");
608 607
   $t->content_like(qr/t1 is private repository/);
609 608
 }
609
+
610
+note 'Project encoding';
611
+{
612
+  unlink $db_file;
613
+  rmtree $rep_home;
614
+
615
+  my $app = Gitprep->new;
616
+  my $t = Test::Mojo->new($app);
617
+  $t->ua->max_redirects(3);
618
+
619
+  # Create admin user
620
+  $t->post_ok('/_start?op=create', form => {password => 'a', password2 => 'a'});
621
+  $t->content_like(qr/Login page/);
622
+
623
+  # Login success
624
+  $t->post_ok('/_login?op=login', form => {id => 'admin', password => 'a'});
625
+  $t->content_like(qr/Admin/);
626
+  
627
+  # Create user
628
+  $t->post_ok('/_admin/user/create?op=create', form => {id => 'kimoto', password => 'a', password2 => 'a'});
629
+  $t->content_like(qr/Success.*created/);
630
+
631
+  # Login as kimoto
632
+  $t->post_ok('/_login?op=login', form => {id => 'kimoto', password => 'a'});
633
+  $t->get_ok('/')->content_like(qr/kimoto/);
634
+
635
+  # Create repository
636
+  $t->post_ok('/_new?op=create', form => {project => 't1', description => 'Hello', readme => 1});
637
+  $t->content_like(qr/README/);
638
+  
639
+  # Change encoding
640
+  $t->post_ok("/kimoto/t1/settings?op=encoding", form => {encoding => 'EUC-jp'});
641
+  $t->content_like(qr/Encoding is EUC-jp/);
642
+}