Skip to content
Merged
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
6 changes: 3 additions & 3 deletions app/lib/tind_spread/tind_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def validate_files(row, errors)
files_not_found(row, errors)
end

# FFT needs to resolve and needs to be either a jpg, pdf, mp3 or mp4
# FFT needs to resolve and needs to be either a jpg, pdf, mp3, mp4, or mov
def validate_fft(key, value, errors)
add_error(errors, key, "URL: #{value} inaccessible") unless valid_url?(value)
add_error(errors, key, "URL: #{value} invalid. needs to be .jpg, .pdf, .mp3 or .mp4") unless fft_valid_format?(value)
add_error(errors, key, "URL: #{value} invalid. needs to be .jpg, .pdf, .mp3, .mp4 or .mov") unless fft_valid_format?(value)
end

# If there is a 500__3 there needs to be a corresponding 500__a
Expand Down Expand Up @@ -123,7 +123,7 @@ def corresponding_6?(key, row)
end

def fft_valid_format?(url)
return true if url.downcase.end_with?('.jpg', '.pdf', '.mp3', '.mp4')
return true if url.downcase.end_with?(*%w[.jpg .pdf .mp3 .mp4 .mov])

false
end
Expand Down
11 changes: 8 additions & 3 deletions spec/lib/tind_spread/tind_validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
expected_errors = [
'header: FFT__a-1 No files found for value',
'header: FFT__a URL: invalid_url inaccessible',
'header: FFT__a URL: invalid_url invalid. needs to be .jpg, .pdf, .mp3 or .mp4',
'header: FFT__a URL: invalid_url invalid. needs to be .jpg, .pdf, .mp3, .mp4 or .mov',
'header: 500__3 There is a 500__3 without a corresponding 500__a. Value for 500__3 is value',
'header: 800__6 There is no matching $6 for value value'
]
Expand All @@ -30,7 +30,7 @@
allow(described_class).to receive(:fft_valid_format?).with('invalid_url').and_return(false)
described_class.send(:validate_fft, 'FFT__a', 'invalid_url', errors)
expect(errors).to include('header: FFT__a URL: invalid_url inaccessible')
expect(errors).to include('header: FFT__a URL: invalid_url invalid. needs to be .jpg, .pdf, .mp3 or .mp4')
expect(errors).to include('header: FFT__a URL: invalid_url invalid. needs to be .jpg, .pdf, .mp3, .mp4 or .mov')
end
end

Expand Down Expand Up @@ -79,7 +79,7 @@
expect(described_class.send(:fft_valid_format?, url)).to be true
end

it 'returns false for a URL not ending with .jpg, .pdf, .mp3, .mp4' do
it 'returns false for a URL not ending with .jpg, .pdf, .mp3, .mp4, .mov' do
url = 'https://example.com/document.txt'
expect(described_class.send(:fft_valid_format?, url)).to be false
end
Expand All @@ -93,6 +93,11 @@
url = 'https://example.com/song.mp4'
expect(described_class.send(:fft_valid_format?, url)).to be true
end

it 'returns true for a URL ending with .mov' do
url = 'https://example.com/video.mov'
expect(described_class.send(:fft_valid_format?, url)).to be true
end
end

describe '.valid_500__3?' do
Expand Down
Loading