-
-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.x] Use authenticated user in Git events even when queued (#9225)
- Loading branch information
1 parent
a001e7d
commit 720d8a8
Showing
7 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ public function setUp(): void | |
Config::set('statamic.git.enabled', true); | ||
|
||
$this->actingAs( | ||
User::make() | ||
$user = User::make() | ||
->id('chewbacca') | ||
->email('[email protected]') | ||
->data(['name' => 'Chewbacca']) | ||
|
@@ -47,11 +47,13 @@ public function setUp(): void | |
Storage::fake('test'); | ||
|
||
Git::shouldReceive('statuses'); | ||
Git::shouldReceive('as')->with($user)->andReturnSelf(); | ||
} | ||
|
||
/** @test */ | ||
public function it_doesnt_commit_when_git_is_disabled() | ||
{ | ||
Git::shouldReceive('as')->never(); | ||
Git::shouldReceive('dispatchCommit')->with('Collection saved')->never(); | ||
Git::shouldReceive('dispatchCommit')->with('Collection deleted')->never(); | ||
|
||
|
@@ -66,6 +68,7 @@ public function it_doesnt_commit_when_git_is_disabled() | |
/** @test */ | ||
public function it_doesnt_commit_when_automatic_is_disabled() | ||
{ | ||
Git::shouldReceive('as')->never(); | ||
Git::shouldReceive('dispatchCommit')->with('Collection saved')->never(); | ||
Git::shouldReceive('dispatchCommit')->with('Collection deleted')->never(); | ||
|
||
|
@@ -80,6 +83,7 @@ public function it_doesnt_commit_when_automatic_is_disabled() | |
/** @test */ | ||
public function it_doesnt_commit_ignored_events() | ||
{ | ||
Git::shouldReceive('as')->never(); | ||
Git::shouldReceive('dispatchCommit')->with('Collection saved')->never(); | ||
Git::shouldReceive('dispatchCommit')->with('Collection deleted')->once(); | ||
|
||
|
@@ -96,6 +100,7 @@ public function it_doesnt_commit_ignored_events() | |
/** @test */ | ||
public function it_doesnt_commit_when_event_subscriber_is_disabled() | ||
{ | ||
Git::shouldReceive('as')->never(); | ||
Git::shouldReceive('dispatchCommit')->with('Collection saved')->never(); | ||
Git::shouldReceive('dispatchCommit')->with('Collection deleted')->once(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,6 +181,16 @@ public function it_gets_git_user_info() | |
$this->assertEquals('Chewy', Git::gitUserName()); | ||
$this->assertEquals('[email protected]', Git::gitUserEmail()); | ||
|
||
$han = User::make() | ||
->email('[email protected]') | ||
->data(['name' => 'Han Solo']) | ||
->makeSuper(); | ||
|
||
$this->assertEquals('Han Solo', Git::as($han)->gitUserName()); | ||
$this->assertEquals('[email protected]', Git::as($han)->gitUserEmail()); | ||
$this->assertEquals('Chewy', Git::gitUserName()); | ||
$this->assertEquals('[email protected]', Git::gitUserEmail()); | ||
|
||
Config::set('statamic.git.use_authenticated', false); | ||
|
||
$this->assertEquals('Spock', Git::gitUserName()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters