diff options
author | Robert Speicher <robert@gitlab.com> | 2017-06-29 02:27:31 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-06-29 02:27:31 +0300 |
commit | b07c00032b038f40796a28e34b6dd4c622bad012 (patch) | |
tree | 303c3d4f6c129110ca7ff849d5f8e161eedbf084 /spec/models | |
parent | 2b97d76d0b08a778710410df910a7601f6b8e9e7 (diff) | |
parent | b9ec3f23dd749e74533900d16568b55201a37e6e (diff) |
Merge branch 'dm-drop-default-scope-on-sortable-finders' into 'master'
Drop default ORDER scope when calling a find method on a Sortable model
Closes #23079 and #34412
See merge request !12499
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/sortable_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/concerns/sortable_spec.rb b/spec/models/concerns/sortable_spec.rb new file mode 100644 index 00000000000..d1e17c4f684 --- /dev/null +++ b/spec/models/concerns/sortable_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Sortable do + let(:relation) { Issue.all } + + describe '#where' do + it 'orders by id, descending' do + order_node = relation.where(iid: 1).order_values.first + expect(order_node).to be_a(Arel::Nodes::Descending) + expect(order_node.expr.name).to eq(:id) + end + end + + describe '#find_by' do + it 'does not order' do + expect(relation).to receive(:unscope).with(:order).and_call_original + + relation.find_by(iid: 1) + end + end +end |