From df95370d9d5e0d7f3fafbf411e21c6542dc90930 Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Wed, 15 Jan 2025 10:41:19 -0800 Subject: [PATCH] Change a GT to a GTE --- lib/pinchflat/settings/setting.ex | 2 +- test/pinchflat/settings_test.exs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pinchflat/settings/setting.ex b/lib/pinchflat/settings/setting.ex index be644f2b..2d687547 100644 --- a/lib/pinchflat/settings/setting.ex +++ b/lib/pinchflat/settings/setting.ex @@ -45,6 +45,6 @@ defmodule Pinchflat.Settings.Setting do setting |> cast(attrs, @allowed_fields) |> validate_required(@required_fields) - |> validate_number(:extractor_sleep_interval_seconds, greater_than: 0) + |> validate_number(:extractor_sleep_interval_seconds, greater_than_or_equal_to: 0) end end diff --git a/test/pinchflat/settings_test.exs b/test/pinchflat/settings_test.exs index 56b9579c..774e2745 100644 --- a/test/pinchflat/settings_test.exs +++ b/test/pinchflat/settings_test.exs @@ -85,5 +85,12 @@ defmodule Pinchflat.SettingsTest do assert %Ecto.Changeset{valid?: true} = Settings.change_setting(setting, %{extractor_sleep_interval_seconds: 0}) assert %Ecto.Changeset{valid?: false} = Settings.change_setting(setting, %{extractor_sleep_interval_seconds: -1}) end + + test "allows you to reset the extractor sleep interval" do + setting = Settings.record() + assert {:ok, setting} = Settings.update_setting(setting, %{extractor_sleep_interval_seconds: 1}) + + assert %Ecto.Changeset{valid?: true} = Settings.change_setting(setting, %{extractor_sleep_interval_seconds: 0}) + end end end