|
2 | 2 |
|
3 | 3 | RSpec.describe Queries::Vacancy, type: :query do
|
4 | 4 | let(:repo) { described_class.new }
|
| 5 | + let(:query_attributes) { return { remote: nil, position_type: nil, location: nil } } |
| 6 | + let(:search_query) { Vacancies::Entities::SearchOptions.new } |
5 | 7 |
|
6 | 8 | describe '#all_with_contact' do
|
7 |
| - subject { repo.all_with_contact(limit: 10, page: 1) } |
| 9 | + subject { repo.all_with_contact(limit: 10, page: 1, search_query: search_query) } |
8 | 10 |
|
9 |
| - before { Fabricate.create(:vacancy, published: published, archived_at: archived_at, deleted_at: deleted_at) } |
| 11 | + let(:remote_available) { nil } |
| 12 | + let(:position_type) { nil } |
| 13 | + let(:location) { nil } |
| 14 | + |
| 15 | + before do |
| 16 | + Fabricate.create( |
| 17 | + :vacancy, |
| 18 | + published: published, |
| 19 | + archived: archived, |
| 20 | + deleted_at: deleted_at, |
| 21 | + remote_available: remote_available, |
| 22 | + position_type: position_type, |
| 23 | + location: location |
| 24 | + ) |
| 25 | + end |
10 | 26 |
|
11 | 27 | context 'when vacancy published and not archived or deleted' do
|
12 | 28 | let(:published) { true }
|
|
16 | 32 | it { expect(subject.count).to eq(1) }
|
17 | 33 | it { expect(subject).to all(be_a(Vacancy)) }
|
18 | 34 | it { expect(subject.first.contact).to be_a(Contact) }
|
| 35 | + |
| 36 | + context 'and remote in search_query is true' do |
| 37 | + let(:search_query) { Vacancies::Entities::SearchOptions.new(query_attributes.merge(remote: true)) } |
| 38 | + |
| 39 | + it { expect(subject).to eq([]) } |
| 40 | + |
| 41 | + context 'and remote_available in record is true as well' do |
| 42 | + let(:remote_available) { true } |
| 43 | + |
| 44 | + it { expect(subject.count).to eq(1) } |
| 45 | + end |
| 46 | + end |
| 47 | + |
| 48 | + context 'and position_type in search_query is equal "other"' do |
| 49 | + let(:search_query) { Vacancies::Entities::SearchOptions.new(query_attributes.merge(position_type: 'other')) } |
| 50 | + |
| 51 | + it { expect(subject).to eq([]) } |
| 52 | + |
| 53 | + context 'and position_type in record is "other" as well' do |
| 54 | + let(:position_type) { 'other' } |
| 55 | + |
| 56 | + it { expect(subject.count).to eq(1) } |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + context 'and location in search query is not empty' do |
| 61 | + let(:search_query) { Vacancies::Entities::SearchOptions.new(query_attributes.merge(location: 'VASYUKI')) } |
| 62 | + |
| 63 | + it { expect(subject).to eq([]) } |
| 64 | + |
| 65 | + context 'and location in record includes location from search query' do |
| 66 | + let(:location) { 'New Vasyuki' } |
| 67 | + |
| 68 | + it { expect(subject.count).to eq(1) } |
| 69 | + end |
| 70 | + end |
19 | 71 | end
|
20 | 72 |
|
21 | 73 | context 'when vacancy published and archived' do
|
|
0 commit comments