Sha256: 634f0edc0841358cc2fc3e3da149add4e6f664340708803ae4154aef5aba4ead

Contents?: true

Size: 906 Bytes

Versions: 2

Compression:

Stored size: 906 Bytes

Contents

require 'spec_helper'

describe Spree::Account::OrdersController do

  describe "index" do

    let(:sorted_orders) { double(Array) }
    let(:complete_orders) { double(Array, order: sorted_orders) }
    let(:user_orders) { double(Array, complete: complete_orders) }
    let(:user) { mock_model Spree::User, :last_incomplete_spree_order => nil, :has_spree_role? => true, :spree_api_key => 'fake', :orders => user_orders }

    before :each do
      controller.stub :spree_current_user => user
      controller.stub :check_authorization
    end

    it 'should render current users orders' do
      spree_get :index
      assigns(:user).should == user
      assigns(:orders).should == sorted_orders
    end

    it 'should redirect to login if user is not logged in' do
      controller.stub(:spree_current_user).and_return nil
      spree_get :index
      response.status.should == 401
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_my_favourites-2.2.2 spec/controllers/spree/account/orders_controller_spec.rb
spree_my_favourites-2.2.1 spec/controllers/spree/account/orders_controller_spec.rb