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

Added tests around asset check in and added missing actions to the api controller action #14260

Merged
merged 32 commits into from
Feb 28, 2024

Conversation

marcusmoore
Copy link
Collaborator

@marcusmoore marcusmoore commented Feb 13, 2024

Description

This PR adds tests around asset check-in via the web and API endpoints. In the process I added some missing actions that the web controller contained that were missing from the api controller:

  • Migrating "legacy" locations from 0 to null/''
  • Accepts the update_default_location=true field to update the asset's rtd_location_id to the provided location_id.
    • Note: the web controller already has this but uses 0 instead of true
  • Clears pending checkout acceptances

I did some test organization and controller code clean up to make things a little easier to follow as well.


Something to note: providing a checkin_at via the web results in the action_date in the action log being {provided_date} 00:00:00. The api behavior differs by taking the provided checkin_at and adding the current time (if the request happens at 8:37:01am then the result is {provided_date} 08:37:01. Let me know if I should bring that behavior in sync.


Type of change

  • Tests

Copy link

This pull request has been linked to Shortcut Story #24808: Add tests around asset check in.

Copy link

what-the-diff bot commented Feb 13, 2024

PR Summary

  • Enhancements to AssetFactory
    We have introduced a new feature to the AssetFactory class named assignedToUser(User $user = null). This improvement will allow the assignment of assets to specific users more efficiently.

  • Changes to AssetCheckinTest File
    We've taken some restructuring steps for our test files. The old AssetCheckinTest.php file located in tests/Feature/Assets has been removed.

  • Introduction of a New Test File
    A new test file called AssetCheckinTest.php has been added under tests/Feature/Checkins. This file includes several new testing methods:

    • testCheckingInAssetRequiresCorrectPermission() ensures that only users with the correct permissions can check in assets.
    • testAssetCanBeCheckedIn() verifies if the assets can be checked in as expected.
    • testCheckInEmailSentToUserIfSettingEnabled() confirms that a check-in email is sent if the function is enabled.
    • testCheckInEmailNotSentToUserIfSettingDisabled() tests that no email is sent if the sending email option is turned off.
    • testLastCheckInFieldIsSetOnCheckin() checks that the last check-in field is updated whenever an asset is checked in.

@marcusmoore marcusmoore marked this pull request as ready for review February 27, 2024 20:31
@marcusmoore marcusmoore requested a review from snipe as a code owner February 27, 2024 20:31
@marcusmoore marcusmoore changed the title Added tests around asset check in Added tests around asset check in and added missing actions to the api controller action Feb 27, 2024
@snipe snipe merged commit a494103 into snipe:develop Feb 28, 2024
8 checks passed
@marcusmoore marcusmoore deleted the chore/sc-24808 branch March 6, 2024 19:42
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.

2 participants