Skip to content

Commit

Permalink
Fixed relations to not interfere with defined writer methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Nov 7, 2013
1 parent 1032597 commit e72b890
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions History.txt
Expand Up @@ -21,6 +21,8 @@
* Fixed anchor in zazen url "":22#foo should link to anchor #foo in node '22'.
* Prop eval returning nil for title properly replaces title with class name.
* Type ctrl+return to enter a newline inside a grid.
* Checking for defined accessors on links before passing to relation proxy (this enables custom code
on relation modification without passing through RelationProxy).

== 1.2.6, 1.2.7 2013-08-16

Expand Down
1 change: 1 addition & 0 deletions lib/zena/use/relations.rb
Expand Up @@ -94,6 +94,7 @@ def relation_base_class

# Return an array of accessor methods for the matched relation alias.
def relation_alias(match)
return nil if respond_to?("#{match[0]}=") # native method
return nil if match[0] == 'parent_id'
role = match[1]
field = match[2]
Expand Down
20 changes: 20 additions & 0 deletions test/unit/relation_proxy_test.rb
Expand Up @@ -601,4 +601,24 @@ def test_attr_public
end
end
end # With many links

context 'with a native writer' do
subject do
node = secure(Node) { nodes(:cleanWater)}
class << node
def reference_zips=(list)
@list=list
end
end
node
end

should 'update with string list of ids' do
login(:lion)
assert_difference('Link.count', 0) do
subject.update_attributes_with_transformation('reference_ids' => [:art, :menu, :bird_jpg].map {|s| nodes_zip(s)}.join(', '))
assert_equal '30,33,35', subject.instance_variable_get(:@list).sort.join(',')
end
end
end
end

0 comments on commit e72b890

Please sign in to comment.