summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-12 03:10:47 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-12 03:10:47 +0000
commit6965dc27dc7338316932271394fd49efaef1ea46 (patch)
treee3a916797cf37f9d739a0773c92557fc685b103f /spec/models
parenta8f63f201972c5c1f66d7e3c4beb54803752a7ed (diff)
downloadgitlab-ce-6965dc27dc7338316932271394fd49efaef1ea46.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/packages/package_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/models/packages/package_spec.rb b/spec/models/packages/package_spec.rb
index 16764673474..56ff13762f9 100644
--- a/spec/models/packages/package_spec.rb
+++ b/spec/models/packages/package_spec.rb
@@ -599,6 +599,20 @@ RSpec.describe Packages::Package, type: :model do
end
end
+ describe '.order_by_package_file' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:package1) { create(:maven_package, project: project) }
+ let_it_be(:package2) { create(:maven_package, project: project) }
+
+ it 'orders packages their associated package_file\'s created_at date', :aggregate_failures do
+ expect(project.packages.order_by_package_file).to match_array([package1, package1, package1, package2, package2, package2])
+
+ create(:package_file, :xml, package: package1)
+
+ expect(project.packages.order_by_package_file).to match_array([package1, package1, package1, package2, package2, package2, package1])
+ end
+ end
+
describe '#versions' do
let_it_be(:project) { create(:project) }
let_it_be(:package) { create(:maven_package, project: project) }