-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed priority for category eula vs default eula #15445
Conversation
PR Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works but can we add a test case for it?
Here is a test that fails on develop and passes on this branch:
public function testDefaultEulaIsSentWhenSetInCategory()
{
Notification::fake();
$this->settings->setEula('My Custom EULA Text');
$user = User::factory()->create();
$category = Category::factory()->create([
'use_default_eula' => 1,
'eula_text' => 'EULA Text that should not be used',
]);
$model = AssetModel::factory()->for($category)->create();
$asset = Asset::factory()->for($model, 'model')->create();
$asset->checkOut($user, User::factory()->superuser()->create()->id);
Notification::assertSentTo($user, CheckoutAssetNotification::class, function ($notification) {
$content = $notification->toMail()->render();
return str_contains($content, 'My Custom EULA Text') && !str_contains($content, 'EULA Text that should not be used');
});
}
This is the change to Tests\Support\Settings
(drop it right above the set()
method):
public function setEula($text = 'Default EULA text')
{
return $this->update(['default_eula_text' => $text]);
}
I think we can add it to NotificationTest
(we should probably move that class to Feature\Notifications\Email\
but we don't need to do it now...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but one more thing...
app/View/Label.php
Outdated
implode(' ', [$previous['label'], $previous['value']]), | ||
implode(' ', [$current['label'], $current['value']]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this supposed to be included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops those are changes for something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍🏾
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that setEula() method just for the tests?
@@ -121,6 +121,10 @@ public function enableBadPasswordLdap(): Settings | |||
'ldap_basedn' => 'CN=Users,DC=ad,DC=example,Dc=com' | |||
]); | |||
} | |||
public function setEula($text = 'Default EULA text') | |||
{ | |||
return $this->update(['default_eula_text' => $text]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's only used for testing. In this case it's in NotificationTest@testDefaultEulaIsSentWhenSetInCategory
on line 40. It's setting it in the application's global settings so we can assert against it further down.
Description
This adds a check to see if the
use_default_eula
is enabled while the categoryeula_text
is populated. properly selecting the eula intended to be used now.Fixes #[sc-26637]
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: