Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
set variant_config to app
Browse files Browse the repository at this point in the history
  • Loading branch information
sbounmy committed Mar 31, 2012
1 parent 513b0f0 commit 69dac4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/spree_variant_options/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ class Engine < Rails::Engine
end
end

initializer "spree_variant_options.environment", :before => :load_config_initializers, :after => "spree.environment" do
initializer "spree_variant_options.environment", :before => :load_config_initializers, :after => "spree.environment" do |app|
Dir.glob(File.join(File.dirname(__FILE__), "../../app/models/spree/app_configuration/*.rb")) do |c|
Rails.application.config.cache_classes ? require(c) : load(c)
end
SpreeVariantOptions::VariantConfig = SpreeVariantOptions::VariantConfiguration.new
app.config.spree.add_class('variant_preferences')
app.config.spree.variant_preferences = SpreeVariantOptions::VariantConfiguration.new

SpreeVariantOptions::VariantConfig = app.config.spree.variant_preferences
end
end
end
4 changes: 2 additions & 2 deletions test/integration/variant_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class ProductTest < ActionDispatch::IntegrationTest

setup do
Spree::Config[:allow_backorders] = false
@product = Factory(:product)
@size = Factory(:option_type)
@color = Factory(:option_type, :name => "Color")
Expand Down Expand Up @@ -34,13 +35,12 @@ class ProductTest < ActionDispatch::IntegrationTest

test 'disallow choose out of stock variants' do
SpreeVariantOptions::VariantConfig.allow_select_outofstock = false
pending "SpreeVariantOptions::VariantConfig[:allow_select_outofstock] is still true in selenium..."

visit spree.product_path(@product)
within("#product-variants") do
size = find_link('M')
size.click
assert !size["class"].include?("selected")
assert size["class"].include?("selected")
color = find_link('Red')
color.click
assert !color["class"].include?("selected")
Expand Down

0 comments on commit 69dac4e

Please sign in to comment.