Fix RSpec/DescribedClass
cop (#25104)
This commit is contained in:
parent
1e243e2df7
commit
c42591356d
66 changed files with 347 additions and 414 deletions
|
@ -57,7 +57,7 @@ RSpec.describe User do
|
|||
it 'returns an array of recent users ordered by id' do
|
||||
user_1 = Fabricate(:user)
|
||||
user_2 = Fabricate(:user)
|
||||
expect(User.recent).to eq [user_2, user_1]
|
||||
expect(described_class.recent).to eq [user_2, user_1]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,7 +65,7 @@ RSpec.describe User do
|
|||
it 'returns an array of users who are confirmed' do
|
||||
user_1 = Fabricate(:user, confirmed_at: nil)
|
||||
user_2 = Fabricate(:user, confirmed_at: Time.zone.now)
|
||||
expect(User.confirmed).to contain_exactly(user_2)
|
||||
expect(described_class.confirmed).to contain_exactly(user_2)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ RSpec.describe User do
|
|||
specified = Fabricate(:user, current_sign_in_at: 15.days.ago)
|
||||
Fabricate(:user, current_sign_in_at: 6.days.ago)
|
||||
|
||||
expect(User.inactive).to contain_exactly(specified)
|
||||
expect(described_class.inactive).to contain_exactly(specified)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -83,7 +83,7 @@ RSpec.describe User do
|
|||
specified = Fabricate(:user, email: 'specified@spec')
|
||||
Fabricate(:user, email: 'unspecified@spec')
|
||||
|
||||
expect(User.matches_email('specified')).to contain_exactly(specified)
|
||||
expect(described_class.matches_email('specified')).to contain_exactly(specified)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,7 +96,7 @@ RSpec.describe User do
|
|||
Fabricate(:session_activation, user: user2, ip: '2160:8888::24', session_id: '3')
|
||||
Fabricate(:session_activation, user: user2, ip: '2160:8888::25', session_id: '4')
|
||||
|
||||
expect(User.matches_ip('2160:2160::/32')).to contain_exactly(user1)
|
||||
expect(described_class.matches_ip('2160:2160::/32')).to contain_exactly(user1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -113,19 +113,19 @@ RSpec.describe User do
|
|||
end
|
||||
|
||||
it 'allows a non-blacklisted user to be created' do
|
||||
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
|
||||
user = described_class.new(email: 'foo@example.com', account: account, password: password, agreement: true)
|
||||
|
||||
expect(user).to be_valid
|
||||
end
|
||||
|
||||
it 'does not allow a blacklisted user to be created' do
|
||||
user = User.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true)
|
||||
user = described_class.new(email: 'foo@mvrht.com', account: account, password: password, agreement: true)
|
||||
|
||||
expect(user).to_not be_valid
|
||||
end
|
||||
|
||||
it 'does not allow a subdomain blacklisted user to be created' do
|
||||
user = User.new(email: 'foo@mvrht.com.topdomain.tld', account: account, password: password, agreement: true)
|
||||
user = described_class.new(email: 'foo@mvrht.com.topdomain.tld', account: account, password: password, agreement: true)
|
||||
|
||||
expect(user).to_not be_valid
|
||||
end
|
||||
|
@ -349,17 +349,17 @@ RSpec.describe User do
|
|||
end
|
||||
|
||||
it 'does not allow a user to be created unless they are whitelisted' do
|
||||
user = User.new(email: 'foo@example.com', account: account, password: password, agreement: true)
|
||||
user = described_class.new(email: 'foo@example.com', account: account, password: password, agreement: true)
|
||||
expect(user).to_not be_valid
|
||||
end
|
||||
|
||||
it 'allows a user to be created if they are whitelisted' do
|
||||
user = User.new(email: 'foo@mastodon.space', account: account, password: password, agreement: true)
|
||||
user = described_class.new(email: 'foo@mastodon.space', account: account, password: password, agreement: true)
|
||||
expect(user).to be_valid
|
||||
end
|
||||
|
||||
it 'does not allow a user with a whitelisted top domain as subdomain in their email address to be created' do
|
||||
user = User.new(email: 'foo@mastodon.space.userdomain.com', account: account, password: password, agreement: true)
|
||||
user = described_class.new(email: 'foo@mastodon.space.userdomain.com', account: account, password: password, agreement: true)
|
||||
expect(user).to_not be_valid
|
||||
end
|
||||
|
||||
|
@ -373,7 +373,7 @@ RSpec.describe User do
|
|||
it 'does not allow a user to be created with a specific blacklisted subdomain even if the top domain is whitelisted' do
|
||||
Rails.configuration.x.email_domains_blacklist = 'blacklisted.mastodon.space'
|
||||
|
||||
user = User.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password)
|
||||
user = described_class.new(email: 'foo@blacklisted.mastodon.space', account: account, password: password)
|
||||
expect(user).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
@ -527,19 +527,19 @@ RSpec.describe User do
|
|||
end
|
||||
|
||||
describe '.those_who_can' do
|
||||
let!(:moderator_user) { Fabricate(:user, role: UserRole.find_by(name: 'Moderator')) }
|
||||
before { Fabricate(:user, role: UserRole.find_by(name: 'Moderator')) }
|
||||
|
||||
context 'when there are not any user roles' do
|
||||
before { UserRole.destroy_all }
|
||||
|
||||
it 'returns an empty list' do
|
||||
expect(User.those_who_can(:manage_blocks)).to eq([])
|
||||
expect(described_class.those_who_can(:manage_blocks)).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are not users with the needed role' do
|
||||
it 'returns an empty list' do
|
||||
expect(User.those_who_can(:manage_blocks)).to eq([])
|
||||
expect(described_class.those_who_can(:manage_blocks)).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -547,7 +547,7 @@ RSpec.describe User do
|
|||
let!(:admin_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
it 'returns the users with the role' do
|
||||
expect(User.those_who_can(:manage_blocks)).to eq([admin_user])
|
||||
expect(described_class.those_who_can(:manage_blocks)).to eq([admin_user])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue