SECURITY: Limit email invitations to topic

This commit is contained in:
Krzysztof Kotlarek
2022-08-10 11:33:16 +02:00
committed by Loïc Guitaut
parent a0537816fb
commit cc84ea2444
2 changed files with 20 additions and 0 deletions
+18
View File
@@ -176,6 +176,24 @@ RSpec.describe Invite do
expect(invite.invite_key).not_to eq(another_invite.invite_key)
end
context "when email is already invited 3 times" do
before do
RateLimiter.enable
3.times do
Invite.generate(user, email: "test@example.com")
end
end
after do
RateLimiter.clear_all!
end
it "raises an error" do
expect { Invite.generate(user, email: "test@example.com") }
.to raise_error(RateLimiter::LimitExceeded)
end
end
end
context 'when inviting to a topic' do