Skip to content

Commit 96eb62c

Browse files
committed
Rename twitter_handle field
1 parent 4d35ed6 commit 96eb62c

File tree

7 files changed

+22
-31
lines changed

7 files changed

+22
-31
lines changed

app/Http/Requests/UpdateProfileRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function rules()
1212
'name' => 'required|max:255',
1313
'email' => 'required|email|max:255|unique:users,email,'.Auth::id(),
1414
'username' => 'required|alpha_dash|max:255|unique:users,username,'.Auth::id(),
15-
'twitter_handle' => 'max:255|nullable|unique:users,twitter_handle,'.Auth::id(),
15+
'twitter' => 'max:255|nullable|unique:users,twitter,'.Auth::id(),
1616
'bio' => 'max:160',
1717
];
1818
}
@@ -39,6 +39,6 @@ public function username(): string
3939

4040
public function twitterHandle(): ?string
4141
{
42-
return $this->get('twitter_handle');
42+
return $this->get('twitter');
4343
}
4444
}

app/Jobs/UpdateProfile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class UpdateProfile
2222
public function __construct(User $user, array $attributes = [])
2323
{
2424
$this->user = $user;
25-
$this->attributes = Arr::only($attributes, ['name', 'email', 'username', 'github_username', 'bio', 'twitter_handle']);
25+
$this->attributes = Arr::only($attributes, ['name', 'email', 'username', 'github_username', 'bio', 'twitter']);
2626
}
2727

2828
public static function fromRequest(User $user, UpdateProfileRequest $request): self
@@ -32,7 +32,7 @@ public static function fromRequest(User $user, UpdateProfileRequest $request): s
3232
'email' => $request->email(),
3333
'username' => strtolower($request->username()),
3434
'bio' => trim(strip_tags($request->bio())),
35-
'twitter_handle' => $request->twitterHandle(),
35+
'twitter' => $request->twitterHandle(),
3636
]);
3737
}
3838

app/User.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class User extends Authenticatable implements MustVerifyEmail
3939
protected $fillable = [
4040
'name',
4141
'email',
42-
'twitter_handle',
42+
'twitter',
4343
'username',
4444
'password',
4545
'ip',
@@ -87,7 +87,7 @@ public function githubUsername(): string
8787

8888
public function twitterHandle(): ?string
8989
{
90-
return $this->twitter_handle;
90+
return $this->twitter;
9191
}
9292

9393
public function gravatarUrl($size = 100): string

database/migrations/2020_07_16_185353_update_articles_table_add_shared_at_field.php renamed to database/migrations/2020_07_16_185353_update_articles_and_users_tables_to_include_share_information.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class UpdateArticlesTableAddSharedAtField extends Migration
7+
class UpdateArticlesAndUsersTablesToIncludeShareInformation extends Migration
88
{
99
public function up()
1010
{
1111
Schema::table('articles', function (Blueprint $table) {
1212
$table->dateTime('shared_at')->after('approved_at')->nullable();
1313
});
14+
15+
Schema::table('users', function (Blueprint $table) {
16+
$table->string('twitter')->after('email')->nullable();
17+
});
1418
}
1519
}

database/migrations/2020_07_18_122946_update_users_table_add_twitter_handle_field.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/Feature/SettingsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public function users_can_update_their_profile()
2727
'name' => 'Freek Murze',
2828
'email' => 'freek@example.com',
2929
'username' => 'freekmurze',
30-
'twitter_handle' => 'freek-murze',
30+
'twitter' => 'freektwitter',
3131
'bio' => 'My bio',
3232
])
3333
->seePageIs('/settings')
3434
->see('Freek Murze')
3535
->see('freekmurze')
36-
->see('freek-murze')
36+
->see('freektwitter')
3737
->see('Settings successfully saved!')
3838
->see('My bio');
3939
}
@@ -113,9 +113,9 @@ public function users_can_set_their_password_when_they_have_none_set_yet()
113113
}
114114

115115
/** @test */
116-
public function twitter_handle_is_optional()
116+
public function twitter_is_optional()
117117
{
118-
$user = $this->createUser(['email' => 'freek@example.com', 'username' => 'freekmurze', 'twitter_handle' => 'freek-murze']);
118+
$user = $this->createUser(['email' => 'freek@example.com', 'username' => 'freekmurze', 'twitter' => 'freektwitter']);
119119

120120
$this->loginAs($user);
121121

@@ -124,10 +124,10 @@ public function twitter_handle_is_optional()
124124
'name' => 'Freek Murze',
125125
'email' => 'freek@example.com',
126126
'username' => 'freekmurze',
127-
'twitter_handle' => '',
127+
'twitter' => '',
128128
])
129129
->seePageIs('/settings')
130-
->dontSee('freek-murze');
130+
->dontSee('freektwitter');
131131

132132
$this->assertNull($user->fresh()->twitterHandle());
133133
}

tests/Unit/Commands/PostArticleToTwitterTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public function published_articles_can_be_shared_on_twitter()
3838
PostArticleToTwitterNotification::class,
3939
function ($notification, $channels, $notifiable) use ($article) {
4040
$tweet = $notification->generateTweet();
41-
return Str::contains($tweet, 'My First Article') &&
42-
Str::contains($tweet, route('articles.show', $article->slug()));
41+
return (
42+
Str::contains($tweet, 'My First Article') &&
43+
Str::contains($tweet, route('articles.show', $article->slug()))
44+
);
4345
}
4446
);
4547

@@ -50,7 +52,7 @@ function ($notification, $channels, $notifiable) use ($article) {
5052
public function articles_are_shared_with_twitter_handle()
5153
{
5254
$user = $this->createUser([
53-
'twitter_handle' => '_joedixon',
55+
'twitter' => '_joedixon',
5456
]);
5557

5658
factory(Article::class)->create([

0 commit comments

Comments
 (0)