Sha256: dad7c648d5e2b1d8535cb70d7be163f8b2289db10c8a596c85cf98e28512aca6

Contents?: true

Size: 798 Bytes

Versions: 12

Compression:

Stored size: 798 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Spree::Order, type: :model do
  let(:order) { described_class.new }

  context '#associate_user!' do
    let(:user) { build_stubbed(:user, email: 'spree@example.com') }
    before { allow(order).to receive(:save!) { true } }

    it 'associates the order with the specified user' do
      order.associate_user! user
      expect(order.user).to eq user
    end

    it "sets the order's email attribute to that of the specified user" do
      order.associate_user! user
      expect(order.email).to eq user.email
    end

    it 'destroys any previous association with a guest user' do
      guest_user = build_stubbed(:user)
      order.user = guest_user
      order.associate_user! user
      expect(order.user).not_to eq guest_user
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
solidus_auth_devise-2.5.9 spec/models/order_spec.rb
solidus_auth_devise-2.5.8 spec/models/order_spec.rb
solidus_auth_devise-2.5.7 spec/models/order_spec.rb
solidus_auth_devise-2.5.6 spec/models/order_spec.rb
solidus_auth_devise-2.5.5 spec/models/order_spec.rb
solidus_auth_devise-2.5.4 spec/models/order_spec.rb
solidus_auth_devise-2.5.3 spec/models/order_spec.rb
solidus_auth_devise-2.5.2 spec/models/order_spec.rb
solidus_auth_devise-2.5.1 spec/models/order_spec.rb
solidus_auth_devise-2.5.0 spec/models/order_spec.rb
solidus_auth_devise-2.4.0 spec/models/order_spec.rb
solidus_auth_devise-2.3.0 spec/models/order_spec.rb