Sha256: 19aa23890f0cefb9ad898f0ebbf961c16b4a7d0bef24c4dd0fe81905eb5ac2c2

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

RSpec.describe SolidusBolt::OrderDecorator do
  let(:order) { create(:order_with_line_items) }

  describe '#bolt_cart' do
    it 'returns a hash with line items and price' do
      result = {
        total_amount: (order.total * 100).to_i,
        tax_amount: (order.tax_total * 100).to_i,
        order_reference: order.number,
        currency: 'USD',
        shipments: array_including(hash_including(:reference)),
        items: [{
          sku: order.line_items.first.sku,
          name: order.line_items.first.name,
          unit_price: 1000,
          quantity: 1
        }]
      }

      expect(order.bolt_cart).to match hash_including(result)
    end
  end

  describe '#bolt_user_identifier' do
    it 'returns a hash with email and phone' do
      result = { email: order.email, phone: '555-555-0199' }
      expect(order.bolt_user_identifier).to eq(result)
    end
  end

  describe '#bolt_user_identity' do
    it 'returns a hash with name' do
      result = { 'first_name': 'John', 'last_name': 'Doe' }
      expect(order.bolt_user_identity).to eq(result)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_bolt-0.7.2 spec/decorators/models/solidus_bolt/order_decorator_spec.rb
solidus_bolt-0.7.1 spec/decorators/models/solidus_bolt/order_decorator_spec.rb
solidus_bolt-0.7.0 spec/decorators/models/solidus_bolt/order_decorator_spec.rb
solidus_bolt-0.6.0 spec/decorators/models/solidus_bolt/order_decorator_spec.rb
solidus_bolt-0.5.0 spec/decorators/models/solidus_bolt/order_decorator_spec.rb
solidus_bolt-0.4.0 spec/decorators/models/solidus_bolt/order_decorator_spec.rb