Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clear prefix_parameters cache when setting prefix

Conflicts:

	activeresource/test/base_test.rb
  • Loading branch information...
commit 4e5e0b7eedd15f23afd15eb8978ff4e24d25eb96 1 parent 9c11b96
@tarmo tarmo authored
View
3  activeresource/lib/active_resource/base.rb
@@ -356,6 +356,9 @@ def prefix=(value = '/')
# Replace :placeholders with '#{embedded options[:lookups]}'
prefix_call = value.gsub(/:\w+/) { |key| "\#{options[#{key}]}" }
+ # Clear prefix parameters in case they have been cached
+ @prefix_parameters = nil
+
# Redefine the new methods.
code = <<-end_code
def prefix_source() "#{value}" end
View
11 activeresource/test/base_test.rb
@@ -484,7 +484,16 @@ def test_set_prefix_with_inline_keys
assert_equal "the_prefixthe_param_value", person_class.prefix(:the_param => "the_param_value")
end
end
-
+
+ def test_set_prefix_twice_should_clear_params
+ SetterTrap.rollback_sets(Person) do |person_class|
+ person_class.prefix = "the_prefix/:the_param1"
+ assert_equal Set.new([:the_param1]), person_class.prefix_parameters
+ person_class.prefix = "the_prefix/:the_param2"
+ assert_equal Set.new([:the_param2]), person_class.prefix_parameters
+ end
+ end
+
def test_set_prefix_with_default_value
SetterTrap.rollback_sets(Person) do |person_class|
person_class.set_prefix
Please sign in to comment.
Something went wrong with that request. Please try again.