mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix specs brought from spree
This commit is contained in:
@@ -6,15 +6,19 @@ require 'spec_helper'
|
||||
# with an actual class that extends ActiveRecord::Base and has a corresponding table in the DB.
|
||||
# So we'll just test it using Order and ShippingMethod. These classes are including the module.
|
||||
describe Spree::Core::CalculatedAdjustments do
|
||||
let(:calculator) { mock_model(Spree::Calculator, :compute => 10, :[]= => nil) }
|
||||
let(:calculator) { build(:calculator) }
|
||||
let(:tax_rate) { Spree::TaxRate.new(calculator: calculator) }
|
||||
|
||||
before do
|
||||
allow(calculator).to receive(:compute) { 10 }
|
||||
allow(calculator).to receive(:[]) { nil }
|
||||
end
|
||||
|
||||
it "should add has_one :calculator relationship" do
|
||||
assert Spree::ShippingMethod.
|
||||
reflect_on_all_associations(:has_one).map(&:name).include?(:calculator)
|
||||
end
|
||||
|
||||
let(:tax_rate) { Spree::TaxRate.new(calculator: calculator) }
|
||||
|
||||
context "#create_adjustment and its resulting adjustment" do
|
||||
let(:order) { Spree::Order.create }
|
||||
let(:target) { order }
|
||||
@@ -26,7 +30,7 @@ describe Spree::Core::CalculatedAdjustments do
|
||||
|
||||
it "should have the correct originator and an amount derived from the calculator and supplied calculable" do
|
||||
adjustment = tax_rate.create_adjustment("foo", target, order)
|
||||
adjustment.should_not be_nil
|
||||
expect(adjustment).not_to be_nil
|
||||
expect(adjustment.amount).to eq 10
|
||||
expect(adjustment.source).to eq order
|
||||
expect(adjustment.originator).to eq tax_rate
|
||||
@@ -34,7 +38,7 @@ describe Spree::Core::CalculatedAdjustments do
|
||||
|
||||
it "should be mandatory if true is supplied for that parameter" do
|
||||
adjustment = tax_rate.create_adjustment("foo", target, order, true)
|
||||
adjustment.should be_mandatory
|
||||
expect(adjustment).to be_mandatory
|
||||
end
|
||||
|
||||
context "when the calculator returns 0" do
|
||||
|
||||
@@ -46,11 +46,11 @@ describe Spree::OrderMailer do
|
||||
|
||||
context "when intercept_email is provided" do
|
||||
it "should strip the bcc recipients" do
|
||||
message.bcc.should be_blank
|
||||
expect(message.bcc).to be_blank
|
||||
end
|
||||
|
||||
it "should strip the cc recipients" do
|
||||
message.cc.should be_blank
|
||||
expect(message.cc).to be_blank
|
||||
end
|
||||
|
||||
it "should replace the receipient with the specified address" do
|
||||
@@ -64,7 +64,7 @@ describe Spree::OrderMailer do
|
||||
Spree::Config[:intercept_email] = "intercept@foobar.com"
|
||||
message.deliver
|
||||
@email = ActionMailer::Base.deliveries.first
|
||||
expect(@email.subject.match(/customer@example\.com/)).to be_true
|
||||
expect(@email.subject.match(/customer@example\.com/)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -34,11 +34,11 @@ module Spree
|
||||
subject.override!
|
||||
end
|
||||
|
||||
it { ActionMailer::Base.smtp_settings[:address].should == "smtp.example.com" }
|
||||
it { ActionMailer::Base.smtp_settings[:domain].should == "example.com" }
|
||||
it { ActionMailer::Base.smtp_settings[:port].should == 123 }
|
||||
it { ActionMailer::Base.smtp_settings[:authentication].should == "None" }
|
||||
it { ActionMailer::Base.smtp_settings[:enable_starttls_auto].should be_true }
|
||||
it { expect(ActionMailer::Base.smtp_settings[:address]).to eq "smtp.example.com" }
|
||||
it { expect(ActionMailer::Base.smtp_settings[:domain]).to eq "example.com" }
|
||||
it { expect(ActionMailer::Base.smtp_settings[:port]).to eq 123 }
|
||||
it { expect(ActionMailer::Base.smtp_settings[:authentication]).to eq "None" }
|
||||
it { expect(ActionMailer::Base.smtp_settings[:enable_starttls_auto]).to be_truthy }
|
||||
|
||||
it "doesnt touch user name config" do
|
||||
expect(ActionMailer::Base.smtp_settings[:user_name]).to be_nil
|
||||
@@ -59,8 +59,8 @@ module Spree
|
||||
end
|
||||
|
||||
context "overrides user credentials" do
|
||||
it { ActionMailer::Base.smtp_settings[:user_name].should == "schof" }
|
||||
it { ActionMailer::Base.smtp_settings[:password].should == "hellospree!" }
|
||||
it { expect(ActionMailer::Base.smtp_settings[:user_name]).to eq "schof" }
|
||||
it { expect(ActionMailer::Base.smtp_settings[:password]).to eq "hellospree!" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -71,7 +71,7 @@ module Spree
|
||||
subject.override!
|
||||
end
|
||||
|
||||
it { ActionMailer::Base.perform_deliveries.should be_false }
|
||||
it { expect(ActionMailer::Base.perform_deliveries).to be_falsy }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ require 'spec_helper'
|
||||
# So we'll just test it using Order instead since it included the module.
|
||||
describe Spree::Core::TokenResource do
|
||||
let(:order) { Spree::Order.new }
|
||||
let(:permission) { mock_model(Spree::TokenizedPermission) }
|
||||
let(:permission) { double(Spree::TokenizedPermission) }
|
||||
|
||||
it 'should add has_one :tokenized_permission relationship' do
|
||||
assert Spree::Order.
|
||||
@@ -18,18 +18,18 @@ describe Spree::Core::TokenResource do
|
||||
it 'should return the token of the associated permission' do
|
||||
order.stub tokenized_permission: permission
|
||||
permission.stub token: 'foo'
|
||||
order.token.should == 'foo'
|
||||
expect(order.token).to eq 'foo'
|
||||
end
|
||||
|
||||
it 'should return nil if there is no associated permission' do
|
||||
order.token.should be_nil
|
||||
expect(order.token).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context '#create_token' do
|
||||
it 'should create a randomized 16 character token' do
|
||||
token = order.create_token
|
||||
token.size.should == 16
|
||||
expect(token.size).to eq 16
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user