mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Set up API for Bulk Order Management (BOM)
This commit is contained in:
2
app/views/spree/api/orders/bulk_index.v1.rabl
Normal file
2
app/views/spree/api/orders/bulk_index.v1.rabl
Normal file
@@ -0,0 +1,2 @@
|
||||
collection @orders.order('id ASC')
|
||||
extends "spree/api/orders/bulk_show"
|
||||
2
app/views/spree/api/orders/bulk_show.v1.rabl
Normal file
2
app/views/spree/api/orders/bulk_show.v1.rabl
Normal file
@@ -0,0 +1,2 @@
|
||||
object @order
|
||||
attributes :id
|
||||
28
spec/controllers/spree/api/orders_controller_spec.rb
Normal file
28
spec/controllers/spree/api/orders_controller_spec.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
require 'spec_helper'
|
||||
require 'spree/api/testing_support/helpers'
|
||||
|
||||
module Spree
|
||||
describe Spree::Api::OrdersController do
|
||||
include Spree::Api::TestingSupport::Helpers
|
||||
render_views
|
||||
|
||||
|
||||
let!(:order1) { FactoryGirl.create(:order) }
|
||||
let!(:line_item1) { FactoryGirl.create(:line_item) }
|
||||
let!(:line_item2) { FactoryGirl.create(:line_item) }
|
||||
let(:attributes) { [:id] }
|
||||
|
||||
before do
|
||||
stub_authentication!
|
||||
Spree.user_class.stub :find_by_spree_api_key => current_api_user
|
||||
end
|
||||
|
||||
context "as a normal user" do
|
||||
it "retrieves a list of products with appropriate attributes" do
|
||||
spree_get :index, { :template => 'bulk_index', :format => :json }
|
||||
keys = json_response.first.keys.map{ |key| key.to_sym }
|
||||
attributes.all?{ |attr| keys.include? attr }.should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user