diff options
author | Josh Frye <joshfng@gmail.com> | 2016-06-02 09:25:40 -0400 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-06-02 09:25:40 -0400 |
commit | 0f3df62e1a42982ffb635dc5a9b201ed2520b0f4 (patch) | |
tree | 73c12eeecdef2a5abd214a838ad31d1008833353 | |
parent | 8835b7889a6265aba3c6d7ee241abf80a1cf07f3 (diff) | |
download | gitlab-ce-0f3df62e1a42982ffb635dc5a9b201ed2520b0f4.tar.gz |
Update specs. Add CHANGELOG entryissue-18036
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 2 | ||||
-rw-r--r-- | spec/features/issues_spec.rb | 15 | ||||
-rw-r--r-- | spec/models/issue_spec.rb | 17 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 17 |
5 files changed, 36 insertions, 16 deletions
diff --git a/CHANGELOG b/CHANGELOG index 6f91dfcfb68..de77625dce3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,7 @@ v 8.9.0 (unreleased) - Measure queue duration between gitlab-workhorse and Rails - Make authentication service for Container Registry to be compatible with < Docker 1.11 - Add Application Setting to configure Container Registry token expire delay (default 5min) + - Cache assigned issue and merge request counts in sidebar nav v 8.8.3 - Fix incorrect links on pipeline page when merge request created from fork diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 46cde460952..50f5b749e38 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -74,7 +74,7 @@ module Issuable def update_assignee_cache_counts # make sure we flush the cache for both the old *and* new assignee User.find(assignee_id_was).update_cache_counts if assignee_id_was - assignee.update_cache_counts if assignee_id + assignee.update_cache_counts if assignee end end diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index fa0d8e1a0cd..9271964166a 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -62,21 +62,6 @@ describe 'Issues', feature: true do expect(issue.reload.assignee).to be_nil end - - it 'updates assigned cache count on change', js: true do - visit edit_namespace_project_issue_path(project.namespace, project, issue) - - expect(page).to have_content "Assignee #{@user.name}" - expect(@user.assigned_open_issues_count).to eq @user.assigned_issues.opened.count - - first('#s2id_issue_assignee_id').click - sleep 2 # wait for ajax stuff to complete - first('.user-result').click - - click_button 'Save changes' - - expect(@user.assigned_open_issues_count).to eq @user.assigned_issues.opened.count - end end describe 'due date', js: true do diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 87b3d8d650a..b87d68283e6 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -269,4 +269,21 @@ describe Issue, models: true do end end end + + describe 'cached counts' do + it 'updates when assignees change' do + user1 = create(:user) + user2 = create(:user) + issue = create(:issue, assignee: user1) + + expect(user1.assigned_open_issues_count).to eq(1) + expect(user2.assigned_open_issues_count).to eq(0) + + issue.assignee = user2 + issue.save + + expect(user1.assigned_open_issues_count).to eq(0) + expect(user2.assigned_open_issues_count).to eq(1) + end + end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 118e1e22a78..a4c55cc2fd0 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -438,4 +438,21 @@ describe MergeRequest, models: true do expect(mr.participants).to include(note1.author, note2.author) end end + + describe 'cached counts' do + it 'updates when assignees change' do + user1 = create(:user) + user2 = create(:user) + mr = create(:merge_request, assignee: user1) + + expect(user1.assigned_open_merge_request_count).to eq(1) + expect(user2.assigned_open_merge_request_count).to eq(0) + + mr.assignee = user2 + mr.save + + expect(user1.assigned_open_merge_request_count).to eq(0) + expect(user2.assigned_open_merge_request_count).to eq(1) + end + end end |