Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-06-17 03:18:10 +0300
committerRobert Speicher <robert@gitlab.com>2016-06-17 03:18:10 +0300
commit6300936b679a182d79f6de917d1fdfe9ee57cbc9 (patch)
treed144a7006efac7e153bf730bffb4d5bbf49d8e3f /spec/models
parent88c7b7ae961dc37d43ca29263d242241ce77efdb (diff)
parent425987861530c9c0fb7fe618d7f4bab017a80253 (diff)
Merge branch 'fix-project-find-with-namespace-order' into 'master'
Fixed ordering in Project.find_with_namespace This MR fixes the ordering of `Project.find_with_namespace` to ensure that it returns rows that match literally first. Closes #18603 See merge request !4682
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/project_spec.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index fedab1f913b..53c8408633c 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -220,7 +220,7 @@ describe Project, models: true do
end
end
- describe :find_with_namespace do
+ describe '.find_with_namespace' do
context 'with namespace' do
before do
@group = create :group, name: 'gitlab'
@@ -231,6 +231,22 @@ describe Project, models: true do
it { expect(Project.find_with_namespace('GitLab/GitlabHQ')).to eq(@project) }
it { expect(Project.find_with_namespace('gitlab-ci')).to be_nil }
end
+
+ context 'when multiple projects using a similar name exist' do
+ let(:group) { create(:group, name: 'gitlab') }
+
+ let!(:project1) do
+ create(:empty_project, name: 'gitlab1', path: 'gitlab', namespace: group)
+ end
+
+ let!(:project2) do
+ create(:empty_project, name: 'gitlab2', path: 'GITLAB', namespace: group)
+ end
+
+ it 'returns the row where the path matches literally' do
+ expect(Project.find_with_namespace('gitlab/GITLAB')).to eq(project2)
+ end
+ end
end
describe :to_param do