From d6b9a62e0a13497b8cc40eb1db56d1ec2b3760ea Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 19 Nov 2018 00:43:52 +0100 Subject: Extract counters from accounts table to account_stats table (#9295) --- spec/models/account_spec.rb | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'spec/models/account_spec.rb') diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 60d13d32e..9133616a2 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -754,24 +754,6 @@ RSpec.describe Account, type: :model do expect(Account.suspended).to match_array([account_1]) end end - - describe 'without_followers' do - it 'returns a relation of accounts without followers' do - account_1 = Fabricate(:account) - account_2 = Fabricate(:account) - Fabricate(:follow, account: account_1, target_account: account_2) - expect(Account.without_followers).to match_array([account_1]) - end - end - - describe 'with_followers' do - it 'returns a relation of accounts with followers' do - account_1 = Fabricate(:account) - account_2 = Fabricate(:account) - Fabricate(:follow, account: account_1, target_account: account_2) - expect(Account.with_followers).to match_array([account_2]) - end - end end context 'when is local' do -- cgit From 395615d9f3c521824f7e56f6d1bb2d82b8e421b4 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 27 Nov 2018 12:28:01 +0100 Subject: Allow hyphens in the middle of remote user names (#9345) Fixes #9309 This only allows hyphens in the middle of a username, much like dots, although I don't have a compelling reason to do so other than keeping the changes minimal. --- app/models/account.rb | 2 +- spec/models/account_spec.rb | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'spec/models/account_spec.rb') diff --git a/app/models/account.rb b/app/models/account.rb index 46d32a36e..f25263306 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -46,7 +46,7 @@ # class Account < ApplicationRecord - USERNAME_RE = /[a-z0-9_]+([a-z0-9_\.]+[a-z0-9_]+)?/i + USERNAME_RE = /[a-z0-9_]+([a-z0-9_\.-]+[a-z0-9_]+)?/i MENTION_RE = /(?<=^|[^\/[:word:]])@((#{USERNAME_RE})(?:@[a-z0-9\.\-]+[a-z0-9]+)?)/i include AccountAvatar diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 9133616a2..f7f78d34c 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -618,9 +618,15 @@ RSpec.describe Account, type: :model do expect(account).not_to model_have_error_on_field(:username) end - it 'is invalid if the username doesn\'t only contains letters, numbers and underscores' do + it 'is valid even if the username contains hyphens' do account = Fabricate.build(:account, domain: 'domain', username: 'the-doctor') account.valid? + expect(account).to_not model_have_error_on_field(:username) + end + + it 'is invalid if the username doesn\'t only contains letters, numbers, underscores and hyphens' do + account = Fabricate.build(:account, domain: 'domain', username: 'the doctor') + account.valid? expect(account).to model_have_error_on_field(:username) end -- cgit