Skip to content

Commit

Permalink
Fixed private build
Browse files Browse the repository at this point in the history
  • Loading branch information
korridor committed Apr 15, 2024
1 parent 5080025 commit 97bb751
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-private.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:
only_args: --no-dev --no-ansi --no-interaction --prefer-dist --ignore-platform-reqs --classmap-authoritative
php_version: 8.3

- name: "Setup PHP with PECL extension"
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, dom, fileinfo, pgsql, swoole

- name: "Install dependencies"
uses: php-actions/composer@v6
if: steps.cache-vendor.outputs.cache-hit != 'true' # Skip if cache hit
Expand All @@ -48,6 +54,9 @@ jobs:
- name: "Build"
run: npm run build

- name: "Activate billing extension"
run: php artisan module:enable Billing

- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
Expand Down
10 changes: 10 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
* @property string $timezone
* @property bool $is_placeholder
* @property Weekday $week_start
* @property-read Organization $currentTeam
* @property Collection<Organization> $organizations
* @property Collection<TimeEntry> $timeEntries
*
* @method HasMany<Organization> ownedTeams()
* @method static UserFactory factory()
* @method static Builder<User> query()
* @method Builder<User> belongsToOrganization(Organization $organization)
* @method Builder<User> active()
*/
class User extends Authenticatable implements FilamentUser
{
Expand Down Expand Up @@ -131,6 +133,14 @@ public function timeEntries(): HasMany
return $this->hasMany(TimeEntry::class);
}

/**
* @param Builder<User> $builder
*/
public function scopeActive(Builder $builder): void
{
$builder->where('is_placeholder', '=', false);
}

/**
* @param Builder<User> $builder
* @return Builder<User>
Expand Down
22 changes: 22 additions & 0 deletions tests/Unit/Model/UserModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
use App\Providers\Filament\AdminPanelProvider;
use Filament\Panel;
use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;

#[CoversClass(User::class)]
#[UsesClass(User::class)]
class UserModelTest extends ModelTestAbstract
{
public function test_normal_user_can_not_access_admin_panel(): void
Expand Down Expand Up @@ -87,4 +91,22 @@ public function test_it_has_many_time_entries(): void
$this->assertCount(3, $timeEntriesRel);
$this->assertTrue($timeEntriesRel->first()->is($timeEntries->first()));
}

public function test_scope_active_returns_only_non_placeholder_users(): void
{
// Arrange
$placeholder = User::factory()->create([
'is_placeholder' => true,
]);
$user = User::factory()->create([
'is_placeholder' => false,
]);

// Act
$activeUsers = User::query()->active()->get();

// Assert
$this->assertCount(1, $activeUsers);
$this->assertTrue($activeUsers->first()->is($user));
}
}

0 comments on commit 97bb751

Please sign in to comment.