Fix bugs in profiling scripts leading to incorrect results.

This commit is contained in:
Guo Xiang Tan 2017-09-13 15:33:59 +08:00
parent e70428ac8c
commit 26c6447161
3 changed files with 12 additions and 8 deletions

View File

@ -693,14 +693,12 @@ class User < ActiveRecord::Base
if email_token = self.email_tokens.active.where(email: self.email).first
EmailToken.confirm(email_token.token)
else
self.active = true
save
self.update!(active: true)
end
end
def deactivate
self.active = false
save
self.update!(active: false)
end
def change_trust_level!(level, opts = nil)

View File

@ -188,7 +188,7 @@ begin
append = "?api_key=#{api_key}&api_username=admin1"
# asset precompilation is a dog, wget to force it
run "wget http://127.0.0.1:#{@port}/ -O /dev/null"
run "wget http://127.0.0.1:#{@port}/ -o /dev/null -O /dev/null"
tests = [
["categories", "/categories"],
@ -197,7 +197,13 @@ begin
# ["user", "/u/admin1/activity"],
]
tests = tests.map { |k, url| ["#{k}_admin", "#{url}#{append}"] } + tests
tests.concat(tests.map { |k, url| ["#{k}_admin", "#{url}#{append}"] })
tests.each do |_, path|
if `curl -s -I "http://127.0.0.1:#{@port}#{path}"` !~ /200 OK/
raise "#{path} returned non 200 response code"
end
end
# NOTE: we run the most expensive page first in the bench

View File

@ -46,10 +46,10 @@ def create_admin(seq)
admin.email = "admin@localhost#{seq}.fake"
admin.username = "admin#{seq}"
admin.password = "password"
admin.save
admin.save!
admin.grant_admin!
admin.change_trust_level!(TrustLevel[4])
admin.email_tokens.update_all(confirmed: true)
admin.activate
}
end