Sha256: 144737018f07691cee285aa0a415b721bd2626c28d6726c38785c785adbb2e8a
Contents?: true
Size: 1.58 KB
Versions: 7
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' describe Spree::Api::BaseController do render_views controller(Spree::Api::BaseController) do def index render :json => { "products" => [] } end end context "cannot make a request to the API" do it "without an API key" do api_get :index json_response.should == { "error" => "You must specify an API key." } response.status.should == 401 end it "with an invalid API key" do request.env["X-Spree-Token"] = "fake_key" get :index, {} json_response.should == { "error" => "Invalid API key (fake_key) specified." } response.status.should == 401 end it "using an invalid token param" do get :index, :token => "fake_key" json_response.should == { "error" => "Invalid API key (fake_key) specified." } end end it 'handles exceptions' do subject.should_receive(:authenticate_user).and_return(true) subject.should_receive(:index).and_raise(Exception.new("no joy")) get :index, :token => "fake_key" json_response.should == { "exception" => "no joy" } end it "maps symantec keys to nested_attributes keys" do klass = stub(:nested_attributes_options => { :line_items => {}, :bill_address => {} }) attributes = { 'line_items' => { :id => 1 }, 'bill_address' => { :id => 2 }, 'name' => 'test order' } mapped = subject.map_nested_attributes_keys(klass, attributes) mapped.has_key?('line_items_attributes').should be_true mapped.has_key?('name').should be_true end end
Version data entries
7 entries across 7 versions & 1 rubygems