mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
add tests
This commit is contained in:
parent
75c645453d
commit
50911b2579
@ -222,6 +222,31 @@ RSpec.describe HasCustomFields do
|
||||
).to eq(1)
|
||||
end
|
||||
|
||||
it "stores boolean values in boolean fields as t or f" do
|
||||
test_item = CustomFieldsTestItem.new
|
||||
CustomFieldsTestItem.register_custom_field_type("bool", :boolean)
|
||||
|
||||
test_item.custom_fields["bool"] = "true"
|
||||
test_item.save_custom_fields
|
||||
|
||||
expect(CustomFieldsTestItemCustomField.last.value).to eq("t")
|
||||
|
||||
test_item.custom_fields["bool"] = "false"
|
||||
test_item.save_custom_fields
|
||||
|
||||
expect(CustomFieldsTestItemCustomField.last.value).to eq("f")
|
||||
end
|
||||
|
||||
it "coerces non-integer values in integer fields" do
|
||||
test_item = CustomFieldsTestItem.new
|
||||
CustomFieldsTestItem.register_custom_field_type("int", :integer)
|
||||
|
||||
test_item.custom_fields["int"] = "true"
|
||||
test_item.save_custom_fields
|
||||
|
||||
expect(CustomFieldsTestItemCustomField.last.value).to eq("0")
|
||||
end
|
||||
|
||||
it "supports type coercion" do
|
||||
test_item = CustomFieldsTestItem.new
|
||||
CustomFieldsTestItem.register_custom_field_type("bool", :boolean)
|
||||
|
Loading…
Reference in New Issue
Block a user