diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 15:08:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 15:08:44 +0000 |
commit | 120f4aaedc8fe830a3f572491d240d8ee6addefb (patch) | |
tree | a2138baa55dfa67d292fb1a83ce686ee7f5d10a5 /spec/models/concerns | |
parent | 729e3765d5feb762df1ccfbc228a8dd4662aa3f9 (diff) | |
download | gitlab-ce-120f4aaedc8fe830a3f572491d240d8ee6addefb.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/concerns')
-rw-r--r-- | spec/models/concerns/optionally_search_spec.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/spec/models/concerns/optionally_search_spec.rb b/spec/models/concerns/optionally_search_spec.rb index 71cf536db89..e1eb4cf8cd2 100644 --- a/spec/models/concerns/optionally_search_spec.rb +++ b/spec/models/concerns/optionally_search_spec.rb @@ -3,28 +3,39 @@ require 'spec_helper' describe OptionallySearch do - let(:model) do - Class.new(ActiveRecord::Base) do - self.table_name = 'users' - - include OptionallySearch + describe '.search' do + let(:model) do + Class.new do + include OptionallySearch + end end - end - describe '.search' do it 'raises NotImplementedError' do expect { model.search('foo') }.to raise_error(NotImplementedError) end end describe '.optionally_search' do + let(:model) do + Class.new(ActiveRecord::Base) do + self.table_name = 'users' + + include OptionallySearch + + def self.search(query, **options) + [query, options] + end + end + end + context 'when a query is given' do it 'delegates to the search method' do expect(model) .to receive(:search) .with('foo', {}) + .and_call_original - model.optionally_search('foo') + expect(model.optionally_search('foo')).to eq(['foo', {}]) end end @@ -33,8 +44,9 @@ describe OptionallySearch do expect(model) .to receive(:search) .with('foo', some_option: true) + .and_call_original - model.optionally_search('foo', some_option: true) + expect(model.optionally_search('foo', some_option: true)).to eq(['foo', { some_option: true }]) end end |