Permalink
Browse files

deep-copy the default configuration object before passing it on to a …

…class..
  • Loading branch information...
Chris Beer
Chris Beer committed Jan 26, 2012
1 parent 10e1b68 commit 47cf614ec21f259539feb531c7f9915a60260353
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/blacklight/configurable.rb
  2. +13 −0 test_support/spec/lib/blacklight_configurable_spec.rb
@@ -45,7 +45,7 @@ def configure_blacklight(*args, &block)
# The default configuration object, by default it reads from Blacklight.config for backwards
# compatibility with Blacklight <= 3.1
def default_configuration
- Blacklight::Configurable.default_configuration
+ Blacklight::Configurable.default_configuration.inheritable_copy
end
end
@@ -86,6 +86,19 @@ class Child < Parent
instance.blacklight_config.foo.should be_nil
klass.blacklight_config.foo.should == "bar"
end
+
+ it "configurable classes should not mutate the default configuration object" do
+ klass = Class.new
+ klass.send(:include, Blacklight::Configurable)
+ klass.blacklight_config.foo = "bar"
+
+ klass2 = Class.new
+ klass2.send(:include, Blacklight::Configurable)
+ klass2.blacklight_config.foo = "asdf"
+
+ klass.blacklight_config.foo.should == "bar"
+ klass2.blacklight_config.foo.should == "asdf"
+ end
end
end

0 comments on commit 47cf614

Please sign in to comment.