summaryrefslogtreecommitdiff
path: root/spec/models/issue_assignee_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/issue_assignee_spec.rb')
-rw-r--r--spec/models/issue_assignee_spec.rb35
1 files changed, 34 insertions, 1 deletions
diff --git a/spec/models/issue_assignee_spec.rb b/spec/models/issue_assignee_spec.rb
index 2d59ba15101..df8e91cd133 100644
--- a/spec/models/issue_assignee_spec.rb
+++ b/spec/models/issue_assignee_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe IssueAssignee do
+RSpec.describe IssueAssignee do
let(:issue) { create(:issue) }
subject { issue.issue_assignees.build(assignee: create(:user)) }
@@ -15,4 +15,37 @@ describe IssueAssignee do
describe 'validations' do
it { is_expected.to validate_uniqueness_of(:assignee).scoped_to(:issue_id) }
end
+
+ describe 'scopes' do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:project_issue) { create(:issue, project: project, assignee_ids: [user.id]) }
+
+ before do
+ issue.update!(assignee_ids: [user.id])
+ end
+
+ context 'in_projects' do
+ it 'returns issue assignees for given project' do
+ expect(IssueAssignee.count).to eq 2
+
+ assignees = IssueAssignee.in_projects([project])
+
+ expect(assignees.count).to eq 1
+ expect(assignees.first.user_id).to eq project_issue.issue_assignees.first.user_id
+ expect(assignees.first.issue_id).to eq project_issue.issue_assignees.first.issue_id
+ end
+ end
+
+ context 'on_issues' do
+ it 'returns issue assignees for given issues' do
+ expect(IssueAssignee.count).to eq 2
+
+ assignees = IssueAssignee.on_issues([project_issue])
+
+ expect(assignees.count).to eq 1
+ expect(assignees.first.issue_id).to eq project_issue.issue_assignees.first.issue_id
+ end
+ end
+ end
end