aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Users.pm17
-rw-r--r--perllib/FixMyStreet/App/Controller/Test.pm60
2 files changed, 75 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Users.pm b/perllib/FixMyStreet/App/Controller/Admin/Users.pm
index d29d2b8b9..fd18caf21 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Users.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Users.pm
@@ -174,7 +174,7 @@ sub add : Local : Args(0) {
$c->forward( '/admin/log_edit', [ $user->id, 'user', 'edit' ] );
$c->flash->{status_message} = _("Updated!");
- $c->res->redirect( $c->uri_for_action( 'admin/users/edit', $user->id ) );
+ $c->detach('post_edit_redirect', [ $user ]);
}
sub fetch_body_roles : Private {
@@ -415,7 +415,8 @@ sub edit : Path : Args(1) {
$c->forward( '/admin/log_edit', [ $id, 'user', 'edit' ] );
}
$c->flash->{status_message} = _("Updated!");
- return $c->res->redirect( $c->uri_for_action( 'admin/users/edit', $user->id ) );
+
+ $c->detach('post_edit_redirect', [ $user ]);
}
if ( $user->from_body ) {
@@ -442,6 +443,18 @@ sub edit : Path : Args(1) {
return 1;
}
+sub post_edit_redirect : Private {
+ my ( $self, $c, $user ) = @_;
+
+ # User may not be visible on this cobrand, e.g. if their from_body
+ # wasn't set.
+ if ( $c->cobrand->users->find( { id => $user->id } ) ) {
+ return $c->res->redirect( $c->uri_for_action( 'admin/users/edit', $user->id ) );
+ } else {
+ return $c->res->redirect( $c->uri_for_action( 'admin/users/index' ) );
+ }
+}
+
sub import :Local {
my ( $self, $c, $id ) = @_;
diff --git a/perllib/FixMyStreet/App/Controller/Test.pm b/perllib/FixMyStreet/App/Controller/Test.pm
new file mode 100644
index 000000000..5ec4bebf3
--- /dev/null
+++ b/perllib/FixMyStreet/App/Controller/Test.pm
@@ -0,0 +1,60 @@
+package FixMyStreet::App::Controller::Test;
+use Moose;
+use namespace::autoclean;
+
+use File::Basename;
+
+BEGIN { extends 'Catalyst::Controller'; }
+
+=head1 NAME
+
+FixMyStreet::App::Controller::Test - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Test-helping Catalyst Controller.
+
+=head1 METHODS
+
+=over 4
+
+=item auto
+
+Makes sure this controller is only available when run in test.
+
+=cut
+
+sub auto : Private {
+ my ($self, $c) = @_;
+ $c->detach( '/page_error_404_not_found' ) unless FixMyStreet->test_mode;
+ return 1;
+}
+
+=item setup
+
+Sets up a particular browser test.
+
+=cut
+
+sub setup : Path('/_test/setup') : Args(1) {
+ my ( $self, $c, $test ) = @_;
+ if ($test eq 'regression-duplicate-hide') {
+ my $problem = FixMyStreet::DB->resultset("Problem")->find(1);
+ $problem->update({ category => 'Skips' });
+ $c->response->body("OK");
+ }
+}
+
+sub teardown : Path('/_test/teardown') : Args(1) {
+ my ( $self, $c, $test ) = @_;
+ if ($test eq 'regression-duplicate-hide') {
+ my $problem = FixMyStreet::DB->resultset("Problem")->find(1);
+ $problem->update({ category => 'Potholes' });
+ $c->response->body("OK");
+ }
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+