summaryrefslogtreecommitdiff
path: root/spec/models/concerns/issuable_spec.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-01-04 22:25:55 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-01-04 22:25:55 +0800
commit104bac3d215383b76b058e8f61b90fdfac936341 (patch)
tree5b0737050878d35e0963272810637e83350ce696 /spec/models/concerns/issuable_spec.rb
parent99b556976370bfe0c052d15b6a8f0642256173fd (diff)
parent034d2e4e749ee09649062d3fb1d26c53021ab4d8 (diff)
downloadgitlab-ce-104bac3d215383b76b058e8f61b90fdfac936341.tar.gz
Merge branch 'master' into fix-git-hooks-when-creating-file
* master: (1031 commits) Add changelog entry for renaming API param [ci skip] Add missing milestone parameter Refactor issues filter in API Fix project hooks params Gitlab::LDAP::Person uses LDAP attributes configuration Don't delete files from spec/fixtures Copy, don't move uploaded avatar files Minor improvements to changelog docs Rename logo, apply for Slack too Fix Gemfile.lock for the octokit update Fix cross-project references copy to include the project reference Add logo in public files Use stable icon for Mattermost integration rewrite the item.respond_to?(:x?) && item.x? to item.try(:x?) API: extern_uid is a string Increases pipeline graph drowdown width in order to prevent strange position on chrome on ubuntu Removed bottom padding from merge manually from CLI because of repositioning award emoji's Make haml_lint happy Improve spec Add feature tests for Cycle Analytics ...
Diffstat (limited to 'spec/models/concerns/issuable_spec.rb')
-rw-r--r--spec/models/concerns/issuable_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 4fa06a8c60a..1078c959419 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -44,6 +44,45 @@ describe Issue, "Issuable" do
it { expect(described_class).to respond_to(:assigned) }
end
+ describe "before_save" do
+ describe "#update_cache_counts" do
+ context "when previous assignee exists" do
+ before do
+ assignee = create(:user)
+ issue.project.team << [assignee, :developer]
+ issue.update(assignee: assignee)
+ end
+
+ it "updates cache counts for new assignee" do
+ user = create(:user)
+
+ expect(user).to receive(:update_cache_counts)
+
+ issue.update(assignee: user)
+ end
+
+ it "updates cache counts for previous assignee" do
+ old_assignee = issue.assignee
+ allow(User).to receive(:find_by_id).with(old_assignee.id).and_return(old_assignee)
+
+ expect(old_assignee).to receive(:update_cache_counts)
+
+ issue.update(assignee: nil)
+ end
+ end
+
+ context "when previous assignee does not exist" do
+ before{ issue.update(assignee: nil) }
+
+ it "updates cache count for the new assignee" do
+ expect_any_instance_of(User).to receive(:update_cache_counts)
+
+ issue.update(assignee: user)
+ end
+ end
+ end
+ end
+
describe ".search" do
let!(:searchable_issue) { create(:issue, title: "Searchable issue") }