Sha256: 066203116320e4a95e8c73bd9c3b6ebc0b8d17254ab176b4e8a44a7b080b624b

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe Spree::Order, :type => :model do
  context 'CurrencyUpdater' do
    context "when changing order currency" do
      let!(:line_item) { create(:line_item) }
      let!(:euro_price) { create(:price, variant: line_item.variant, amount: 8, currency: 'EUR') }

      context "#homogenize_line_item_currencies" do
        it "succeeds without error" do
          expect { line_item.order.update_attributes!(currency: 'EUR') }.to_not raise_error
        end      

        it "changes the line_item currencies" do
          expect { line_item.order.update_attributes!(currency: 'EUR') }.to change{ line_item.reload.currency }.from('USD').to('EUR')
        end

        it "changes the line_item amounts" do
          expect { line_item.order.update_attributes!(currency: 'EUR') }.to change{ line_item.reload.amount }.to(8)
        end

        it "fails to change the order currency when no prices are available in that currency" do
          expect { line_item.order.update_attributes!(currency: 'GBP') }.to raise_error
        end

        it "calculates the item total in the order.currency" do
          expect { line_item.order.update_attributes!(currency: 'EUR') }.to change{ line_item.order.item_total }.to(8)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree_core-3.0.10 spec/models/spree/order/currency_updater_spec.rb
spree_core-3.0.9 spec/models/spree/order/currency_updater_spec.rb
spree_core-3.0.8 spec/models/spree/order/currency_updater_spec.rb
spree_core-3.0.7 spec/models/spree/order/currency_updater_spec.rb
spree_core-3.0.6.1 spec/models/spree/order/currency_updater_spec.rb
spree_core-3.0.6 spec/models/spree/order/currency_updater_spec.rb