diff --git a/spec/models/spree/product_option_type_spec.rb b/spec/models/spree/product_option_type_spec.rb deleted file mode 100644 index 8bf1870013..0000000000 --- a/spec/models/spree/product_option_type_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Spree::ProductOptionType do - -end diff --git a/spec/models/spree/product_property_spec.rb b/spec/models/spree/product_property_spec.rb index e979efb769..34bd96a314 100644 --- a/spec/models/spree/product_property_spec.rb +++ b/spec/models/spree/product_property_spec.rb @@ -1,14 +1,13 @@ +# frozen_string_literal: true + require 'spec_helper' describe Spree::ProductProperty do - context "validations" do it "should validate length of value" do pp = create(:product_property) pp.value = "x" * 256 pp.should_not be_valid end - end - end diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index e5c0aa072c..6b12dead78 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -7,7 +7,7 @@ module Spree context '#duplicate' do before do - product.stub :taxons => [create(:taxon)] + product.stub taxons: [create(:taxon)] end it 'duplicates product' do @@ -42,7 +42,7 @@ module Spree context "product has variants" do before do - create(:variant, :product => product) + create(:variant, product: product) end context "#destroy" do @@ -148,8 +148,8 @@ module Spree context "permalink" do context "build product with similar name" do - let!(:other) { create(:product, :name => 'foo bar') } - let(:product) { build(:product, :name => 'foo') } + let!(:other) { create(:product, name: 'foo bar') } + let(:product) { build(:product, name: 'foo') } before { product.valid? } @@ -160,31 +160,31 @@ module Spree context "build permalink with quotes" do it "saves quotes" do - product = create(:product, :name => "Joe's", :permalink => "joe's") + product = create(:product, name: "Joe's", permalink: "joe's") product.permalink.should == "joe's" end end context "permalinks must be unique" do before do - @product1 = create(:product, :name => 'foo') + @product1 = create(:product, name: 'foo') end it "cannot create another product with the same permalink" do - pending '[Spree build] Failing spec' - @product2 = create(:product, :name => 'foo') + pending '[Spree build] Failing spec' + @product2 = create(:product, name: 'foo') lambda do - @product2.update_attributes(:permalink => @product1.permalink) + @product2.update(permalink: @product1.permalink) end.should raise_error(ActiveRecord::RecordNotUnique) end end it "supports Chinese" do - create(:product, :name => "你好").permalink.should == "ni-hao" + create(:product, name: "你好").permalink.should == "ni-hao" end context "manual permalink override" do - let(:product) { create(:product, :name => "foo") } + let(:product) { create(:product, name: "foo") } it "calling save_permalink with a parameter" do product.name = "foobar" @@ -196,17 +196,17 @@ module Spree end end - context "override permalink of deleted product" do - let(:product) { create(:product, :name => "foo") } + context "override permalink of deleted product" do + let(:product) { create(:product, name: "foo") } - it "should create product with same permalink from name like deleted product" do - product.permalink.should == "foo" - product.destroy - - new_product = create(:product, :name => "foo") - new_product.permalink.should == "foo" - end - end + it "should create product with same permalink from name like deleted product" do + product.permalink.should == "foo" + product.destroy + + new_product = create(:product, name: "foo") + new_product.permalink.should == "foo" + end + end end context "properties" do @@ -237,11 +237,11 @@ module Spree # Regression test for #2455 it "should not overwrite properties' presentation names" do - Spree::Property.where(:name => 'foo').first_or_create!(:presentation => "Foo's Presentation Name") + Spree::Property.where(name: 'foo').first_or_create!(presentation: "Foo's Presentation Name") product.set_property('foo', 'value1') product.set_property('bar', 'value2') - Spree::Property.where(:name => 'foo').first.presentation.should == "Foo's Presentation Name" - Spree::Property.where(:name => 'bar').first.presentation.should == "bar" + Spree::Property.where(name: 'foo').first.presentation.should == "Foo's Presentation Name" + Spree::Property.where(name: 'bar').first.presentation.should == "bar" end end @@ -260,16 +260,16 @@ module Spree context "when prototype with option types is supplied" do def build_option_type_with_values(name, values) - ot = create(:option_type, :name => name) + ot = create(:option_type, name: name) values.each do |val| - ot.option_values.create(:name => val.downcase, :presentation => val) + ot.option_values.create(name: val.downcase, presentation: val) end ot end let(:prototype) do size = build_option_type_with_values("size", %w(Small Medium Large)) - create(:prototype, :name => "Size", :option_types => [ size ]) + create(:prototype, name: "Size", option_types: [size]) end let(:option_values_hash) do diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index 6db5047062..4d1aafc4d5 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -22,7 +22,7 @@ module Spree it "propagate to stock items" do Spree::StockLocation.any_instance.should_receive(:propagate_variant) - product.variants.create(:name => "Foobar") + product.variants.create(name: "Foobar") end context "stock location has disable propagate all variants" do @@ -30,7 +30,7 @@ module Spree it "propagate to stock items" do Spree::StockLocation.any_instance.should_not_receive(:propagate_variant) - product.variants.create(:name => "Foobar") + product.variants.create(name: "Foobar") end end end @@ -38,7 +38,7 @@ module Spree context "product has other variants" do describe "option value accessors" do before { - @multi_variant = FactoryGirl.create :variant, :product => variant.product + @multi_variant = FactoryGirl.create :variant, product: variant.product variant.product.reload } @@ -58,7 +58,7 @@ module Spree multi_variant.set_option_value('media_type', 'CD') expect { - multi_variant.set_option_value('media_type', 'DVD') + multi_variant.set_option_value('media_type', 'DVD') }.to_not change(multi_variant.option_values, :count) expect { @@ -70,7 +70,7 @@ module Spree context "product has other variants" do describe "option value accessors" do before { - @multi_variant = create(:variant, :product => variant.product) + @multi_variant = create(:variant, product: variant.product) variant.product.reload } @@ -90,7 +90,7 @@ module Spree multi_variant.set_option_value('media_type', 'CD') expect { - multi_variant.set_option_value('media_type', 'DVD') + multi_variant.set_option_value('media_type', 'DVD') }.to_not change(multi_variant.option_values, :count) expect { @@ -104,7 +104,7 @@ module Spree context "price parsing" do before(:each) do I18n.locale = I18n.default_locale - I18n.backend.store_translations(:de, { :number => { :currency => { :format => { :delimiter => '.', :separator => ',' } } } }) + I18n.backend.store_translations(:de, { number: { currency: { format: { delimiter: '.', separator: ',' } } } }) end after do @@ -187,7 +187,7 @@ module Spree describe '.price_in' do before do - variant.prices << create(:price, :variant => variant, :currency => "EUR", :amount => 33.33) + variant.prices << create(:price, variant: variant, currency: "EUR", amount: 33.33) end subject { variant.price_in(currency).display_amount } @@ -218,7 +218,7 @@ module Spree describe '.amount_in' do before do - variant.prices << create(:price, :variant => variant, :currency => "EUR", :amount => 33.33) + variant.prices << create(:price, variant: variant, currency: "EUR", amount: 33.33) end subject { variant.amount_in(currency) } @@ -251,8 +251,8 @@ module Spree # Regression test for #2432 describe 'options_text' do before do - option_type = double("OptionType", :presentation => "Foo") - option_values = [double("OptionValue", :option_type => option_type, :presentation => "bar")] + option_type = double("OptionType", presentation: "Foo") + option_values = [double("OptionValue", option_type: option_type, presentation: "bar")] variant.stub(:option_values).and_return(option_values) end @@ -344,7 +344,7 @@ module Spree expect(variant.total_on_hand).to eq(Spree::Stock::Quantifier.new(variant).total_on_hand) end end - + describe "double loading" do # app/models/spree/variant_decorator.rb may be double-loaded in delayed job environment, # so we need to be able to do so without error.