Extract EE specific files/lines for Plan spec/finders
We have the following files containing EE specific code. We should move them to ee/
spec/finders/issues_finder_spec.rb
diff --git a/spec/finders/issues_finder_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/finders/issues_finder_spec.rb
index fe8000e419b..47d51af3898 100644
--- a/spec/finders/issues_finder_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/finders/issues_finder_spec.rb
@@ -48,6 +48,22 @@ describe IssuesFinder do
expect(issues).to contain_exactly(issue1, issue2, issue3, issue4)
end
+ context 'sort by issues with no weight' do
+ let(:params) { { weight: Issue::WEIGHT_NONE } }
+
+ it 'returns all issues' do
+ expect(issues).to contain_exactly(issue1, issue2, issue3, issue4)
+ end
+ end
+
+ context 'sort by issues with any weight' do
+ let(:params) { { weight: Issue::WEIGHT_ANY } }
+
+ it 'returns all issues' do
+ expect(issues).to be_empty
+ end
+ end
+
context 'filtering by assignee ID' do
let(:params) { { assignee_id: user.id } }
@@ -56,6 +72,36 @@ describe IssuesFinder do
end
end
+ context 'filtering by assignee IDs' do
+ set(:user3) { create(:user) }
+ let(:params) { { assignee_ids: [user2.id, user3.id] } }
+
+ before do
+ project2.add_developer(user3)
+
+ issue3.assignees = [user2, user3]
+ end
+
+ it 'returns issues assigned to those users' do
+ expect(issues).to contain_exactly(issue3)
+ end
+ end
+
+ context 'filtering by assignee usernames' do
+ set(:user3) { create(:user) }
+ let(:params) { { assignee_username: [user2.username, user3.username] } }
+
+ before do
+ project2.add_developer(user3)
+
+ issue3.assignees = [user2, user3]
+ end
+
+ it 'returns issues assigned to those users' do
+ expect(issues).to contain_exactly(issue3)
+ end
+ end
+
context 'filtering by no assignee' do
let(:params) { { assignee_id: 'None' } }
@@ -490,6 +536,32 @@ describe IssuesFinder do
end
end
+ context 'filtering by confidential' do
+ set(:confidential_issue) { create(:issue, project: project1, confidential: true) }
+
+ context 'no filtering' do
+ it 'returns all issues' do
+ expect(issues).to contain_exactly(issue1, issue2, issue3, issue4, confidential_issue)
+ end
+ end
+
+ context 'user filters confidential issues' do
+ let(:params) { { confidential: true } }
+
+ it 'returns only confdential issues' do
+ expect(issues).to contain_exactly(confidential_issue)
+ end
+ end
+
+ context 'user filters only public issues' do
+ let(:params) { { confidential: false } }
+
+ it 'returns only confdential issues' do
+ expect(issues).to contain_exactly(issue1, issue2, issue3, issue4)
+ end
+ end
+ end
+
context 'when the user is unauthorized' do
let(:search_user) { nil }
@@ -556,7 +628,7 @@ describe IssuesFinder do
it 'returns the number of rows for the default state' do
finder = described_class.new(user)
- expect(finder.row_count).to eq(4)
+ expect(finder.row_count).to eq(5)
end
it 'returns the number of rows for a given state' do
@@ -614,6 +686,26 @@ describe IssuesFinder do
expect(subject).to include(public_issue, confidential_issue)
end
end
+
+ context 'for an auditor' do
+ let(:auditor_user) { create(:user, :auditor) }
+
+ subject { described_class.new(auditor_user, params).with_confidentiality_access_check }
+
+ it 'returns all issues' do
+ expect(subject).to include(public_issue, confidential_issue)
+ end
+ end
+
+ context 'for an admin' do
+ let(:admin_user) { create(:user, :admin) }
+
+ subject { described_class.new(admin_user, params).with_confidentiality_access_check }
+
+ it 'returns all issues' do
+ expect(subject).to include(public_issue, confidential_issue)
+ end
+ end
end
context 'when searching within a specific project' do
@@ -681,6 +773,38 @@ describe IssuesFinder do
subject
end
end
+
+ context 'for an auditor' do
+ let(:auditor_user) { create(:user, :auditor) }
+
+ subject { described_class.new(auditor_user, params).with_confidentiality_access_check }
+
+ it 'returns all issues' do
+ expect(subject).to include(public_issue, confidential_issue)
+ end
+
+ it 'does not filter by confidentiality' do
+ expect(Issue).not_to receive(:where).with(a_string_matching('confidential'), anything)
+
+ subject
+ end
+ end
+
+ context 'for an admin' do
+ let(:admin_user) { create(:user, :auditor) }
+
+ subject { described_class.new(admin_user, params).with_confidentiality_access_check }
+
+ it 'returns all issues' do
+ expect(subject).to include(public_issue, confidential_issue)
+ end
+
+ it 'does not filter by confidentiality' do
+ expect(Issue).not_to receive(:where).with(a_string_matching('confidential'), anything)
+
+ subject
+ end
+ end
end
end
They're all EE only tests or so. (Some we could probably just move to CE)