Delete dead code Variant#set_option_value

This commit is contained in:
Matt-Yorkley
2021-02-16 20:29:33 +00:00
parent 105f59d959
commit 42a5d7cdc7
2 changed files with 0 additions and 99 deletions

View File

@@ -174,39 +174,6 @@ module Spree
deleted_at
end
def set_option_value(opt_name, opt_value)
# no option values on master
return if is_master
option_type = Spree::OptionType.where(name: opt_name).first_or_initialize do |o|
o.presentation = opt_name
o.save!
end
current_value = option_values.detect { |o| o.option_type.name == opt_name }
if current_value.nil?
# then we have to check to make sure that the product has the option type
unless product.option_types.include? option_type
product.option_types << option_type
product.save
end
else
return if current_value.name == opt_value
option_values.delete(current_value)
end
option_value = Spree::OptionValue.where(option_type_id: option_type.id,
name: opt_value).first_or_initialize do |o|
o.presentation = opt_value
o.save!
end
option_values << option_value
save
end
def option_value(opt_name)
option_values.detect { |o| o.option_type.name == opt_name }.try(:presentation)
end

View File

@@ -20,72 +20,6 @@ module Spree
end
end
context "product has other variants" do
describe "option value accessors" do
before {
@multi_variant = create(:variant, product: variant.product)
variant.product.reload
}
let(:multi_variant) { @multi_variant }
it "should set option value" do
expect(multi_variant.option_value('media_type')).to be_nil
multi_variant.set_option_value('media_type', 'DVD')
expect(multi_variant.option_value('media_type')).to eq 'DVD'
multi_variant.set_option_value('media_type', 'CD')
expect(multi_variant.option_value('media_type')).to eq 'CD'
end
it "should not duplicate associated option values when set multiple times" do
multi_variant.set_option_value('media_type', 'CD')
expect {
multi_variant.set_option_value('media_type', 'DVD')
}.to_not change(multi_variant.option_values, :count)
expect {
multi_variant.set_option_value('coolness_type', 'awesome')
}.to change(multi_variant.option_values, :count).by(1)
end
end
context "product has other variants" do
describe "option value accessors" do
before {
@multi_variant = create(:variant, product: variant.product)
variant.product.reload
}
let(:multi_variant) { @multi_variant }
it "should set option value" do
expect(multi_variant.option_value('media_type')).to be_nil
multi_variant.set_option_value('media_type', 'DVD')
expect(multi_variant.option_value('media_type')).to eq 'DVD'
multi_variant.set_option_value('media_type', 'CD')
expect(multi_variant.option_value('media_type')).to eq 'CD'
end
it "should not duplicate associated option values when set multiple times" do
multi_variant.set_option_value('media_type', 'CD')
expect {
multi_variant.set_option_value('media_type', 'DVD')
}.to_not change(multi_variant.option_values, :count)
expect {
multi_variant.set_option_value('coolness_type', 'awesome')
}.to change(multi_variant.option_values, :count).by(1)
end
end
end
end
context "price parsing" do
before(:each) do
I18n.locale = I18n.default_locale