summaryrefslogtreecommitdiffhomepage
path: root/test/workbook/worksheet/tc_data_validation.rb
diff options
context:
space:
mode:
authorKoza <[email protected]>2023-09-26 11:33:36 +0200
committerKoza <[email protected]>2023-10-19 10:21:07 +0200
commit964d9800117196c0494d852d84d26613c9cc89f9 (patch)
tree155714420a73c814ebfd9d322a0fb4f06d357d80 /test/workbook/worksheet/tc_data_validation.rb
parent57ddee52d3208a475ba32a78f814884fd7a1cf4c (diff)
downloadcaxlsx-964d9800117196c0494d852d84d26613c9cc89f9.tar.gz
caxlsx-964d9800117196c0494d852d84d26613c9cc89f9.zip
Fix data validations for none type validations to show warnings only
Diffstat (limited to 'test/workbook/worksheet/tc_data_validation.rb')
-rw-r--r--test/workbook/worksheet/tc_data_validation.rb29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb
index fa09b0ab..f411823e 100644
--- a/test/workbook/worksheet/tc_data_validation.rb
+++ b/test/workbook/worksheet/tc_data_validation.rb
@@ -239,6 +239,24 @@ class TestDataValidation < Test::Unit::TestCase
assert doc.xpath("//xmlns:worksheet/xmlns:dataValidations/xmlns:dataValidation/xmlns:formula1='=5/2'")
end
+ def test_none_to_xml
+ p = Axlsx::Package.new
+ @ws = p.workbook.add_worksheet name: "data_validation"
+ @ws.add_data_validation("A1", { type: :none,
+ showInputMessage: true, promptTitle: 'Be careful!',
+ prompt: 'This is a warning to be extra careful editing this cell' })
+
+ doc = Nokogiri::XML.parse(@ws.to_xml_string)
+
+ # test attributes
+ assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='1']/xmlns:dataValidation[@sqref='A1']
+ [@promptTitle='Be careful!'][@prompt='This is a warning to be extra careful editing this cell']
+ [@allowBlank=1][@showInputMessage=1][@type='none']").size)
+ assert doc.xpath("//xmlns:worksheet/xmlns:dataValidations[@count='1']/xmlns:dataValidation[@sqref='A1']
+ [@promptTitle='Be careful!'][@prompt='This is a warning to be extra careful editing this cell']
+ [@allowBlank=1][@showInputMessage=1][@type='none']")
+ end
+
def test_multiple_datavalidations_to_xml
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet name: "data_validation"
@@ -276,6 +294,15 @@ class TestDataValidation < Test::Unit::TestCase
def test_empty_attributes
v = Axlsx::DataValidation.new
- assert_nil(v.send(:get_valid_attributes))
+ assert_equal([:allowBlank,
+ :error,
+ :errorStyle,
+ :errorTitle,
+ :prompt,
+ :promptTitle,
+ :showErrorMessage,
+ :showInputMessage,
+ :sqref,
+ :type], v.send(:get_valid_attributes))
end
end