Skip to content

Commit

Permalink
Update from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed May 11, 2021
1 parent 899d1e7 commit 320d073
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lib/autoinstall/ask/question.rb
Expand Up @@ -86,6 +86,8 @@ def value=(val)
[true, "true"].include?(val)
when "symbol"
val.to_sym
when "static_text"
nil
else
val.to_s
end
Expand Down
10 changes: 9 additions & 1 deletion src/lib/autoinstall/ask/runner.rb
Expand Up @@ -120,7 +120,15 @@ def run_dialog(dialog)
#
# @return [Integer,nil] Next dialog ID
def find_next_dialog_index
return unless File.file?(DIALOG_FILE) && File.size(DIALOG_FILE) <= MAX_DIALOG_FILE_SIZE
return unless File.exist?(DIALOG_FILE)

is_file = File.file?(DIALOG_FILE)
file_size = File.size(DIALOG_FILE)
if !is_file || file_size > MAX_DIALOG_FILE_SIZE
log.error "Ignoring #{DIALOG_FILE} because it is not a file (#{is_file}) or " \
"it is too big (#{file_size}."
return
end

next_dialog = File.read(DIALOG_FILE)
FileUtils.rm(DIALOG_FILE)
Expand Down
2 changes: 2 additions & 0 deletions src/lib/autoinstall/widgets/ask/check_box.rb
Expand Up @@ -37,6 +37,8 @@ def initialize(question)
end

# @macro seeAbstractWidget
# The ':notify' option is needed to notify the timer when the value changes.
# @see Y2Autoinstall::Widgets::Ask::Dialog::TimeoutWrapper
def opt
[:notify]
end
Expand Down
4 changes: 3 additions & 1 deletion src/lib/autoinstall/widgets/ask/combo_box.rb
Expand Up @@ -36,8 +36,10 @@ def initialize(question)
end

# @macro seeAbstractWidget
# The ':notify' option is needed to notify the timer when the value changes.
# @see Y2Autoinstall::Widgets::Ask::Dialog::TimeoutWrapper
def opt
[:notify, :immediate]
[:notify]
end

# @macro seeComboBox
Expand Down
2 changes: 2 additions & 0 deletions src/lib/autoinstall/widgets/ask/input_field.rb
Expand Up @@ -37,6 +37,8 @@ def initialize(question)
end

# @macro seeAbstractWidget
# This options are needed to notify the timer when the value changes
# @see Y2Autoinstall::Widgets::Ask::Dialog::TimeoutWrapper
def opt
[:hstretch, :notify]
end
Expand Down
2 changes: 2 additions & 0 deletions src/lib/autoinstall/widgets/ask/password_field.rb
Expand Up @@ -57,6 +57,8 @@ def value
end

# @macro seeAbstractWidget
# The ':notify' option is needed to notify the timer when the value changes.
# @see Y2Autoinstall::Widgets::Ask::Dialog::TimeoutWrapper
def opt
[:hstretch, :notify]
end
Expand Down
9 changes: 9 additions & 0 deletions test/lib/autoinstall/ask/question_test.rb
Expand Up @@ -83,6 +83,15 @@
end
end

context "when the question's type is 'static_text'" do
let(:type) { "static_text" }

it "does not set the value" do
question.value = "1"
expect(question.value).to be_nil
end
end

context "when the question's type is not set" do
subject(:question) do
described_class.new("Question 1")
Expand Down

0 comments on commit 320d073

Please sign in to comment.