[Codestriker-commits] CVS update: codestriker/t/Http url-builder.t
Brought to you by:
sits
|
From: <si...@us...> - 2008-08-10 12:18:45
|
User: sits
Date: 08/08/10 05:18:44
Modified: lib/Codestriker/TopicListeners BugTracking.pm Email.pm
lib/Codestriker/Action ListTopics.pm ViewTopicInfo.pm
ViewTopicComments.pm SubmitNewTopic.pm
SubmitNewComment.pm ListTopicsRSS.pm
ViewTopicProperties.pm ViewTopic.pm CreateTopic.pm
ListProjects.pm EditComment.pm
lib/Codestriker/Http Input.pm UrlBuilder.pm
Added: lib/Codestriker/Http/Method StaticResourcesMethod.pm
CreateTopicMethod.pm ViewTopicTextMethod.pm
SearchTopicsMethod.pm DownloadMetricsMethod.pm
AddCommentMethod.pm CreateProjectMethod.pm
ViewMetricsMethod.pm ViewTopicPropertiesMethod.pm
ViewTopicCommentsMethod.pm ListProjectsMethod.pm
EditProjectMethod.pm ViewTopicMetricsMethod.pm
ViewTopicFileMethod.pm ListTopicsMethod.pm
t/Http/Method create-project.t view-topic-properties.t
add-comment.t view-metrics.t list-projects.t
view-topic-comments.t view-topic-metrics.t
create-topic.t search-topics.t view-topic-text.t
list-topics.t edit-project.t download-metrics.t
view-topic-file.t
lib/Codestriker/Http Method.pm
t/Http url-builder.t
Log:
Initial major refactoring of the URL/dispatch system Codestriker uses. Still quite a bit of work to do, but this is a step in the direction of still supporting the old CGI URLs, but now supports nicer REST-style URLs as well.
Index: StaticResourcesMethod.pm
===================================================================
RCS file: StaticResourcesMethod.pm
diff -N StaticResourcesMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StaticResourcesMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,42 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for returning the URL to static resources, such as online help.
+
+package Codestriker::Http::Method::StaticResourcesMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::StaticResourcesMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ # Check if the HTML files are accessible via another URL (required for
+ # sourceforge deployment), which is specified via $Codestriker::codestriker_css.
+ my $htmlurl;
+ if (defined $Codestriker::codestriker_css &&
+ $Codestriker::codestriker_css ne "" &&
+ $Codestriker::codestriker_css =~ /[\/\\]/o) {
+ $htmlurl = $Codestriker::codestriker_css;
+ $htmlurl =~ s/\/.+?\.css//;
+ } else {
+ # Standard Codestriker deployment.
+ $htmlurl = $self->{url_prefix};
+ $htmlurl =~ s/codestriker\/codestriker\.pl/codestrikerhtml/;
+ }
+
+ if ($self->{cgi_style}) {
+ return $htmlurl;
+ } else {
+ return $self->{url_prefix} . "/static";
+ }
+}
+
+1;
Index: CreateTopicMethod.pm
===================================================================
RCS file: CreateTopicMethod.pm
diff -N CreateTopicMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CreateTopicMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,53 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for creating a topic.
+
+package Codestriker::Http::Method::CreateTopicMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::CreateTopicMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, $obsoletes) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=create" .
+ (defined $obsoletes ? "&obsoletes=$obsoletes" : "");
+ } else {
+ return $self->{url_prefix} . "/topics/create" .
+ (defined $obsoletes ? "/obsoletes/$obsoletes" : "");
+ }
+}
+
+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 "create") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/topics/create/}) {
+ $self->_extract_nice_parameters($http_input,
+ obsoletes => 'obsoletes');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::CreateTopic->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicTextMethod.pm
===================================================================
RCS file: ViewTopicTextMethod.pm
diff -N ViewTopicTextMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicTextMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,64 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for viewing the topic text.
+
+package Codestriker::Http::Method::ViewTopicTextMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicTextMethod::ISA =
+ ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, %args) = @_;
+
+ die "Parameter topicid missing" unless defined $args{topicid};
+ die "Parameter projectid missing" unless defined $args{projectid};
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=view&topic=$args{topicid}" .
+ (defined $args{updated} ? "&updated=$args{updated}" : "") .
+ (defined $args{tabwidth} ? "&tabwidth=$args{tabwidth}" : "") .
+ (defined $args{mode} ? "&mode=$args{mode}" : "") .
+ (defined $args{fview} ? "&fview=$args{fview}" : "") .
+ (defined $args{filenumber} ? "#" . "$args{filenumber}|$args{line}|$args{new}" : "");
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/text" .
+ (defined $args{fview} ? "/filenumber/$args{filenumber}" : "") .
+ (defined $args{mode} ? "/mode/$args{mode}" : "") .
+ (defined $args{filenumber} ? "#" . "$args{filenumber}|$args{line}|$args{new}" : "");
+ }
+}
+
+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 "view") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/text}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid',
+ filenumber => 'fview', mode => 'mode');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopic->process($http_input, $http_output);
+}
+
+1;
Index: SearchTopicsMethod.pm
===================================================================
RCS file: SearchTopicsMethod.pm
diff -N SearchTopicsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SearchTopicsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for searching topics.
+
+package Codestriker::Http::Method::SearchTopicsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::SearchTopicsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=search";
+ } else {
+ return $self->{url_prefix} . "/topics/search";
+ }
+}
+
+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 "search") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/topics/search/}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::Search->process($http_input, $http_output);
+}
+
+1;
Index: DownloadMetricsMethod.pm
===================================================================
RCS file: DownloadMetricsMethod.pm
diff -N DownloadMetricsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DownloadMetricsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for donwloading metrics.
+
+package Codestriker::Http::Method::DownloadMetricsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::DownloadMetricsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=metrics_download";
+ } else {
+ return $self->{url_prefix} . "/metrics/download";
+ }
+}
+
+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 "metrics_download") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/metrics/download$}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::MetricsReport->process_download($http_input, $http_output);
+}
+
+1;
Index: AddCommentMethod.pm
===================================================================
RCS file: AddCommentMethod.pm
diff -N AddCommentMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AddCommentMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,63 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for adding a comment to a topic.
+
+package Codestriker::Http::Method::AddCommentMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::AddCommentMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, %args) = @_;
+
+ die "Parameter topicid missing" unless defined $args{topicid};
+ die "Parameter projectid missing" unless defined $args{projectid};
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=edit&fn=$args{filenumber}&line=$args{line}&new=$args{new}&topic=$args{topicid}" .
+ (defined $args{anchor} ? "&a=$args{anchor}" : "") .
+ (defined $args{context} ? "&context=$args{context}" : "");
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/comment/" .
+ "$args{filenumber}|$args{line}|$args{new}/add" .
+ (defined $args{anchor} ? "/anchor/$args{anchor}" : "") .
+ (defined $args{context} ? "/context/$args{context}" : "");
+ }
+}
+
+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 "edit") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/comment/(\d+)\|(\d+)\|(\d+)/add}) {
+ $http_input->{fn} = $1;
+ $http_input->{line} = $2;
+ $http_input->{new} = $3;
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid',
+ anchor => 'anchor', context => 'context');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::EditComment->process($http_input, $http_output);
+}
+
+1;
Index: CreateProjectMethod.pm
===================================================================
RCS file: CreateProjectMethod.pm
diff -N CreateProjectMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CreateProjectMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for creating a project.
+
+package Codestriker::Http::Method::CreateProjectMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::CreateProjectMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=create_project";
+ } else {
+ return $self->{url_prefix} . "/admin/projects/create";
+ }
+}
+
+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 "create_project") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/admin/projects/create$}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::CreateProject->process($http_input, $http_output);
+}
+
+1;
Index: ViewMetricsMethod.pm
===================================================================
RCS file: ViewMetricsMethod.pm
diff -N ViewMetricsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewMetricsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for viewing metrics.
+
+package Codestriker::Http::Method::ViewMetricsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewMetricsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=metrics_report";
+ } else {
+ return $self->{url_prefix} . "/metrics/view";
+ }
+}
+
+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 "metrics_report") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/metrics/view$}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::MetricsReport->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicPropertiesMethod.pm
===================================================================
RCS file: ViewTopicPropertiesMethod.pm
diff -N ViewTopicPropertiesMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicPropertiesMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,54 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for viewing the topic properties.
+
+package Codestriker::Http::Method::ViewTopicPropertiesMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicPropertiesMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, %args) = @_;
+
+ die "Parameter topicid missing" unless defined $args{topicid};
+ die "Parameter projectid missing" unless defined $args{projectid};
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=view_topic_properties&topic=$args{topicid}";
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/properties";
+ }
+}
+
+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 "view_topic_properties") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/properties}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopicProperties->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicCommentsMethod.pm
===================================================================
RCS file: ViewTopicCommentsMethod.pm
diff -N ViewTopicCommentsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicCommentsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,54 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for viewing topic comments.
+
+package Codestriker::Http::Method::ViewTopicCommentsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicCommentsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, %args) = @_;
+
+ die "Parameter topicid missing" unless defined $args{topicid};
+ die "Parameter projectid missing" unless defined $args{projectid};
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=list_comments&topic=$args{topicid}";
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/comments";
+ }
+}
+
+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 "list_comments") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/comments}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopicComments->process($http_input, $http_output);
+}
+
+1;
Index: ListProjectsMethod.pm
===================================================================
RCS file: ListProjectsMethod.pm
diff -N ListProjectsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ListProjectsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for listing the projects.
+
+package Codestriker::Http::Method::ListProjectsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ListProjectsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=list_projects";
+ } else {
+ return $self->{url_prefix} . "/admin/projects/list";
+ }
+}
+
+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 "list_project") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/admin/projects/list$}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ListProjects->process($http_input, $http_output);
+}
+
+1;
Index: EditProjectMethod.pm
===================================================================
RCS file: EditProjectMethod.pm
diff -N EditProjectMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ EditProjectMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,51 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for editing a project.
+
+package Codestriker::Http::Method::EditProjectMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::EditProjectMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, $projectid) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=edit_project&projectid=$projectid";
+ } else {
+ return $self->{url_prefix} . "/admin/project/$projectid/edit";
+ }
+}
+
+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 "edit_project") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/admin/project/\d+/edit$}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::EditProject->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicMetricsMethod.pm
===================================================================
RCS file: ViewTopicMetricsMethod.pm
diff -N ViewTopicMetricsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicMetricsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,54 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for viewing the topic metrics.
+
+package Codestriker::Http::Method::ViewTopicMetricsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicMetricsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, %args) = @_;
+
+ die "Parameter topicid missing" unless defined $args{topicid};
+ die "Parameter projectid missing" unless defined $args{projectid};
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=viewinfo&topic=$args{topicid}";
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/metrics";
+ }
+}
+
+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 "viewinfo") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/metrics}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopicInfo->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicFileMethod.pm
===================================================================
RCS file: ViewTopicFileMethod.pm
diff -N ViewTopicFileMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicFileMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,60 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for viewing the a topic file.
+
+package Codestriker::Http::Method::ViewTopicFileMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicFileMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, %args) = @_;
+
+ die "Parameter topicid missing" unless defined $args{topicid};
+ die "Parameter projectid missing" unless defined $args{projectid};
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=view_file&fn=$args{filenumber}&" .
+ "topic=$args{topicid}&new=$args{new}" .
+ (defined $args{mode} ? "&mode=$args{mode}" : "") .
+ (defined $args{line} ? "#$args{filenumber}|$args{line}|$args{new}" : "");
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/file/$args{filenumber}" .
+ (defined $args{mode} ? "/mode/$args{mode}" : "") .
+ (defined $args{line} ? "#$args{filenumber}|$args{line}|$args{new}" : "");
+ }
+}
+
+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 "view_file") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/file/\d+}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid',
+ file => 'fn');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopicFile->process($http_input, $http_output);
+}
+
+1;
Index: ListTopicsMethod.pm
===================================================================
RCS file: ListTopicsMethod.pm
diff -N ListTopicsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ListTopicsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,90 @@
+###############################################################################
+# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved.
+# si...@us...
+#
+# This program is free software; you can redistribute it and modify it under
+# the terms of the GPL.
+
+# Method for listing topics.
+
+package Codestriker::Http::Method::ListTopicsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ListTopicsMethod::ISA =
+ ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, %args) = @_;
+
+ my $sstate = defined $args{sstate} ? CGI::escape(join ',', @{$args{sstate}}) : "";
+ my $sproject = defined $args{sproject} ? CGI::escape(join ',', @{$args{sproject}}) : "";
+ my $action = defined $args{rss} && $args{rss} ? "list_topics_rss" : "list_topics";
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=$action" .
+ (defined $args{sauthor} && $args{sauthor} ne "" ? "&sauthor=" . CGI::escape($args{sauthor}) : "") .
+ (defined $args{sreviewer} && $args{sreviewer} ne "" ? "&sreviewer=" . CGI::escape($args{sreviewer}) : "") .
+ (defined $args{scc} && $args{scc} ne "" ? "&scc=" . CGI::escape($args{scc}) : "") .
+ (defined $args{sbugid} && $args{sbugid} ne "" ? "&sbugid=" . CGI::escape($args{sbugid}) : "") .
+ (defined $args{stext} && $args{stext} ne "" ? "&stext=" . CGI::escape($args{stext}) : "") .
+ (defined $args{stitle} && $args{stitle} ne "" ? "&stitle=" . CGI::escape($args{stitle}) : "") .
+ (defined $args{sdescription} && $args{sdescription} ne "" ? "&sdescription=" . CGI::escape($args{sdescription}) : "") .
+ (defined $args{scomments} && $args{scomments} ne "" ? "&scomments=" . CGI::escape($args{scomments}) : "") .
+ (defined $args{sbody} && $args{sbody} ne "" ? "&sbody=" . CGI::escape($args{sbody}) : "") .
+ (defined $args{sfilename} && $args{sfilename} ne "" ? "&sfilename=" . CGI::escape($args{sfilename}) : "") .
+ (defined $args{content} && $args{content} ne "" ? "&content=" . CGI::escape($args{content}) : "") .
+ ($sstate ne "" ? "&sstate=$sstate" : "") .
+ ($sproject ne "" ? "&sproject=$sproject" : "");
+ } else {
+ return $self->{url_prefix} .
+ ($action eq "list_topics_rss" ? "/feed" : "") . "/topics/list" .
+ (defined $args{sauthor} && $args{sauthor} ne "" ? "/author/" . CGI::escape($args{sauthor}) : "") .
+ (defined $args{sreviewer} && $args{sreviewer} ne "" ? "/reviewer/" . CGI::escape($args{sreviewer}) : "") .
+ (defined $args{scc} && $args{scc} ne "" ? "/cc/" . CGI::escape($args{scc}) : "") .
+ (defined $args{sbugid} && $args{sbugid} ne "" ? "/bugid/" . CGI::escape($args{sbugid}) : "") .
+ (defined $args{stext} && $args{stext} ne "" ? "/text/" . CGI::escape($args{stext}) : "") .
+ (defined $args{stitle} && $args{stitle} ne "" ? "/title/" . CGI::escape($args{stitle}) : "") .
+ (defined $args{sdescription} && $args{sdescription} ne "" ? "/description/" . CGI::escape($args{sdescription}) : "") .
+ (defined $args{scomments} && $args{scomments} ne "" ? "/comment/" . CGI::escape($args{scomments}) : "") .
+ (defined $args{sbody} && $args{sbody} ne "" ? "/body/" . CGI::escape($args{sbody}) : "") .
+ (defined $args{sfilename} && $args{sfilename} ne "" ? "/filename/" . CGI::escape($args{sfilename}) : "") .
+ (defined $args{content} && $args{content} ne "" ? "/content/" . CGI::escape($args{content}) : "") .
+ ($sstate ne "" ? "/state/$sstate" : "") .
+ ($sproject ne "" ? "/project/$sproject" : "");
+ }
+}
+
+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 "list_topics" || $action eq "list_topics_rss")) {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/feed/topics/list} ||
+ $path_info =~ m{^$self->{url_prefix}/topics/list}) {
+ $self->_extract_nice_parameters($http_input,
+ author => 'sauthor', reviewer => 'sreviewer',
+ cc => 'scc', bugid => 'sbugid', text => 'stext',
+ title => 'stitle', description => 'sdescription',
+ comment => 'scomments', body => 'sbody',
+ filename => 'sfilename', content => 'content',
+ state => 'sstate', project => 'sproject');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ListTopics->process($http_input, $http_output);
+}
+
+1;
Index: create-project.t
===================================================================
RCS file: create-project.t
diff -N create-project.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ create-project.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,23 @@
+# Tests for the CreateProject method.
+
+use strict;
+use Test::More tests => 2;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::CreateProjectMethod;
+
+# 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::CreateProjectMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::CreateProjectMethod->new($mock_query, 0);
+
+is($url_cgi->url(), $mock_query->url() . '?action=create_project',
+ "List projects URL CGI syntax");
+is($url_nice->url(), $mock_query->url() . '/admin/projects/create',
+ "List projects URL nice syntax");
Index: view-topic-properties.t
===================================================================
RCS file: view-topic-properties.t
diff -N view-topic-properties.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ view-topic-properties.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,40 @@
+# Tests for the ViewTopicProperties method.
+
+use strict;
+use Test::More tests => 4;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::ViewTopicPropertiesMethod;
+
+# 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::ViewTopicPropertiesMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::ViewTopicPropertiesMethod->new($mock_query, 0);
+
+is($url_cgi->url(topicid => 1234, projectid => 10),
+ $mock_query->url() . '?action=view_topic_properties&topic=1234',
+ "View topic properties URL CGI syntax");
+
+is($url_nice->url(topicid => 1234, projectid => 10),
+ $mock_query->url() . '/project/10/topic/1234/properties',
+ "View topic properties 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() . '/project/10/topic/1234/properties';
+ });
+$mock_query->mock('param', sub { return undef; });
+$url_nice->extract_parameters($mock_http_input);
+is ($mock_http_input->{projectid}, "10", "project nice URL parameter extraction");
+is ($mock_http_input->{topicid}, "1234", "topicid nice URL parameter extraction");
+
+
\ No newline at end of file
Index: add-comment.t
===================================================================
RCS file: add-comment.t
diff -N add-comment.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ add-comment.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,46 @@
+# Tests for the AddComment method.
+
+use strict;
+use Test::More tests => 8;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::AddCommentMethod;
+
+# 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::AddCommentMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::AddCommentMethod->new($mock_query, 0);
+
+is($url_cgi->url(filenumber => 3, line => 55, new => 0, topicid => 1234,
+ projectid => 10, context => 3),
+ $mock_query->url() . '?action=edit&fn=3&line=55&new=0&topic=1234&context=3',
+ "Add comment URL CGI syntax");
+
+is($url_nice->url(filenumber => 3, line => 55, new => 0, topicid => 1234,
+ projectid => 10, context => 3),
+ $mock_query->url() . '/project/10/topic/1234/comment/3|55|0/add/context/3',
+ "Add comment 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() . '/project/10/topic/1234/comment/3|55|0/add/context/3';
+ });
+$mock_query->mock('param', sub { return undef; });
+$url_nice->extract_parameters($mock_http_input);
+is ($mock_http_input->{projectid}, "10", "projectid nice URL parameter extraction");
+is ($mock_http_input->{topicid}, "1234", "topicid nice URL parameter extraction");
+is ($mock_http_input->{fn}, "3", "fn nice URL parameter extraction");
+is ($mock_http_input->{line}, "55", "line nice URL parameter extraction");
+is ($mock_http_input->{new}, "0", "new nice URL parameter extraction");
+is ($mock_http_input->{context}, "3", "context nice URL parameter extraction");
+
+
\ No newline at end of file
Index: view-metrics.t
===================================================================
RCS file: view-metrics.t
diff -N view-metrics.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ view-metrics.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,25 @@
+# Tests for the ViewMetrics method.
+
+use strict;
+use Test::More tests => 2;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::ViewMetricsMethod;
+
+# 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::ViewMetricsMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::ViewMetricsMethod->new($mock_query, 0);
+
+is($url_cgi->url(),
+ $mock_query->url() . '?action=metrics_report',
+ "View metric reports URL CGI syntax");
+is($url_nice->url(),
+ $mock_query->url() . '/metrics/view',
+ "View metric reports URL CGI syntax");
Index: list-projects.t
===================================================================
RCS file: list-projects.t
diff -N list-projects.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ list-projects.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,23 @@
+# Tests for the ListProjects method.
+
+use strict;
+use Test::More tests => 2;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::ListProjectsMethod;
+
+# 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::ListProjectsMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::ListProjectsMethod->new($mock_query, 0);
+
+is($url_cgi->url(), $mock_query->url() . '?action=list_projects',
+ "List projects URL CGI syntax");
+is($url_nice->url(), $mock_query->url() . '/admin/projects/list',
+ "List projects URL nice syntax");
Index: view-topic-comments.t
===================================================================
RCS file: view-topic-comments.t
diff -N view-topic-comments.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ view-topic-comments.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,40 @@
+# Tests for the ViewTopicComments method.
+
+use strict;
+use Test::More tests => 4;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::ViewTopicCommentsMethod;
+
+# 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::ViewTopicCommentsMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::ViewTopicCommentsMethod->new($mock_query, 0);
+
+is($url_cgi->url(topicid => 1234, projectid => 10),
+ $mock_query->url() . '?action=list_comments&topic=1234',
+ "View comments URL CGI syntax");
+
+is($url_nice->url(topicid => 1234, projectid => 10),
+ $mock_query->url() . '/project/10/topic/1234/comments',
+ "View comments 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() . '/project/10/topic/1234/comments';
+ });
+$mock_query->mock('param', sub { return undef; });
+$url_nice->extract_parameters($mock_http_input);
+is ($mock_http_input->{projectid}, "10", "projectid nice URL parameter extraction");
+is ($mock_http_input->{topicid}, "1234", "topicid nice URL parameter extraction");
+
+
\ No newline at end of file
Index: view-topic-metrics.t
===================================================================
RCS file: view-topic-metrics.t
diff -N view-topic-metrics.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ view-topic-metrics.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,40 @@
+# Tests for the ViewTopicMetrics method.
+
+use strict;
+use Test::More tests => 4;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::ViewTopicMetricsMethod;
+
+# 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::ViewTopicMetricsMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::ViewTopicMetricsMethod->new($mock_query, 0);
+
+is($url_cgi->url(topicid => 1234, projectid => 10),
+ $mock_query->url() . '?action=viewinfo&topic=1234',
+ "View topic metrics URL CGI syntax");
+
+is($url_nice->url(topicid => 1234, projectid => 10),
+ $mock_query->url() . '/project/10/topic/1234/metrics',
+ "View topic metrics 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() . '/project/10/topic/1234/metrics';
+ });
+$mock_query->mock('param', sub { return undef; });
+$url_nice->extract_parameters($mock_http_input);
+is ($mock_http_input->{projectid}, "10", "project nice URL parameter extraction");
+is ($mock_http_input->{topicid}, "1234", "topicid nice URL parameter extraction");
+
+
\ No newline at end of file
Index: create-topic.t
===================================================================
RCS file: create-topic.t
diff -N create-topic.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ create-topic.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,47 @@
+# Tests for the CreateTopic method.
+
+use strict;
+use Test::More tests => 5;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::CreateTopicMethod;
+
+# 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::CreateTopicMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::CreateTopicMethod->new($mock_query, 0);
+
+is($url_cgi->url(),
+ $mock_query->url() . '?action=create',
+ "Create topic URL CGI syntax");
+
+is($url_nice->url(),
+ $mock_query->url() . '/topics/create',
+ "Create topic URL nice syntax");
+
+is($url_cgi->url(45),
+ $mock_query->url() . '?action=create&obsoletes=45',
+ "Create topic with obsolete topics URL CGI syntax");
+
+is($url_nice->url(45),
+ $mock_query->url() . '/topics/create/obsoletes/45',
+ "Create topic with obsolete topics 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() . '/topics/create/obsoletes/45';
+ });
+$mock_query->mock('param', sub { return undef; });
+$url_nice->extract_parameters($mock_http_input);
+is ($mock_http_input->{obsoletes}, "45", "obsoletes nice URL parameter extraction");
+
+
\ No newline at end of file
Index: search-topics.t
===================================================================
RCS file: search-topics.t
diff -N search-topics.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ search-topics.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,23 @@
+# Tests for the SearchTopics method.
+
+use strict;
+use Test::More tests => 2;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::SearchTopicsMethod;
+
+# 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::SearchTopicsMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::SearchTopicsMethod->new($mock_query, 0);
+
+is($url_cgi->url(), $mock_query->url() . '?action=search',
+ "Search URL CGI syntax");
+is($url_nice->url(), $mock_query->url() . '/topics/search',
+ "Search URL nice syntax");
Index: view-topic-text.t
===================================================================
RCS file: view-topic-text.t
diff -N view-topic-text.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ view-topic-text.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,67 @@
+# Tests for the ViewTopicText method.
+
+use strict;
+use Test::More tests => 8;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::ViewTopicTextMethod;
+
+# 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::ViewTopicTextMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::ViewTopicTextMethod->new($mock_query, 0);
+
+is($url_cgi->url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1),
+ $mock_query->url() . '?action=view&topic=1234#2|3|1',
+ "View URL CGI syntax");
+
+is($url_nice->url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1),
+ $mock_query->url() . '/project/10/topic/1234/text#2|3|1',
+ "View URL nice syntax");
+
+is($url_cgi->url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1, fview => 2),
+ $mock_query->url() . '?action=view&topic=1234&fview=2#2|3|1',
+ "View URL CGI syntax specific file");
+
+is($url_nice->url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1, fview => 2),
+ $mock_query->url() . '/project/10/topic/1234/text/filenumber/2#2|3|1',
+ "View URL nice syntax specific file");
+
+# Check if parameters are missing.
+eval {
+ $url_cgi->url(projectid => 10, filenumber => 2, line => 3, new => 1);
+ fail("View URL missing topicid parameter");
+};
+if ($@) {
+ # Expected.
+ 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;
+$mock_query->mock('path_info',
+ sub {
+ return $mock_query->url() . '/project/10/topic/1234/text#2|3|1';
+ });
+$mock_query->mock('param', sub { return undef; });
+$url_nice->extract_parameters($mock_http_input);
+is ($mock_http_input->{projectid}, "10", "project nice URL parameter extraction");
+is ($mock_http_input->{topicid}, "1234", "topicid nice URL parameter extraction");
+
+
\ No newline at end of file
Index: list-topics.t
===================================================================
RCS file: list-topics.t
diff -N list-topics.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ list-topics.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,79 @@
+# Tests for the ListTopics method.
+
+use strict;
+use Test::More tests => 11;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::ListTopicsMethod;
+
+# 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::ListTopicsMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::ListTopicsMethod->new($mock_query, 0);
+
+# Test list topics URL generation.
+is ($url_cgi->url(sauthor => "sits", sreviewer => "engineering",
+ sbugid => "10,20", stitle => "Example title",
+ scomments => "Critical Error",
+ sstate => [0],
+ sproject => [10,20]),
+ $mock_query->url() . '?action=list_topics&sauthor=sits&sreviewer=engineering' .
+ '&sbugid=10%2C20&stitle=Example%20title&scomments=Critical%20Error' .
+ '&sstate=0&sproject=10%2C20',
+ "List topics URL CGI syntax");
+is ($url_nice->url(sauthor => "sits", sreviewer => "engineering",
+ sbugid => "10,20", stitle => "Example title",
+ scomments => "Critical Error",
+ sstate => [0],
+ sproject => [10,20]),
+ $mock_query->url() . '/topics/list/author/sits/reviewer/engineering' .
+ '/bugid/10%2C20/title/Example%20title/comment/Critical%20Error' .
+ '/state/0/project/10%2C20',
+ "List topics URL nice syntax");
+
+# Test list topics RSS URL generation.
+is ($url_cgi->url(sauthor => "sits", sreviewer => "engineering",
+ sbugid => "10,20", stitle => "Example title",
+ scomments => "Critical Error",
+ sstate => [0],
+ sproject => [10,20], rss => 1),
+ $mock_query->url() . '?action=list_topics_rss&sauthor=sits&sreviewer=engineering' .
+ '&sbugid=10%2C20&stitle=Example%20title&scomments=Critical%20Error' .
+ '&sstate=0&sproject=10%2C20',
+ "List topics URL CGI syntax");
+is ($url_nice->url(sauthor => "sits", sreviewer => "engineering",
+ sbugid => "10,20", stitle => "Example title",
+ scomments => "Critical Error",
+ sstate => [0], rss => 1,
+ sproject => [10,20]),
+ $mock_query->url() . '/feed/topics/list/author/sits/reviewer/engineering' .
+ '/bugid/10%2C20/title/Example%20title/comment/Critical%20Error' .
+ '/state/0/project/10%2C20',
+ "List topics 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() . '/topics/list/author/sits/reviewer/engineering' .
+ '/bugid/10%2C20/title/Example%20title/comment/Critical%20Error' .
+ '/state/0/project/10%2C30';
+ });
+$mock_query->mock('param', sub { return undef; });
+$url_nice->extract_parameters($mock_http_input);
+is ($mock_http_input->{sauthor}, "sits", "sauthor nice URL parameter extraction");
+is ($mock_http_input->{sreviewer}, "engineering", "sreviewer nice URL parameter extraction");
+is ($mock_http_input->{sbugid}, "10,20", "sbugid nice URL parameter extraction");
+is ($mock_http_input->{stitle}, "Example title", "stitle nice URL parameter extraction");
+is ($mock_http_input->{scomments}, "Critical Error", "scomment nice URL parameter extraction");
+is ($mock_http_input->{sstate}, "0", "sstate nice URL parameter extraction");
+is ($mock_http_input->{sproject}, "10,30", "sproject nice URL parameter extraction");
+
+
\ No newline at end of file
Index: edit-project.t
===================================================================
RCS file: edit-project.t
diff -N edit-project.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ edit-project.t 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,36 @@
+# Tests for the EditProject method.
+
+use strict;
+use Test::More tests => 3;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::EditProjectMethod;
+
+# 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::EditProjectMethod->new($mock_query, 1);
+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");
+is($url_nice->url(45), $mock_query->url() . '/admin/project/45/edit',
+ "List projects 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/edit';
+ });
+$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");
+
+
\ No newline at end of file
Index: download-metrics.t
===================================================================
RCS file: download-metrics.t
diff -N download-metrics.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ download-metr...
[truncated message content] |