Skip to content

Commit

Permalink
Merge pull request #37 from clarkeash/fix/case-sensitivity
Browse files Browse the repository at this point in the history
fix case-sensitivity
  • Loading branch information
clarkeash committed Oct 14, 2018
2 parents e7228e8 + ce8735a commit 7cdfe6e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
32 changes: 16 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Carbon\Carbon;
use Clarkeash\Doorman\Exceptions\DuplicateException;
use Clarkeash\Doorman\Models\Invite;
use Illuminate\Support\Str;

class Generator
{
Expand Down Expand Up @@ -94,7 +95,7 @@ public function expiresIn($days = 14)
protected function build(): Invite
{
$invite = new Invite;
$invite->code = $this->manager->code();
$invite->code = Str::upper($this->manager->code());
$invite->for = $this->email;
$invite->max = $this->uses;
$invite->valid_until = $this->expiry;
Expand Down
14 changes: 14 additions & 0 deletions tests/Feature/CheckInvitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,18 @@ public function it_can_have_unlimited_redemptions()
Assert::assertTrue(Doorman::check('ABCDE'));
}
}

/**
* @test
*/
public function it_is_not_case_sensitive()
{
Invite::forceCreate([
'code' => 'ABCDE',
]);

Assert::assertTrue(Doorman::check('ABCDE'));
Assert::assertTrue(Doorman::check('abcde'));
Assert::assertTrue(Doorman::check('AbCdE'));
}
}
12 changes: 12 additions & 0 deletions tests/Feature/GenerateInvitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,16 @@ public function only_one_invite_per_email_can_be_generated_2()
{
Doorman::generate()->for('me@ashleyclarke.me')->times(3)->make();
}

/**
* @test
*/
public function generated_codes_should_always_be_uppercase()
{
Doorman::generate()->make();

$invite = Invite::first();

Assert::assertEquals(strtoupper($invite->code), $invite->code);
}
}

0 comments on commit 7cdfe6e

Please sign in to comment.