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:
Diffstat (limited to 'spec/models/concerns/ci/has_variable_spec.rb')
-rw-r--r--spec/models/concerns/ci/has_variable_spec.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/spec/models/concerns/ci/has_variable_spec.rb b/spec/models/concerns/ci/has_variable_spec.rb
index 861d8f3b974..d7d0cabd4ae 100644
--- a/spec/models/concerns/ci/has_variable_spec.rb
+++ b/spec/models/concerns/ci/has_variable_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Ci::HasVariable do
+RSpec.describe Ci::HasVariable, feature_category: :continuous_integration do
subject { build(:ci_variable) }
it { is_expected.to validate_presence_of(:key) }
@@ -113,4 +113,36 @@ RSpec.describe Ci::HasVariable do
end
end
end
+
+ describe '.order_by' do
+ let_it_be(:relation) { Ci::Variable.all }
+
+ it 'supports ordering by key ascending' do
+ expect(relation).to receive(:reorder).with({ key: :asc })
+
+ relation.order_by('key_asc')
+ end
+
+ it 'supports ordering by key descending' do
+ expect(relation).to receive(:reorder).with({ key: :desc })
+
+ relation.order_by('key_desc')
+ end
+
+ context 'when order method is unknown' do
+ it 'does not call reorder' do
+ expect(relation).not_to receive(:reorder)
+
+ relation.order_by('unknown')
+ end
+ end
+
+ context 'when order method is nil' do
+ it 'does not call reorder' do
+ expect(relation).not_to receive(:reorder)
+
+ relation.order_by(nil)
+ end
+ end
+ end
end