2015-10-02 11:00:23 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe User, benchmark: true do
|
|
|
|
describe '.by_login' do
|
|
|
|
before do
|
|
|
|
%w{Alice Bob Eve}.each do |name|
|
|
|
|
create(:user,
|
|
|
|
email: "#{name}@gitlab.com",
|
|
|
|
username: name,
|
|
|
|
name: name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:iterations) { 1000 }
|
|
|
|
|
|
|
|
describe 'using a capitalized username' do
|
2015-10-05 04:51:24 -04:00
|
|
|
benchmark_subject { User.by_login('Alice') }
|
2015-10-02 11:00:23 -04:00
|
|
|
|
|
|
|
it { is_expected.to iterate_per_second(iterations) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'using a lowercase username' do
|
2015-10-05 04:51:24 -04:00
|
|
|
benchmark_subject { User.by_login('alice') }
|
2015-10-02 11:00:23 -04:00
|
|
|
|
|
|
|
it { is_expected.to iterate_per_second(iterations) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'using a capitalized Email address' do
|
2015-10-05 04:51:24 -04:00
|
|
|
benchmark_subject { User.by_login('Alice@gitlab.com') }
|
2015-10-02 11:00:23 -04:00
|
|
|
|
|
|
|
it { is_expected.to iterate_per_second(iterations) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'using a lowercase Email address' do
|
2015-10-05 04:51:24 -04:00
|
|
|
benchmark_subject { User.by_login('alice@gitlab.com') }
|
2015-10-02 11:00:23 -04:00
|
|
|
|
|
|
|
it { is_expected.to iterate_per_second(iterations) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|