Skip to content

Commit

Permalink
Add an extra layer to test passing down warn_about_add_children_to_leaf.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfly committed Feb 10, 2017
1 parent 08e2500 commit 4f65248
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/i18n/tasks/data/tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ class Node # rubocop:disable Metrics/ClassLength
attr_accessor :value
attr_reader :key, :children, :parent

def initialize(key:, value: nil, data: nil, parent: nil, children: nil)
def initialize(key:, value: nil, data: nil, parent: nil, children: nil, warn_about_add_children_to_leaf: true)
@key = key
@key = @key.to_s.freeze if @key
@value = value
@data = data
@parent = parent
@warn_about_add_children_to_leaf = warn_about_add_children_to_leaf
self.children = (children if children)
end

Expand All @@ -34,7 +35,7 @@ def children=(children)
when NilClass
nil
else
Siblings.new(nodes: children, parent: self)
Siblings.new(nodes: children, parent: self, warn_about_add_children_to_leaf: @warn_about_add_children_to_leaf)
end
dirty!
end
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/data/tree/siblings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def set(full_key, node)

if rest
unless child
child = Node.new(key: key_part, parent: parent, children: [])
child = Node.new(key: key_part, parent: parent, children: [], warn_about_add_children_to_leaf: @warn_add_children_to_leaf)
append! child
end
unless child.children
Expand Down
4 changes: 2 additions & 2 deletions spec/used_keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
div = t 'a'
p = t 'a'
h1 = t 'b'
h2 = t 'c'
h3 = t 'c.underneath_c'
h2 = t 'c.layer'
h3 = t 'c.layer.underneath_c'
SLIM
end

Expand Down

0 comments on commit 4f65248

Please sign in to comment.