Sha256: 8034f981e9f196f855dd962ad67dbd5ae687e949c4c80405ba20695b86d427c4

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

RSpec.describe SolidusPaypalCommercePlatform::PaypalAddress, type: :model do
  let(:order) { create(:order) }
  let(:original_address) { create(:address) }
  let(:address) { create(:address) }
  let(:params) {
    {
      updated_address: {
        admin_area_1: address.state.abbr,
        admin_area_2: address.city,
        address_line_1: address.address1,
        address_line_2: address.address2,
        postal_code: address.zipcode,
        country_code: address.country.iso
      },
      recipient: {
        name: {
          given_name: address.firstname,
          surname: address.lastname
        }
      }
    }
  }

  describe "#update_address" do
    subject{ order.ship_address }

    it "formats PayPal addresses correctly" do
      order.ship_address = original_address

      described_class.new(order).update(params)

      expect(subject.state).to eq address.state
      expect(subject.city).to eq address.city
      expect(subject.address1).to eq address.address1
      expect(subject.address2).to eq address.address2
      expect(subject.zipcode).to eq address.zipcode
      expect(subject.country).to eq address.country
      expect(subject.firstname).to eq address.firstname
      expect(subject.lastname).to eq address.lastname
      expect(subject.phone).to eq original_address.phone
    end

    context "when no address exists" do
      it "produce a valid address" do
        order.ship_address = nil

        described_class.new(order).update(params)

        expect(subject).to be_present
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_paypal_commerce_platform-0.2.2 spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
solidus_paypal_commerce_platform-0.2.1 spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
solidus_paypal_commerce_platform-0.2.0 spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
solidus_paypal_commerce_platform-0.1.0 spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
solidus_paypal_commerce_platform-0.0.1 spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb