Skip to content

Commit

Permalink
Add test for user matching ip (#17572)
Browse files Browse the repository at this point in the history
  • Loading branch information
tribela authored Feb 16, 2022
1 parent 436d124 commit 2fd2666
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@
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') }
Expand Down

0 comments on commit 2fd2666

Please sign in to comment.