diff options
author | Sean McGivern <sean@gitlab.com> | 2019-05-11 15:06:44 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-05-14 19:01:48 +0300 |
commit | 79dd92c8189600f24a29fe2da8d391cdb021f8fd (patch) | |
tree | fff4f45718495005bcacc82156bf7fc05943a568 /spec/models/application_record_spec.rb | |
parent | 513fa60310e5b5d8dbdf81daf0c6ae7e506b4d8b (diff) |
Optimise upload path calls
String#underscore isn't particularly slow, but it's possible for us to
call it many times in a users autocomplete request, with mostly-static
values ('User', 'Group', etc.). We can memoise this and save a
surprising amount of time (around 10% of the total request time in some
cases).
Diffstat (limited to 'spec/models/application_record_spec.rb')
-rw-r--r-- | spec/models/application_record_spec.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/models/application_record_spec.rb b/spec/models/application_record_spec.rb index cc90a998d3f..74573d0941c 100644 --- a/spec/models/application_record_spec.rb +++ b/spec/models/application_record_spec.rb @@ -52,4 +52,10 @@ describe ApplicationRecord do expect { Suggestion.find_or_create_by!(note: nil) }.to raise_error(ActiveRecord::RecordInvalid) end end + + describe '.underscore' do + it 'returns the underscored value of the class as a string' do + expect(MergeRequest.underscore).to eq('merge_request') + end + end end |