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 CompanyableTrait to Department model #13415

Merged
merged 4 commits into from
Sep 14, 2023

Conversation

marcusmoore
Copy link
Collaborator

@marcusmoore marcusmoore commented Aug 8, 2023

Description

This PR adds a couple (see edit) simple tests around the Api/DepartmentsController's index method to ensure it returns the number of rows expected (specific values aren't tested) and that the results adhere to full company scoping when it is enabled.

Since we have a passing test for adhering to company scoping we can add the CompanyableTrait to the Department model and remove the Company::scopeCompanyables() wrapper in the controller.

This is another small step in the direction of simplifying how models are scoped to companies.


Edit: snuck in a couple more simple tests for authentication and authorization.

Type of change

  • Bug fix (non-breaking change which fixes an issue) (sort of ❓)

@marcusmoore marcusmoore marked this pull request as ready for review August 8, 2023 00:13
@marcusmoore marcusmoore requested a review from snipe as a code owner August 8, 2023 00:13
@what-the-diff
Copy link

what-the-diff bot commented Aug 8, 2023

PR Summary

  • Enhanced Data Selection in Department Details
    Upgraded the process of data retrieval for department details. Now, it focuses only on specific columns from the 'departments' table, reducing data load. Additionally, the image of each department is now part of the data selected, which should enhance the visual presentation. The number of users in each department is also counted and attached for reference, aiding in usage analytics.

  • Incorporated CompanyableTrait in Department Model
    Introduced a new trait, 'CompanyableTrait,' into the department model. This trait signifies that our department can inherit certain functionalities related to the company context, providing greater flexibility and reusability of code.

  • Added DepartmentIndex Tests
    Introduced new test cases to ensure that the 'Department Index' endpoint works correctly. It is now confirmed that 'DepartmentIndex' returns the expected departments and strictly adheres to company scoping, providing proof of reliability and adherence to business rules.

@marcusmoore
Copy link
Collaborator Author

@snipe is there anything holding this back?

@snipe snipe merged commit d916e20 into snipe:develop Sep 14, 2023
@marcusmoore marcusmoore deleted the feature/department-scoping branch September 14, 2023 19:46
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