User: sits    
  Date: 08/08/27 01:43:10

  Modified:    t/Http/Method view-topic-text.t edit-project.t
               lib/Codestriker/Http Dispatcher.pm
  Added:       t/Http/Method update-project.t
               lib/Codestriker/Http/Method UpdateProjectMethod.pm
  Log:
  Last method that needed implementing - update project.
  
  
  
  Index: view-topic-text.t
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/t/Http/Method/view-topic-text.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- view-topic-text.t 10 Aug 2008 12:18:42 -0000      1.1
  +++ view-topic-text.t 27 Aug 2008 08:43:10 -0000      1.2
  @@ -1,7 +1,7 @@
   # Tests for the ViewTopicText method.
   
   use strict;
  -use Test::More tests => 8;
  +use Test::More tests => 7;
   
   use lib '../../../lib';
   use Test::MockObject;
  @@ -43,15 +43,6 @@
        pass("View URL missing topicid parameter");
   }   
   
  -eval {
  -     $url_cgi->url(topicid => 1234, filenumber => 2, line => 3, new => 1);
  -     fail("View URL missing projectid parameter");
  -};
  -if ($@) {
  -     # Expected.
  -     pass("View URL missing projectid parameter");
  -}   
  -
   # Check that the parameters extracted correctly.
   my $mock_http_input = Test::MockObject->new();
   $mock_http_input->{query} = $mock_query;
  
  
  
  
  
  Index: edit-project.t
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/t/Http/Method/edit-project.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- edit-project.t    10 Aug 2008 12:18:42 -0000      1.1
  +++ edit-project.t    27 Aug 2008 08:43:10 -0000      1.2
  @@ -18,9 +18,9 @@
   my $url_nice = 
Codestriker::Http::Method::EditProjectMethod->new($mock_query, 0);
   
   is($url_cgi->url(45), $mock_query->url() . 
'?action=edit_project&projectid=45',
  -   "List projects URL CGI syntax");
  +   "Edit project URL CGI syntax");
   is($url_nice->url(45), $mock_query->url() . '/admin/project/45/edit',
  -   "List projects URL nice syntax");
  +   "Edit project URL nice syntax");
   
   # Check that the parameters extracted correctly.
   my $mock_http_input = Test::MockObject->new();
  
  
  
  
  
  Index: update-project.t
  ===================================================================
  RCS file: update-project.t
  diff -N update-project.t
  --- /dev/null 1 Jan 1970 00:00:00 -0000
  +++ update-project.t  27 Aug 2008 08:43:10 -0000      1.1
  @@ -0,0 +1,34 @@
  +# Tests for the UpdateProject method.
  +
  +use strict;
  +use Test::More tests => 3;
  +
  +use lib '../../../lib';
  +use Test::MockObject;
  +use Codestriker;
  +use Codestriker::Http::Method::UpdateProjectMethod;
  +
  +# Create a CGI mock object for these tests.
  +my $mock_query = Test::MockObject->new();
  +$mock_query->mock('url',
  +            sub { 'http://localhost.localdomain/codestriker/codestriker.pl' 
} );
  +
  +# Create two method objects to test each URL scheme.
  +my $url_cgi = 
Codestriker::Http::Method::UpdateProjectMethod->new($mock_query, 1);
  +my $url_nice = 
