diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-22 09:48:49 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-22 09:48:49 +0000 |
commit | 29b6d465a7491e9660c91e324df7a7b7d9d03868 (patch) | |
tree | 5abebae07d20871c8eacec306fc803be63c05d92 /spec/models | |
parent | ea9dda9541caffe59714ff427918f674bec0a6f2 (diff) | |
parent | e17020b9079d6e4f349a1a01e5d43393b6b49f18 (diff) | |
download | gitlab-ce-29b6d465a7491e9660c91e324df7a7b7d9d03868.tar.gz |
Merge branch 'rs-dev-issue-2355' into 'master'
MergeRequest#show performance improvements
This is a first pass on improving the performance of the `MergeRequests#show` page. Notable changes:
- The "Commits" tab is loaded lazily, so the initial page load should be much faster for MRs with many commits.
- Relative timestamps via `timeago` are only initialized once per load instead of `O(n^2)`. This greatly improves frontend rendering times for a large number of commits.
- Refactored `User.find_for_commit` to use a single ARel-generated SQL query instead of the old method which resulted in one query, and could result in up to three.
See merge request !838
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/user_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index fa7680fbbec..afdd9f71af2 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -364,6 +364,31 @@ describe User do end end + describe '.find_for_commit' do + it 'finds by primary email' do + user = create(:user, email: 'foo@example.com') + + expect(User.find_for_commit(user.email, '')).to eq user + end + + it 'finds by secondary email' do + email = create(:email, email: 'foo@example.com') + user = email.user + + expect(User.find_for_commit(email.email, '')).to eq user + end + + it 'finds by name' do + user = create(:user, name: 'Joey JoJo') + + expect(User.find_for_commit('', 'Joey JoJo')).to eq user + end + + it 'returns nil when nothing found' do + expect(User.find_for_commit('', '')).to be_nil + end + end + describe 'search' do let(:user1) { create(:user, username: 'James', email: 'james@testing.com') } let(:user2) { create(:user, username: 'jameson', email: 'jameson@example.com') } |