Sha256: e71c32579ce23ce3eaab4cd0b2d4db83bfd51538c8940d1b29f141e7b6348fc4
Contents?: true
Size: 1.24 KB
Versions: 6
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' describe Spree::Promotion::Rules::Country, type: :model do let(:rule) { Spree::Promotion::Rules::Country.new } let(:order) { create(:order) } let(:country) { create(:country) } let(:other_country) { create(:country) } before { allow(Spree::Country).to receive(:default) { other_country.id } } context 'preferred country is set' do before { rule.preferred_country_id = country.id } it 'should be eligible for correct country' do allow(order).to receive_message_chain(:ship_address, :country_id) { country.id } expect(rule).to be_eligible(order) end it 'should not be eligible for incorrect country' do allow(order).to receive_message_chain(:ship_address, :country_id) { other_country.id } expect(rule).not_to be_eligible(order) end end context 'preferred country is not set' do it 'should be eligible for default country' do allow(order).to receive_message_chain(:ship_address, :country_id) { other_country.id } expect(rule).to be_eligible(order) end it 'should not be eligible for incorrect country' do allow(order).to receive_message_chain(:ship_address, :country_id) { country.id } expect(rule).not_to be_eligible(order) end end end
Version data entries
6 entries across 6 versions & 1 rubygems