Codestriker::Http::Method::UpdateProjectMethod->new($mock_query, 0);
  +
  +is($url_cgi->url(45), $mock_query->url() . '?action=submit_editproject',
  +   "Update project URL CGI syntax");
  +is($url_nice->url(45), $mock_query->url() . '/admin/project/45/update',
  +   "Update project URL nice syntax");
  +
  +# Check that the parameters extracted correctly.
  +my $mock_http_input = Test::MockObject->new();
  +$mock_http_input->{query} = $mock_query;
  +$mock_query->mock('path_info',
  +                  sub {
  +                     return $mock_query->url() . '/admin/project/45/update';
  +                  });
  +$mock_query->mock('param', sub { return undef; });                  
  +$url_nice->extract_parameters($mock_http_input);
  +is ($mock_http_input->{projectid}, "45", "projectid nice URL parameter 
extraction");
  
  
  
  
  
  Index: Dispatcher.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Http/Dispatcher.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Dispatcher.pm     26 Aug 2008 22:18:50 -0000      1.6
  +++ Dispatcher.pm     27 Aug 2008 08:43:10 -0000      1.7
  @@ -28,6 +28,7 @@
   use Codestriker::Http::Method::CreateProjectMethod;
   use Codestriker::Http::Method::DownloadMetricsMethod;
   use Codestriker::Http::Method::EditProjectMethod;
  +use Codestriker::Http::Method::UpdateProjectMethod;
   use Codestriker::Http::Method::ListProjectsMethod;
   use Codestriker::Http::Method::SearchTopicsMethod;
   use Codestriker::Http::Method::SubmitSearchTopicsMethod;
  @@ -63,6 +64,7 @@
        push @methods, 
Codestriker::Http::Method::DownloadTopicTextMethod->new($query);
        push @methods, 
Codestriker::Http::Method::DownloadMetricsMethod->new($query);
        push @methods, 
Codestriker::Http::Method::EditProjectMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::UpdateProjectMethod->new($query);
        push @methods, 
Codestriker::Http::Method::ListProjectsMethod->new($query);
        push @methods, 
Codestriker::Http::Method::SearchTopicsMethod->new($query);
        push @methods, 
Codestriker::Http::Method::SubmitSearchTopicsMethod->new($query);
  
  
  
  
  
  Index: UpdateProjectMethod.pm
  ===================================================================
  RCS file: UpdateProjectMethod.pm
  diff -N UpdateProjectMethod.pm
  --- /dev/null 1 Jan 1970 00:00:00 -0000
  +++ UpdateProjectMethod.pm    27 Aug 2008 08:43:10 -0000      1.1
  @@ -0,0 +1,51 @@
  
+###############################################################################
  +# Codestriker: Copyright (c) 2001, 2002 David Sitsky.  All rights reserved.
  +# [EMAIL PROTECTED]
  +#
  +# This program is free software; you can redistribute it and modify it under
  +# the terms of the GPL.
  +
  +# Method for updating a project.
  +
  +package Codestriker::Http::Method::UpdateProjectMethod;
  +
  +use strict;
  +use Codestriker::Http::Method;
  +
  [EMAIL PROTECTED]::Http::Method::UpdateProjectMethod::ISA = 
("Codestriker::Http::Method");
  +
  +# Generate a URL for this method.
  +sub url() {
  +    my ($self, $projectid) = @_;
  +     
  +    if ($self->{cgi_style}) {
  +        return $self->{url_prefix} . "?action=submit_editproject";
  +    } else {
  +     return $self->{url_prefix} . "/admin/project/$projectid/update";
  +    }
  +}
  +
  +sub extract_parameters {
  +     my ($self, $http_input) = @_;
  +     
  +     my $action = $http_input->{query}->param('action'); 
  +    my $path_info = $http_input->{query}->path_info();
  +    if ($self->{cgi_style} && defined $action && $action eq 
"submit_editproject") {  
  +             $http_input->extract_cgi_parameters();
  +             return 1;
  +     } elsif ($path_info =~ 
m{^$self->{url_prefix}/admin/project/\d+/update$}) {
  +         $self->_extract_nice_parameters($http_input,
  +                                         project => 'projectid');
  +             return 1;
  +     } else {
  +             return 0;
  +     }
  +}
  +
  +sub execute {
  +     my ($self, $http_input, $http_output) = @_;
  +     
  +     Codestriker::Action::SubmitEditProject->process($http_input, 
$http_output);
  +}
  +
  +1;
  
  
  

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits

Reply via email to