More tests, also fixes.

master
Manager Bot 3 years ago
parent dc4c4674f4
commit 2ce2d6b846
  1. 12
      Web/lib/MJB/Web/Controller/Dashboard.pm
  2. 45
      Web/t/01_endpoints/04_dashboard/11_blog_settings.t
  3. 6
      Web/templates/dashboard/blog_settings.html.ep

@ -201,9 +201,9 @@ sub blog_settings ($c) {
my $data = $c->jekyll($blog->domain->name)->config->data;
$c->stash->{form_title} = $data->{title};
$c->stash->{form_desc} = $data->{description};
$c->stash->{form_email} = $data->{email};
$c->stash->{form}->{title} = $data->{title};
$c->stash->{form}->{desc} = $data->{description};
$c->stash->{form}->{email} = $data->{email};
}
#==
@ -219,9 +219,9 @@ sub do_blog_settings ($c) {
my $jekyll = $c->jekyll($blog->domain->name);
my $title = $c->stash->{form_title} = $c->param( 'configTitle' );
my $desc = $c->stash->{form_desc} = $c->param( 'configDesc' );
my $email = $c->stash->{form_email} = $c->param( 'configEmail' );
my $title = $c->stash->{form}->{title} = $c->param( 'configTitle' );
my $desc = $c->stash->{form}->{desc} = $c->param( 'configDesc' );
my $email = $c->stash->{form}->{email} = $c->param( 'configEmail' );
$jekyll->config->data->{title} = $title;
$jekyll->config->data->{description} = $desc;

@ -0,0 +1,45 @@
#!/usr/bin/env perl
use MJB::Web::Test;
#==
# This test ensures that the settings panel for the blog can be viewed.
#
# 1. Create user and login.
# 2. Make a new blog.
# 3. Go to the settings panel
# 4. Confirm the stash values.
#==
my $t = Test::Mojo::MJB->new('MJB::Web');
my $blog_id = $t->create_user
->post_ok( '/blog/domain', form => {
domain => 'blog.example.com',
calling_route => 'show_blog_domain_owned',
})
->get_ok( '/dashboard' )
->stash->{blogs}->[0]->id;
$t->get_ok( "/dashboard/blog/$blog_id" )
->status_is( 200 )
->code_block( sub {
my $self = shift;
ok exists $self->stash->{blog}, "The blog loads!";
is $self->stash->{blog}->domain->name, 'blog.example.com', "Correct domain name for id.";
});
$t->get_ok( "/dashboard/blog/$blog_id/settings" )
->code_block(sub {
my $self = shift;
ok exists $self->stash->{form}->{title}, 'There is a title';
ok exists $self->stash->{form}->{desc}, 'There is a description';
ok exists $self->stash->{form}->{email}, 'There is an email';
})
->status_is( 200 );
#==
# Remove Jekyll blog repos that were created as a part of this test.
#==
$t->clear_tempdir;
done_testing;

@ -7,17 +7,17 @@
<form method="POST" action="<%= $c->url_for( 'do_dashboard_blog_settings' ) %>">
<div class="mt-3 mb-3">
<label for="configTitle" class="col-sm-2 col-form-label">Title</label>
<input type="text" class="form-control" id="configTitle" name="configTitle" value="<%= $c->stash->{form_title} %>">
<input type="text" class="form-control" id="configTitle" name="configTitle" value="<%= $c->stash->{form}->{title} %>">
</div>
<div class="mt-3 mb-3">
<label for="configDesc" class="col-sm-2 col-form-label">Description</label>
<input type="text" class="form-control" id="configDesc" name="configDesc" value="<%= $c->stash->{form_desc} %>">
<input type="text" class="form-control" id="configDesc" name="configDesc" value="<%= $c->stash->{form}->{desc} %>">
</div>
<div class="mt-3 mb-3">
<label for="configEmail" class="col-sm-2 col-form-label">Email</label>
<input type="text" class="form-control" id="configEmail" name="configEmail" value="<%= $c->stash->{form_email} %>">
<input type="text" class="form-control" id="configEmail" name="configEmail" value="<%= $c->stash->{form}->{email} %>">
</div>
<div class="mb-3">

Loading…
Cancel
Save