From 1fcff6e58cda487fc5e82fb1b9ccbe83ea14d7ea Mon Sep 17 00:00:00 2001 From: Seb Dangerfield <1449113+sedan07@users.noreply.github.com> Date: Thu, 28 Jan 2021 17:20:49 +0000 Subject: [PATCH] Don't use last component group id for "other" section on subscription page Otherwise this breaks then there aren't any component groups as it cannot use the last value the var was assigned as it never happened. #8 --- app/Http/Controllers/SubscribeController.php | 2 +- resources/views/subscribe/manage.blade.php | 4 +-- tests/SmokeTest.php | 35 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/SubscribeController.php b/app/Http/Controllers/SubscribeController.php index afa866a9610e..1052794220b7 100644 --- a/app/Http/Controllers/SubscribeController.php +++ b/app/Http/Controllers/SubscribeController.php @@ -67,7 +67,7 @@ public function __construct(Guard $auth) public function showSubscribe() { return View::make('subscribe.subscribe') - ->withAboutApp(Markdown::convertToHtml(Config::get('setting.app_about'))); + ->withAboutApp(Markdown::convertToHtml(Config::get('setting.app_about', ''))); } /** diff --git a/resources/views/subscribe/manage.blade.php b/resources/views/subscribe/manage.blade.php index 23472c6be3e1..cb3df4facb19 100644 --- a/resources/views/subscribe/manage.blade.php +++ b/resources/views/subscribe/manage.blade.php @@ -45,9 +45,9 @@
{{ trans('cachet.components.group.other') }}
- {{ trans('cachet.components.select_all') }} + {{ trans('cachet.components.select_all') }}  |  - {{ trans('cachet.components.deselect_all') }} + {{ trans('cachet.components.deselect_all') }}
@foreach($ungroupedComponents as $component) diff --git a/tests/SmokeTest.php b/tests/SmokeTest.php index d3f91bdd3004..b064de684ea8 100644 --- a/tests/SmokeTest.php +++ b/tests/SmokeTest.php @@ -15,6 +15,10 @@ use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\Setting; use Illuminate\Foundation\Testing\DatabaseMigrations; +use Illuminate\Support\Facades\Notification; +use CachetHQ\Cachet\Notifications\Subscriber\VerifySubscriptionNotification; +use CachetHQ\Cachet\Models\Subscriber; +use Illuminate\Support\Facades\URL; /** * This is the smoke test class. @@ -44,6 +48,37 @@ public function test_single_component_page() $this->get('/incidents/1')->assertStatus(200); } + /** + * Test the subscribe process works + */ + public function test_subscribe_page() + { + $this->configureApp(); + + Notification::fake(); + + $this->get('/subscribe')->assertStatus(200); + + Notification::assertNothingSent(); + + $this->post('/subscribe', ['email' => 'test@example.com'])->assertStatus(302); + + $subscriber = Subscriber::where('email', 'test@example.com')->first(); + + Notification::assertSentTo( + [$subscriber], + VerifySubscriptionNotification::class + ); + + $verify_route = URL::signedRoute(cachet_route_generator('subscribe.verify'), ['code' => $subscriber->verify_code]); + + $this->followingRedirects()->get($verify_route)->assertStatus(200); + + # Subscriber should now be verified + $subscriber->refresh(); + $this->assertEquals(true, $subscriber->getIsVerifiedAttribute()); + } + public function test_dashboard_auth_page() { $this->configureApp();