Fix conflict between normalize and array_attribute macros.
Fix the `normalize` and `array_attribute` macros conflicting with each other on the WikiPage model. This meant code like `wiki_page.other_names = "foo bar"` didn't work. Both macros defined a `other_names=` method, but one method overrode the other. The fix is to use anonymous modules and prepend so we can chain method calls with super.
This commit is contained in:
@@ -101,6 +101,10 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
should normalize_attribute(:other_names).from(["ABC"]).to(["ABC"])
|
||||
should normalize_attribute(:other_names).from(["foo", "foo"]).to(["foo"])
|
||||
should normalize_attribute(:other_names).from(%w[foo*bar baz baz 加賀(艦これ)]).to(%w[foo*bar baz 加賀(艦これ)])
|
||||
|
||||
should normalize_attribute(:other_names).from("foo foo").to(["foo"])
|
||||
should normalize_attribute(:other_names).from("foo bar").to(["foo", "bar"])
|
||||
should normalize_attribute(:other_names).from("_foo_ Bar").to(["foo", "Bar"])
|
||||
end
|
||||
|
||||
context "during title validation" do
|
||||
|
||||
Reference in New Issue
Block a user