mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Add basic spec
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe DfcProvider::Api::ProductsController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:enterprise) { create(:distributor_enterprise) }
|
||||
let(:product) do
|
||||
create(:simple_product, supplier: enterprise )
|
||||
end
|
||||
let!(:visible_inventory_item) do
|
||||
create(:inventory_item,
|
||||
enterprise: enterprise,
|
||||
variant: product.variants.first,
|
||||
visible: true)
|
||||
end
|
||||
|
||||
describe('.index') do
|
||||
before do
|
||||
allow(controller)
|
||||
.to receive(:spree_current_user) { enterprise.owner }
|
||||
|
||||
get :index, enterprise_id: enterprise.id
|
||||
end
|
||||
|
||||
it 'is successful' do
|
||||
expect(response.status).to eq 200
|
||||
end
|
||||
|
||||
it 'renders the related product' do
|
||||
expect(response.body)
|
||||
.to include("\"DFC:description\":\"#{product.variants.first.name}\"")
|
||||
end
|
||||
end
|
||||
end
|
||||
3
engines/dfc_provider/spec/spec_helper.rb
Normal file
3
engines/dfc_provider/spec/spec_helper.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
require "../../spec/spec_helper.rb"
|
||||
|
||||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
||||
Reference in New Issue
Block a user