Skip to content

Commit

Permalink
Stop the <ask> sequence if next_dialog is '-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed May 10, 2021
1 parent 9740dbc commit 151687c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/autoinstall/ask/runner.rb
Expand Up @@ -125,7 +125,7 @@ def find_next_dialog_index
next_dialog = File.read(DIALOG_FILE)
FileUtils.rm(DIALOG_FILE)
dialog_id = next_dialog.to_i
return unless dialog_id
return dialog_id if dialog_id.nil? || dialog_id == -1

next_dialog = dialogs.find { |d| d.id == dialog_id }
dialogs.index(next_dialog)
Expand All @@ -150,7 +150,10 @@ def go_back
#
# @return [Dialog,nil] Returns the following dialog or `nil` if there are no more dialogs
def go_next
next_index = find_next_dialog_index || (current_index + 1)
next_index = find_next_dialog_index
return nil if next_index == -1

next_index ||= current_index + 1
@indexes.push(next_index)
dialogs[next_index]
end
Expand Down
11 changes: 11 additions & 0 deletions test/lib/autoinstall/ask/runner_test.rb
Expand Up @@ -222,6 +222,17 @@
runner.run
end
end

context "and the content is '-1'" do
before do
File.write(next_dialog_file, "-1\n")
end

it "finishes the sequence" do
expect(ask_dialog1).to_not receive(:run)
runner.run
end
end
end
end
end

0 comments on commit 151687c

Please sign in to comment.