|
|
@ -607,19 +607,19 @@ RSpec.describe Account, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is invalid if the username is longer then 30 characters' do |
|
|
|
it 'is invalid if the username is longer then 30 characters' do |
|
|
|
account = Fabricate.build(:account, username: Faker::Lorem.characters(31)) |
|
|
|
account = Fabricate.build(:account, username: Faker::Lorem.characters(number: 31)) |
|
|
|
account.valid? |
|
|
|
account.valid? |
|
|
|
expect(account).to model_have_error_on_field(:username) |
|
|
|
expect(account).to model_have_error_on_field(:username) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is invalid if the display name is longer than 30 characters' do |
|
|
|
it 'is invalid if the display name is longer than 30 characters' do |
|
|
|
account = Fabricate.build(:account, display_name: Faker::Lorem.characters(31)) |
|
|
|
account = Fabricate.build(:account, display_name: Faker::Lorem.characters(number: 31)) |
|
|
|
account.valid? |
|
|
|
account.valid? |
|
|
|
expect(account).to model_have_error_on_field(:display_name) |
|
|
|
expect(account).to model_have_error_on_field(:display_name) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is invalid if the note is longer than 500 characters' do |
|
|
|
it 'is invalid if the note is longer than 500 characters' do |
|
|
|
account = Fabricate.build(:account, note: Faker::Lorem.characters(501)) |
|
|
|
account = Fabricate.build(:account, note: Faker::Lorem.characters(number: 501)) |
|
|
|
account.valid? |
|
|
|
account.valid? |
|
|
|
expect(account).to model_have_error_on_field(:note) |
|
|
|
expect(account).to model_have_error_on_field(:note) |
|
|
|
end |
|
|
|
end |
|
|
@ -653,19 +653,19 @@ RSpec.describe Account, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is valid even if the username is longer then 30 characters' do |
|
|
|
it 'is valid even if the username is longer then 30 characters' do |
|
|
|
account = Fabricate.build(:account, domain: 'domain', username: Faker::Lorem.characters(31)) |
|
|
|
account = Fabricate.build(:account, domain: 'domain', username: Faker::Lorem.characters(number: 31)) |
|
|
|
account.valid? |
|
|
|
account.valid? |
|
|
|
expect(account).not_to model_have_error_on_field(:username) |
|
|
|
expect(account).not_to model_have_error_on_field(:username) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is valid even if the display name is longer than 30 characters' do |
|
|
|
it 'is valid even if the display name is longer than 30 characters' do |
|
|
|
account = Fabricate.build(:account, domain: 'domain', display_name: Faker::Lorem.characters(31)) |
|
|
|
account = Fabricate.build(:account, domain: 'domain', display_name: Faker::Lorem.characters(number: 31)) |
|
|
|
account.valid? |
|
|
|
account.valid? |
|
|
|
expect(account).not_to model_have_error_on_field(:display_name) |
|
|
|
expect(account).not_to model_have_error_on_field(:display_name) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is valid even if the note is longer than 500 characters' do |
|
|
|
it 'is valid even if the note is longer than 500 characters' do |
|
|
|
account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(501)) |
|
|
|
account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(number: 501)) |
|
|
|
account.valid? |
|
|
|
account.valid? |
|
|
|
expect(account).not_to model_have_error_on_field(:note) |
|
|
|
expect(account).not_to model_have_error_on_field(:note) |
|
|
|
end |
|
|
|
end |
|
|
@ -804,7 +804,7 @@ RSpec.describe Account, type: :model do |
|
|
|
context 'when is local' do |
|
|
|
context 'when is local' do |
|
|
|
# Test disabled because test environment omits autogenerating keys for performance |
|
|
|
# Test disabled because test environment omits autogenerating keys for performance |
|
|
|
xit 'generates keys' do |
|
|
|
xit 'generates keys' do |
|
|
|
account = Account.create!(domain: nil, username: Faker::Internet.user_name(nil, ['_'])) |
|
|
|
account = Account.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_'])) |
|
|
|
expect(account.keypair.private?).to eq true |
|
|
|
expect(account.keypair.private?).to eq true |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -812,12 +812,12 @@ RSpec.describe Account, type: :model do |
|
|
|
context 'when is remote' do |
|
|
|
context 'when is remote' do |
|
|
|
it 'does not generate keys' do |
|
|
|
it 'does not generate keys' do |
|
|
|
key = OpenSSL::PKey::RSA.new(1024).public_key |
|
|
|
key = OpenSSL::PKey::RSA.new(1024).public_key |
|
|
|
account = Account.create!(domain: 'remote', username: Faker::Internet.user_name(nil, ['_']), public_key: key.to_pem) |
|
|
|
account = Account.create!(domain: 'remote', username: Faker::Internet.user_name(separators: ['_']), public_key: key.to_pem) |
|
|
|
expect(account.keypair.params).to eq key.params |
|
|
|
expect(account.keypair.params).to eq key.params |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'normalizes domain' do |
|
|
|
it 'normalizes domain' do |
|
|
|
account = Account.create!(domain: 'にゃん', username: Faker::Internet.user_name(nil, ['_'])) |
|
|
|
account = Account.create!(domain: 'にゃん', username: Faker::Internet.user_name(separators: ['_'])) |
|
|
|
expect(account.domain).to eq 'xn--r9j5b5b' |
|
|
|
expect(account.domain).to eq 'xn--r9j5b5b' |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|