Merge tag 'v2.9.3' into hometown-2.9.3
This commit is contained in:
@ -3,27 +3,33 @@ require 'rails_helper'
|
||||
RSpec.describe Invite, type: :model do
|
||||
describe '#valid_for_use?' do
|
||||
it 'returns true when there are no limitations' do
|
||||
invite = Invite.new(max_uses: nil, expires_at: nil)
|
||||
invite = Fabricate(:invite, max_uses: nil, expires_at: nil)
|
||||
expect(invite.valid_for_use?).to be true
|
||||
end
|
||||
|
||||
it 'returns true when not expired' do
|
||||
invite = Invite.new(max_uses: nil, expires_at: 1.hour.from_now)
|
||||
invite = Fabricate(:invite, max_uses: nil, expires_at: 1.hour.from_now)
|
||||
expect(invite.valid_for_use?).to be true
|
||||
end
|
||||
|
||||
it 'returns false when expired' do
|
||||
invite = Invite.new(max_uses: nil, expires_at: 1.hour.ago)
|
||||
invite = Fabricate(:invite, max_uses: nil, expires_at: 1.hour.ago)
|
||||
expect(invite.valid_for_use?).to be false
|
||||
end
|
||||
|
||||
it 'returns true when uses still available' do
|
||||
invite = Invite.new(max_uses: 250, uses: 249, expires_at: nil)
|
||||
invite = Fabricate(:invite, max_uses: 250, uses: 249, expires_at: nil)
|
||||
expect(invite.valid_for_use?).to be true
|
||||
end
|
||||
|
||||
it 'returns false when maximum uses reached' do
|
||||
invite = Invite.new(max_uses: 250, uses: 250, expires_at: nil)
|
||||
invite = Fabricate(:invite, max_uses: 250, uses: 250, expires_at: nil)
|
||||
expect(invite.valid_for_use?).to be false
|
||||
end
|
||||
|
||||
it 'returns false when invite creator has been disabled' do
|
||||
invite = Fabricate(:invite, max_uses: nil, expires_at: nil)
|
||||
SuspendAccountService.new.call(invite.user.account)
|
||||
expect(invite.valid_for_use?).to be false
|
||||
end
|
||||
end
|
||||
|
@ -31,7 +31,47 @@ RSpec.describe Tag, type: :model do
|
||||
end
|
||||
|
||||
it 'matches #aesthetic' do
|
||||
expect(subject.match('this is #aesthetic')).to_not be_nil
|
||||
expect(subject.match('this is #aesthetic').to_s).to eq ' #aesthetic'
|
||||
end
|
||||
|
||||
it 'matches digits at the start' do
|
||||
expect(subject.match('hello #3d').to_s).to eq ' #3d'
|
||||
end
|
||||
|
||||
it 'matches digits in the middle' do
|
||||
expect(subject.match('hello #l33ts35k').to_s).to eq ' #l33ts35k'
|
||||
end
|
||||
|
||||
it 'matches digits at the end' do
|
||||
expect(subject.match('hello #world2016').to_s).to eq ' #world2016'
|
||||
end
|
||||
|
||||
it 'matches underscores at the beginning' do
|
||||
expect(subject.match('hello #_test').to_s).to eq ' #_test'
|
||||
end
|
||||
|
||||
it 'matches underscores at the end' do
|
||||
expect(subject.match('hello #test_').to_s).to eq ' #test_'
|
||||
end
|
||||
|
||||
it 'matches underscores in the middle' do
|
||||
expect(subject.match('hello #one_two_three').to_s).to eq ' #one_two_three'
|
||||
end
|
||||
|
||||
it 'matches middle dots' do
|
||||
expect(subject.match('hello #one·two·three').to_s).to eq ' #one·two·three'
|
||||
end
|
||||
|
||||
it 'does not match middle dots at the start' do
|
||||
expect(subject.match('hello #·one·two·three')).to be_nil
|
||||
end
|
||||
|
||||
it 'does not match middle dots at the end' do
|
||||
expect(subject.match('hello #one·two·three·').to_s).to eq ' #one·two·three'
|
||||
end
|
||||
|
||||
it 'does not match purely-numeric hashtags' do
|
||||
expect(subject.match('hello #0123456')).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user