Skip to content

Commit

Permalink
Apply patch to handle empty string column values for sign media
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmcarthur committed Jan 15, 2024
1 parent 2bc14f8 commit 64b8f31
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/signbank/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Asset < Signbank::Record
scope :image, -> { where("filename LIKE '%.png'") }

def url
return unless super
return unless super.presence

AssetURL.new(super).url.to_s
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/signbank/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Example < Signbank::Record
default_scope -> { order(display_order: :asc).where.not(video: nil) }

def video
return unless super
return unless super.presence

AssetURL.new(super).url.to_s
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/signbank/sign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def picture_url
end

def video
return unless super
return unless super.presence

AssetURL.new(super).url.to_s
end
Expand Down
5 changes: 5 additions & 0 deletions spec/models/signbank/asset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
asset = Signbank::Asset.new(url: nil)
expect(asset.url).to be_nil
end

it 'is nil when the URL is blank' do
asset = Signbank::Asset.new(url: "")
expect(asset.url).to be_nil
end
end

describe '.scoped' do
Expand Down
5 changes: 5 additions & 0 deletions spec/models/signbank/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@
example = Signbank::Example.new(video: nil)
expect(example.video).to be_nil
end

it 'is nil when the URL is blank' do
example = Signbank::Example.new(video: "")
expect(example.video).to be_nil
end
end
end
5 changes: 5 additions & 0 deletions spec/models/signbank/sign_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,10 @@ module Signbank
sign = Signbank::Sign.new(video: nil)
expect(sign.video).to be_nil
end

it 'is nil when the URL is blank' do
sign = Signbank::Sign.new(video: "")
expect(sign.video).to be_nil
end
end
end

0 comments on commit 64b8f31

Please sign in to comment.