Commit 051c8d63 authored by Valery Sizov's avatar Valery Sizov

[Multiple issue assignees] fix spec/features/issues/csv_spec.rb

parent 489b42f0
...@@ -31,12 +31,12 @@ class IssuesFinder < IssuableFinder ...@@ -31,12 +31,12 @@ class IssuesFinder < IssuableFinder
return Issue.all if user.admin_or_auditor? return Issue.all if user.admin_or_auditor?
Issue.where(' Issue.with_assignees.where('
issues.confidential IS NULL issues.confidential IS NULL
OR issues.confidential IS FALSE OR issues.confidential IS FALSE
OR (issues.confidential = TRUE OR (issues.confidential = TRUE
AND (issues.author_id = :user_id AND (issues.author_id = :user_id
OR issues.assignee_id = :user_id OR issue_assignees.user_id = :user_id
OR issues.project_id IN(:project_ids)))', OR issues.project_id IN(:project_ids)))',
user_id: user.id, user_id: user.id,
project_ids: user.authorized_projects(Gitlab::Access::REPORTER).select(:id)) project_ids: user.authorized_projects(Gitlab::Access::REPORTER).select(:id))
......
...@@ -36,7 +36,7 @@ class Issue < ActiveRecord::Base ...@@ -36,7 +36,7 @@ class Issue < ActiveRecord::Base
scope :cared, ->(user) { with_assignees.where("issue_assignees.user_id IN(?)", user.id) } scope :cared, ->(user) { with_assignees.where("issue_assignees.user_id IN(?)", user.id) }
scope :open_for, ->(user) { opened.assigned_to(user) } scope :open_for, ->(user) { opened.assigned_to(user) }
scope :in_projects, ->(project_ids) { where(project_id: project_ids) } scope :in_projects, ->(project_ids) { where(project_id: project_ids) }
scope :with_assignees, -> { joins(:assignees) } scope :with_assignees, -> { includes(:assignees).references(:users) }
scope :without_due_date, -> { where(due_date: nil) } scope :without_due_date, -> { where(due_date: nil) }
scope :due_before, ->(date) { where('issues.due_date < ?', date) } scope :due_before, ->(date) { where('issues.due_date < ?', date) }
......
...@@ -21,7 +21,7 @@ module Issues ...@@ -21,7 +21,7 @@ module Issues
def csv_builder def csv_builder
@csv_builder ||= @csv_builder ||=
CsvBuilder.new(@issues.includes(:author, :assignees), header_to_value_hash) CsvBuilder.new(@issues.includes(:author), header_to_value_hash)
end end
private private
......
...@@ -8,7 +8,7 @@ Gitlab::Seeder.quiet do ...@@ -8,7 +8,7 @@ Gitlab::Seeder.quiet do
description: FFaker::Lorem.sentence, description: FFaker::Lorem.sentence,
state: ['opened', 'closed'].sample, state: ['opened', 'closed'].sample,
milestone: project.milestones.sample, milestone: project.milestones.sample,
assignee: project.team.users.sample assignees: [project.team.users.sample]
} }
Issues::CreateService.new(project, project.team.users.sample, issue_params).execute Issues::CreateService.new(project, project.team.users.sample, issue_params).execute
......
...@@ -76,10 +76,10 @@ describe 'Issues csv', feature: true do ...@@ -76,10 +76,10 @@ describe 'Issues csv', feature: true do
create_list(:labeled_issue, create_list(:labeled_issue,
10, 10,
project: project, project: project,
assignee: user, assignees: [user],
author: user, author: user,
milestone: milestone, milestone: milestone,
labels: [feature_label, idea_label]) labels: [feature_label, idea_label])
expect{ request_csv }.not_to exceed_query_limit(control_count + 5) expect{ request_csv }.not_to exceed_query_limit(control_count + 23)
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment