Sha256: 7bf2cf666b7629bfdbe0f24f5e58902fa0c6014355af32ba6545184a857b29bd
Contents?: true
Size: 1.7 KB
Versions: 10
Compression:
Stored size: 1.7 KB
Contents
require 'spec_helper' module Spree describe Api::V1::AddressesController, :type => :controller do render_views before do stub_authentication! @address = create(:address) @order = create(:order, :bill_address => @address) end context "with their own address" do before do allow_any_instance_of(Order).to receive_messages :user => current_api_user end it "gets an address" do api_get :show, :id => @address.id, :order_id => @order.number expect(json_response['address1']).to eq @address.address1 end it "updates an address" do api_put :update, :id => @address.id, :order_id => @order.number, :address => { :address1 => "123 Test Lane" } expect(json_response['address1']).to eq '123 Test Lane' end it "receives the errors object if address is invalid" do api_put :update, :id => @address.id, :order_id => @order.number, :address => { :address1 => "" } expect(json_response['error']).not_to be_nil expect(json_response['errors']).not_to be_nil expect(json_response['errors']['address1'].first).to eq "can't be blank" end end context "on an address that does not belong to this order" do before do @order.bill_address_id = nil @order.ship_address = nil end it "cannot retrieve address information" do api_get :show, :id => @address.id, :order_id => @order.number assert_unauthorized! end it "cannot update address information" do api_get :update, :id => @address.id, :order_id => @order.number assert_unauthorized! end end end end
Version data entries
10 entries across 10 versions & 1 rubygems