Skip to content

Commit

Permalink
Fixed several factories which were causing dependency errors when run…
Browse files Browse the repository at this point in the history
…ning the full test suite.
  • Loading branch information
Jellyfishboy committed Mar 1, 2014
1 parent 212afca commit 30c45bc
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--drb

--color
--format documentation
Binary file modified db/test.sqlite3
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion spec/factories/accessories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
sequence(:price) { |n| n }
sequence(:weight) { |n| n }
sequence(:cost_value) { |n| n }
active true
active false

factory :invalid_accessory do
name nil
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/addresses.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :address do
active true
active false
default false
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/products.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FactoryGirl.define do
factory :product do
sequence(:name) { |n| "#{Faker::Lorem.characters(10)}#{n}" }
sequence(:name) { |n| "#{Faker::Lorem.word}#{Faker::Lorem.characters(8)}#{n}" }
meta_description { Faker::Lorem.characters(10) }
short_description { Faker::Lorem.characters(15) }
description { Faker::Lorem.characters(20) }
sku { Faker::Lorem.characters(5) }
sequence(:part_number) { |n| "GA#{n}" }
featured false
active true
active false
sequence(:weighting) { |n| n }

association :category
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/shippings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
name { Faker::Lorem.characters(10) }
sequence(:price) { |n| n }
description { Faker::Lorem.characters(99) }
active true
active false
end
end
4 changes: 2 additions & 2 deletions spec/factories/skus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
sequence(:length) { |n| n }
sequence(:weight) { |n| n }
sequence(:thickness) { |n| n }
attribute_value { Faker::Lorem.word }
active true
sequence(:attribute_value) { |n| "#{Faker::Lorem.word}#{n}" }
active false

association :attribute_type
association :product
Expand Down
10 changes: 5 additions & 5 deletions spec/models/accessory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
describe "When a used accessory is updated or deleted" do

it "should set the record as inactive" do
accessory = create(:accessory)
accessory = create(:accessory, active: true)
accessory.inactivate!
expect(accessory.active).to eq false
end
Expand All @@ -35,16 +35,16 @@
describe "When the new accessory fails to update" do

it "should set the record as active" do
accessory = create(:accessory, active: false)
accessory = create(:accessory)
accessory.activate!
expect(accessory.active).to eq true
end
end

it "should return an array of 'active' accessorys" do
accessory_1 = create(:accessory)
accessory_2 = create(:accessory, active: false)
accessory_3 = create(:accessory)
accessory_1 = create(:accessory, active: true)
accessory_2 = create(:accessory)
accessory_3 = create(:accessory, active: true)
expect(Accessory.active).to match_array([accessory_1, accessory_3])
end

Expand Down
18 changes: 9 additions & 9 deletions spec/models/product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@
describe "When a used product is updated or deleted" do

it "should set the record as inactive" do
product = create(:product)
product = create(:product, active: true)
product.inactivate!
expect(product.active).to eq false
end
end

describe "When the new SKU fails to update" do
describe "When the product fails to update" do

it "should set the record as active" do
sku = create(:sku, active: false)
sku.activate!
expect(sku.active).to eq true
product = create(:product)
product.activate!
expect(product.active).to eq true
end
end

it "should return an array of active products" do
product_1 = create(:product, active: false)
product_2 = create(:product)
product_3 = create(:product)
product_1 = create(:product)
product_2 = create(:product, active: true)
product_3 = create(:product, active: true)
expect(Product.active).to match_array([product_2, product_3])
end

Expand All @@ -66,7 +66,7 @@
product_1 = create(:product, weighting: 2000)
product_2 = create(:product, weighting: 3000)
product_3 = create(:product, weighting: 1000)
expect(Product.all).to match_array([product_2, product_1, product_3])
expect(Product.last(3)).to match_array([product_2, product_1, product_3])
end
end

Expand Down
10 changes: 5 additions & 5 deletions spec/models/shipping_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
describe "When a used shipping is updated or deleted" do

it "should set the record as inactive" do
shipping = create(:shipping)
shipping = create(:shipping, active: true)
shipping.inactivate!
expect(shipping.active).to eq false
end
Expand All @@ -32,16 +32,16 @@
describe "When the new shipping fails to update" do

it "should set the record as active" do
shipping = create(:shipping, active: false)
shipping = create(:shipping)
shipping.activate!
expect(shipping.active).to eq true
end
end

it "should return an array of 'active' shippings" do
shipping_1 = create(:shipping)
shipping_2 = create(:shipping, active: false)
shipping_3 = create(:shipping)
shipping_1 = create(:shipping, active: true)
shipping_2 = create(:shipping)
shipping_3 = create(:shipping, active: true)
expect(Shipping.active).to match_array([shipping_1, shipping_3])
end

Expand Down
11 changes: 5 additions & 6 deletions spec/models/sku_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
describe "When a used SKU is updated or deleted" do

it "should set the record as inactive" do
sku = create(:sku)
sku = create(:sku, active: true)
sku.inactivate!
expect(sku.active).to eq false
end
Expand All @@ -47,7 +47,7 @@
describe "When the new SKU fails to update" do

it "should set the record as active" do
sku = create(:sku, active: false)
sku = create(:sku)
sku.activate!
expect(sku.active).to eq true
end
Expand All @@ -63,10 +63,9 @@
end

it "should return an array of active SKUs" do
product = create(:product)
sku_1 = create(:sku, active: false, product: product)
sku_2 = create(:sku, product: product)
sku_3 = create(:sku, active: false, product: product)
sku_1 = create(:sku)
sku_2 = create(:sku, active: true)
sku_3 = create(:sku)
expect(Sku.active).to match_array([sku_2])
end

Expand Down

0 comments on commit 30c45bc

Please sign in to comment.