DEV: Remove mocks from specs.
This commit is contained in:
parent
a2044c4528
commit
bdb8e9efdb
|
@ -11,8 +11,9 @@ describe Jobs::SuspiciousLogin do
|
|||
end
|
||||
|
||||
it "will not send an email on first login" do
|
||||
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :suspicious_login)).never
|
||||
expect do
|
||||
described_class.new.execute(user_id: user.id, client_ip: "1.1.1.1")
|
||||
end.to_not change { Jobs::CriticalUserEmail.jobs.size }
|
||||
|
||||
expect(UserAuthTokenLog.where(action: "suspicious").count).to eq(0)
|
||||
end
|
||||
|
@ -20,9 +21,10 @@ describe Jobs::SuspiciousLogin do
|
|||
it "will not send an email when user log in from a known location" do
|
||||
UserAuthTokenLog.create!(action: "generate", user_id: user.id, client_ip: "1.1.1.1")
|
||||
|
||||
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :suspicious_login)).never
|
||||
expect do
|
||||
described_class.new.execute(user_id: user.id, client_ip: "1.1.1.1")
|
||||
described_class.new.execute(user_id: user.id, client_ip: "1.1.1.2")
|
||||
end.to_not change { Jobs::CriticalUserEmail.jobs.size }
|
||||
|
||||
expect(UserAuthTokenLog.where(action: "suspicious").count).to eq(0)
|
||||
end
|
||||
|
@ -30,10 +32,12 @@ describe Jobs::SuspiciousLogin do
|
|||
it "will send an email when user logs in from a new location" do
|
||||
UserAuthTokenLog.create!(action: "generate", user_id: user.id, client_ip: "1.1.1.1")
|
||||
|
||||
Jobs.expects(:enqueue).with(:critical_user_email, has_entries(type: :suspicious_login))
|
||||
described_class.new.execute(user_id: user.id, client_ip: "1.1.2.1")
|
||||
|
||||
expect(UserAuthTokenLog.where(action: "suspicious").count).to eq(1)
|
||||
|
||||
expect(Jobs::CriticalUserEmail.jobs.first["args"].first["type"])
|
||||
.to eq('suspicious_login')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue