Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .ameba.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,15 @@ Style/PredicateName:

Style/QueryBoolMethods:
Enabled: false

Style/RedundantSelf:
Enabled: false

Style/HeredocIndent:
Enabled: false

Style/PercentLiteralDelimiters:
Enabled: false

Style/MultilineStringLiteral:
Enabled: false
14 changes: 14 additions & 0 deletions spec/control_system_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ module PlaceOS::Model

control_system.destroy
end

it "allows empty/blank strings without validation errors" do
control_system = Generator.control_system
control_system.camera_snapshot_urls = [""]
control_system.valid?.should be_true

control_system.camera_snapshot_urls = ["", ""]
control_system.valid?.should be_true

control_system.camera_snapshot_urls = ["", "https://placeos.com/"]
control_system.valid?.should be_true

control_system.destroy
end
end

describe "remove_module" do
Expand Down
13 changes: 8 additions & 5 deletions src/placeos-models/control_system.cr
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ module PlaceOS::Model
# Validate support URI
validate ->(this : ControlSystem) {
this.camera_snapshot_urls.each do |snap_url|
next if snap_url.blank?
if !Validation.valid_uri?(snap_url)
this.validation_error(:camera_snapshot_urls, "contains an invalid URI")
break
Expand Down Expand Up @@ -381,11 +382,13 @@ module PlaceOS::Model

Module.find?(module_id).try(&.destroy) unless still_in_use

Log.debug { {
message: "module removed from system #{still_in_use ? "still in use" : "deleted as not in any other systems"}",
module_id: module_id,
control_system_id: control_system_id,
} }
Log.debug do
{
message: "module removed from system #{still_in_use ? "still in use" : "deleted as not in any other systems"}",
module_id: module_id,
control_system_id: control_system_id,
}
end

true
end
Expand Down
Loading