mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add basic SearchOrders service spec
This commit is contained in:
37
spec/services/search_orders_spec.rb
Normal file
37
spec/services/search_orders_spec.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe SearchOrders do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
let!(:order1) { create(:order, distributor: distributor) }
|
||||
let!(:order2) { create(:order, distributor: distributor) }
|
||||
let!(:order3) { create(:order, distributor: distributor) }
|
||||
|
||||
let(:enterprise_user) { distributor.owner }
|
||||
|
||||
describe '#orders' do
|
||||
let(:params) { {} }
|
||||
let(:service) { SearchOrders.new(params, enterprise_user) }
|
||||
|
||||
it 'returns orders' do
|
||||
expect(service.orders.count).to eq 3
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pagination_data' do
|
||||
let(:params) { { per_page: 15, page: 1 } }
|
||||
let(:service) { SearchOrders.new(params, enterprise_user) }
|
||||
|
||||
it 'returns pagination data' do
|
||||
expect(service.pagination_data).to eq pagination_data
|
||||
end
|
||||
end
|
||||
|
||||
def pagination_data
|
||||
{
|
||||
results: 3,
|
||||
pages: 1,
|
||||
page: 1,
|
||||
per_page: 15
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user