-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathperf.rake
More file actions
42 lines (37 loc) · 966 Bytes
/
perf.rake
File metadata and controls
42 lines (37 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class MyCustomAuth < DerailedBenchmarks::AuthHelper
attr_writer :user
# Include devise test helpers and turn on test mode
# We need to do this on the class level
def setup
# self.class.instance_eval do
require 'devise'
require 'warden'
extend ::Warden::Test::Helpers
extend ::Devise::TestHelpers
Warden.test_mode!
# end
end
def user
if @user
@user = @user.call if @user.is_a?(Proc)
@user
else
@group = Group.create label: 'Dummy', group_type: 'Centre', study: '*'
password = SecureRandom.hex
@user = User.first_or_create!(
email: "#{SecureRandom.hex}@example.com",
password: password,
password_confirmation: password,
group_id: @group.id
)
@user.admin!
@user
end
end
# Logs the user in, then call the parent app
def call(env)
login_as(user)
app.call(env)
end
end
DerailedBenchmarks.auth = MyCustomAuth.new