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

feat: limit User model to a single membership #135

Merged
merged 35 commits into from May 19, 2022

Conversation

greatislander
Copy link
Contributor

@greatislander greatislander commented May 12, 2022

This PR makes a few changes:

  1. Users can not be a member of more than one Organization. This is enforced when a User attempts to create or join an Organization if they already are part of one.
  2. Memberships and Invitations now use more conventional Controller methods and Form requests instead of Actions for clarity and consistency with other Controllers.
  3. The HearthCommand has been updated to use file globbing to copy stubs rather than requiring changes every time a new stub file is added.

@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #135 (96cb663) into main (dc740d8) will increase coverage by 8.27%.
The diff coverage is 47.82%.

❗ Current head 96cb663 differs from pull request most recent head 02365ea. Consider uploading reports for the commit 02365ea to get more accurate results

@@             Coverage Diff              @@
##               main     #135      +/-   ##
============================================
+ Coverage     54.09%   62.36%   +8.27%     
- Complexity       73       82       +9     
============================================
  Files            21       25       +4     
  Lines           342      372      +30     
============================================
+ Hits            185      232      +47     
+ Misses          157      140      -17     
Impacted Files Coverage Δ
src/Commands/HearthCommand.php 22.22% <14.28%> (+3.17%) ⬆️
src/HearthServiceProvider.php 100.00% <100.00%> (+3.70%) ⬆️
src/Models/Invitation.php 100.00% <100.00%> (ø)
src/Models/Membership.php 100.00% <100.00%> (ø)
src/Traits/AriaDescribable.php 100.00% <100.00%> (ø)
src/Traits/HandlesValidation.php 80.00% <100.00%> (ø)
src/Traits/HasInvitations.php 100.00% <100.00%> (ø)
src/Traits/HasMembers.php 100.00% <100.00%> (ø)
src/Components/Textarea.php 100.00% <0.00%> (+100.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc740d8...02365ea. Read the comment docs.

@greatislander greatislander marked this pull request as ready for review May 17, 2022 01:10
@greatislander greatislander self-assigned this May 17, 2022
@greatislander greatislander added the enhancement New feature or request label May 17, 2022
@greatislander greatislander added this to In progress in v3 via automation May 17, 2022
@greatislander greatislander added this to the v3 milestone May 17, 2022
@greatislander greatislander marked this pull request as draft May 19, 2022 13:24
@greatislander greatislander marked this pull request as ready for review May 19, 2022 15:10
Comment on lines +13 to +26
protected function getEnvironmentSetUp($app)
{
Schema::dropAllTables();

$create_users_table = include __DIR__ . '/../../database/migrations/create_users_table.php.stub';
$update_users_table = include __DIR__ . '/../../database/migrations/update_users_table.php.stub';
$create_memberships_table = include __DIR__ . '/../../database/migrations/2021_03_01_000000_create_memberships_table.php';
$create_organizations_table = include __DIR__ . '/../../database/migrations/create_organizations_table.php.stub';

$create_users_table->up();
$update_users_table->up();
$create_memberships_table->up();
$create_organizations_table->up();
}
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this will work for you, but I used the DatabaseMigrations trait to run the migrations with the tests.

@jobara
Copy link
Member

jobara commented May 19, 2022

@greatislander I'm getting errors when running composer test from hearth directly. The first thing I had to do was create the test database. However, after that there are still errors. I think they're all instances of the following:

In Organization.php line 13:
                                                         
  Trait "Spatie\Translatable\HasTranslations" not found  

Not sure if there's something I'm missing and causing this error. For the database requirement, it's probably best to update the README to explain what's needed.

@jobara
Copy link
Member

jobara commented May 19, 2022

In Organization.php line 13:
                                                         
  Trait "Spatie\Translatable\HasTranslations" not found  

I missed running composer update, the tests are passing now.

v3 automation moved this from In progress to Reviewer approved May 19, 2022
@greatislander greatislander merged commit 78280b4 into main May 19, 2022
v3 automation moved this from Reviewer approved to Done May 19, 2022
@greatislander greatislander deleted the feat/single-memberships branch May 19, 2022 19:33
greatislander added a commit that referenced this pull request May 19, 2022
Co-authored-by: greatislander <greatislander@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
v3
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants