[Enhancement] Filter media based on min and/or max duration (#356)
* Added duration limits to source model * Added duration limits to source form * Added validation for min/max amounts * Added duration checks to pending query * Moved min/max filters up in source form * Removed debugger
This commit is contained in:
1 parent
8e9f02c807
commit
af8235c6b3
8 files changed
+154
-1
No files matched your search
@@ -681,6 +681,34 @@ defmodule Pinchflat.SourcesTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "change_source/3 when testing min/max duration validations" do
|
||||
test "succeeds if min and max are nil" do
|
||||
source = source_fixture()
|
||||
|
||||
assert %{errors: []} = Sources.change_source(source, %{min_duration_seconds: nil, max_duration_seconds: nil})
|
||||
end
|
||||
|
||||
test "succeeds if either min or max is nil" do
|
||||
source = source_fixture()
|
||||
|
||||
assert %{errors: []} = Sources.change_source(source, %{min_duration_seconds: nil, max_duration_seconds: 100})
|
||||
assert %{errors: []} = Sources.change_source(source, %{min_duration_seconds: 100, max_duration_seconds: nil})
|
||||
end
|
||||
|
||||
test "succeeds if min is less than max" do
|
||||
source = source_fixture()
|
||||
|
||||
assert %{errors: []} = Sources.change_source(source, %{min_duration_seconds: 100, max_duration_seconds: 200})
|
||||
end
|
||||
|
||||
test "fails if min is greater than or equal to max" do
|
||||
source = source_fixture()
|
||||
|
||||
assert %{errors: [_]} = Sources.change_source(source, %{min_duration_seconds: 200, max_duration_seconds: 100})
|
||||
assert %{errors: [_]} = Sources.change_source(source, %{min_duration_seconds: 100, max_duration_seconds: 100})
|
||||
end
|
||||
end
|
||||
|
||||
describe "change_source/3 when testing original_url validation" do
|
||||
test "succeeds when an original URL is valid" do
|
||||
source = source_fixture()
|
||||
|
||||
Reference in new issue
Block a user