mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Merge pull request #15445 from Godmartinz/eula_confusion
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run
Fixed priority for category eula vs default eula
This commit is contained in:
commit
f6bf2d03c4
|
@ -950,11 +950,12 @@ class Asset extends Depreciable
|
|||
{
|
||||
|
||||
if (($this->model) && ($this->model->category)) {
|
||||
if ($this->model->category->eula_text) {
|
||||
if (($this->model->category->eula_text) && ($this->model->category->use_default_eula === 0)) {
|
||||
return Helper::parseEscapedMarkedown($this->model->category->eula_text);
|
||||
} elseif ($this->model->category->use_default_eula == '1') {
|
||||
} elseif ($this->model->category->use_default_eula === 1) {
|
||||
return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text);
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,10 @@ class 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]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $attributes Attributes to modify in the application's settings.
|
||||
|
|
|
@ -33,4 +33,28 @@ class NotificationTest extends TestCase
|
|||
$asset->checkOut($user, $admin->id);
|
||||
Notification::assertSentTo($user, CheckoutAssetNotification::class);
|
||||
}
|
||||
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');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue