Skip to content

Commit

Permalink
Check text box for default value for automate hash correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jun 25, 2018
1 parent adb2759 commit 081f35c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/dialog_field_text_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def value_from_dialog_fields(dialog_values)
end

def automate_output_value
return default_value if default_value.present?
return nil if @value.nil?
return MiqPassword.encrypt(@value) if self.protected?
convert_value_to_type
Expand Down
10 changes: 10 additions & 0 deletions spec/models/dialog_field_text_box_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@
described_class.new(:value => "12test", :data_type => data_type, :protected => protected_attr)
end

let(:dialog_field_with_default_value) do
described_class.new(:default_value => "123test")
end

context "when the data type is a string" do
let(:data_type) { "string" }

Expand All @@ -359,6 +363,12 @@
expect(dialog_field.automate_output_value).to eq("12test")
end
end

context "when it is not protected" do
it "returns the default value" do
expect(dialog_field_with_default_value.automate_output_value).to eq("123test")
end
end
end

context "when the data type is an integer" do
Expand Down

0 comments on commit 081f35c

Please sign in to comment.