mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add spec for truthiness
It's generally expected that a #save method will return true on succes, and false on failure.
This commit is contained in:
@@ -7,6 +7,7 @@ describe Sets::ProductSet do
|
||||
let(:product_set) do
|
||||
described_class.new(collection_attributes: collection_hash)
|
||||
end
|
||||
subject{ product_set.save }
|
||||
|
||||
context 'when the product does not exist yet' do
|
||||
let!(:stock_location) { create(:stock_location, backorderable_default: false) }
|
||||
@@ -33,6 +34,24 @@ describe Sets::ProductSet do
|
||||
end
|
||||
|
||||
context 'when the product does exist' do
|
||||
let(:product) { create(:simple_product, name: "product name") }
|
||||
|
||||
context "with valid name" do
|
||||
let(:collection_hash) {
|
||||
{ 0 => { id: product.id, name: "New season product" } }
|
||||
}
|
||||
|
||||
it { is_expected.to eq true }
|
||||
end
|
||||
|
||||
context "with invalid name" do
|
||||
let(:collection_hash) {
|
||||
{ 0 => { id: product.id, name: "" } } # Product Name can't be blank
|
||||
}
|
||||
|
||||
it { is_expected.to eq false }
|
||||
end
|
||||
|
||||
context 'when a different variant_unit is passed' do
|
||||
let!(:product) do
|
||||
create(
|
||||
@@ -68,7 +87,6 @@ describe Sets::ProductSet do
|
||||
|
||||
context "when the product is in an order cycle" do
|
||||
let(:producer) { create(:enterprise) }
|
||||
let(:product) { create(:simple_product) }
|
||||
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
let!(:order_cycle) {
|
||||
|
||||
Reference in New Issue
Block a user