summaryrefslogtreecommitdiff
path: root/spec/finders
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2019-03-04 19:44:46 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2019-03-04 19:44:46 +0100
commit59db98a0cabea4421434655d7f7873110363d21a (patch)
treef3f72bca43724e230090aeae7aa0c15e56b707bf /spec/finders
parent5c80bbb33c12490bc5fa711642a40fc16bdb79a4 (diff)
parent025015048f7eaad29ee7816c6040fb3e0c06eb8d (diff)
downloadgitlab-ce-59db98a0cabea4421434655d7f7873110363d21a.tar.gz
Merge dev master into GitLab.com master
Diffstat (limited to 'spec/finders')
-rw-r--r--spec/finders/merge_requests_finder_spec.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb
index 107da08a0a9..79f854cdb96 100644
--- a/spec/finders/merge_requests_finder_spec.rb
+++ b/spec/finders/merge_requests_finder_spec.rb
@@ -31,7 +31,7 @@ describe MergeRequestsFinder do
p
end
end
- let(:project4) { create_project_without_n_plus_1(group: subgroup) }
+ let(:project4) { create_project_without_n_plus_1(:repository, group: subgroup) }
let(:project5) { create_project_without_n_plus_1(group: subgroup) }
let(:project6) { create_project_without_n_plus_1(group: subgroup) }
@@ -68,6 +68,15 @@ describe MergeRequestsFinder do
expect(merge_requests.size).to eq(2)
end
+ it 'filters by commit sha' do
+ merge_requests = described_class.new(
+ user,
+ commit_sha: merge_request5.merge_request_diff.last_commit_sha
+ ).execute
+
+ expect(merge_requests).to contain_exactly(merge_request5)
+ end
+
context 'filtering by group' do
it 'includes all merge requests when user has access' do
params = { group_id: group.id }
@@ -269,6 +278,21 @@ describe MergeRequestsFinder do
expect(merge_requests).to contain_exactly(old_merge_request, new_merge_request)
end
end
+
+ context 'when project restricts merge requests' do
+ let(:non_member) { create(:user) }
+ let(:project) { create(:project, :repository, :public, :merge_requests_private) }
+ let!(:merge_request) { create(:merge_request, source_project: project) }
+
+ it "returns nothing to to non members" do
+ merge_requests = described_class.new(
+ non_member,
+ project_id: project.id
+ ).execute
+
+ expect(merge_requests).to be_empty
+ end
+ end
end
describe '#row_count', :request_store do