Skip to content

Commit

Permalink
#182 report on parent tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Mar 6, 2018
1 parent d87d950 commit 1c813e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 12 additions & 1 deletion objects/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ def notify(tickets)
next if current.empty?
tickets.notify(p.xpath('issue/text()')[0], current)
end
@after.xpath('/puzzles/puzzle[ticket]').each do |p|
id = p.xpath('id/text()')[0]
current = summary(p, true)
old = @before.xpath("//puzzle[id='#{id}']")
previous = old.empty? ? '' : summary(old[0], true)
next if previous == current
next if current.empty?
tickets.notify(p.xpath('ticket/text()')[0], current)
end
end

private
Expand All @@ -49,9 +58,11 @@ def issues(puzzle, xpath)
end
end

def summary(puzzle)
def summary(puzzle, itself = false)
all = issues(puzzle, 'children//puzzle')
all += issues(puzzle, 'self::node()') if itself
alive = issues(puzzle, 'children//puzzle[@alive="true" and issue]')
alive += issues(puzzle, 'self::node()[@alive="true" and issue]') if itself
if alive.empty?
if all.empty?
''
Expand Down
3 changes: 1 addition & 2 deletions test/test_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def test_notification_on_two_new_puzzles
end

def test_notification_on_solved_puzzle
return
tickets = Tickets.new
Diff.new(
Nokogiri::XML(
Expand Down Expand Up @@ -126,7 +125,7 @@ def test_notification_on_solved_puzzle
)
assert(
tickets.messages[0] ==
'55 these puzzles are still not solved: [66](#), [77](#)',
'500 the puzzle [100]() is solved',
"Text is wrong: #{tickets.messages[0]}"
)
end
Expand Down

0 comments on commit 1c813e7

Please sign in to comment.