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

[4.x] Test that global scopes on syncable models can break resource syncing #1285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lukinovec
Copy link
Contributor

Having global scopes on syncable models breaks resource syncing in some cases (in response to https://discord.com/channels/976506366502006874/1043694788358189167/1325068028567883786).

When using global scopes on a model, you can take advantage of the UpdateOrCreateSyncedResource::$scopeGetModelQuery property to exclude the global scope that makes the syncable model records excluded from resource syncing.

For example, in TSP's boot(), do:

UpdateOrCreateSyncedResource::$scopeGetModelQuery = function (Builder $query) {
     if ($query->getModel()->hasGlobalScope(FooScope::class)) {
         $query->withoutGlobalScope(FooScope::class);
     }
};

@lukinovec lukinovec changed the title Add test for syncable models with global scopes Test that global scopes on syncable models can break resource syncing Jan 7, 2025
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.73%. Comparing base (f955b38) to head (a0f4126).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1285      +/-   ##
============================================
+ Coverage     84.70%   84.73%   +0.03%     
  Complexity     1037     1037              
============================================
  Files           175      175              
  Lines          3047     3047              
============================================
+ Hits           2581     2582       +1     
+ Misses          466      465       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stancl stancl changed the title Test that global scopes on syncable models can break resource syncing [4.x] Test that global scopes on syncable models can break resource syncing Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant