Skip to content
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

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

Godmartinz
Copy link
Collaborator

Description

This adds a check to see if the use_default_eula is enabled while the category eula_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.

  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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 A
  • Test B

Test Configuration:

  • PHP version:
  • MySQL version
  • Webserver version
  • OS version

Checklist:

Copy link

what-the-diff bot commented Sep 3, 2024

PR Summary

  • Modification to getEula() function in Asset.php
    The function has been updated to include an additional check within its operation. This newly added condition verifies whether the model category is using the default End User License Agreement (EULA) or not. If it is not using the default EULA, the function will provide the standard EULA text from system settings, offering consistency across different model categories.

Copy link
Collaborator

@marcusmoore marcusmoore left a 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...)

Copy link
Collaborator

@marcusmoore marcusmoore left a 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...

Comment on lines 161 to 162
implode(' ', [$previous['label'], $previous['value']]),
implode(' ', [$current['label'], $current['value']]),
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@marcusmoore marcusmoore left a 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 👍🏾

Copy link
Owner

@snipe snipe left a 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]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing?

Copy link
Collaborator

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.

@snipe snipe merged commit f6bf2d0 into snipe:develop Sep 10, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants