diff options
author | Starfall <us@starfall.systems> | 2022-02-25 12:35:11 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-02-25 12:35:11 -0600 |
commit | ad1733ea294c6049336a9aeeb7ff96c8fea22cfa (patch) | |
tree | 306ff2d36a8bce82039890c4327f7d7bf37583dc /spec/models/user_spec.rb | |
parent | c5f289e8ef7ec1592d068ac797add7332343820d (diff) | |
parent | e48eaf64cc7cb0cfab388331c4823ee5fb580d59 (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r-- | spec/models/user_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 406438c22..1645ab59e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -89,6 +89,19 @@ RSpec.describe User, type: :model do expect(User.matches_email('specified')).to match_array([specified]) end end + + describe 'matches_ip' do + it 'returns a relation of users whose ip address is matching with the given CIDR' do + user1 = Fabricate(:user) + user2 = Fabricate(:user) + Fabricate(:session_activation, user: user1, ip: '2160:2160::22', session_id: '1') + Fabricate(:session_activation, user: user1, ip: '2160:2160::23', session_id: '2') + 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 match_array([user1]) + end + end end let(:account) { Fabricate(:account, username: 'alice') } |