Skip to content

Commit 2f3a695

Browse files
Allowing .mov for tind-spread-validation (#63)
* Allowing .mov for tind-spread-validation * passing array for allowed extensions for tind-spread-validation
1 parent 4bfaff6 commit 2f3a695

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎app/lib/tind_spread/tind_validation.rb‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ def validate_files(row, errors)
6464
files_not_found(row, errors)
6565
end
6666

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

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

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

128128
false
129129
end

‎spec/lib/tind_spread/tind_validation_spec.rb‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
expected_errors = [
1616
'header: FFT__a-1 No files found for value',
1717
'header: FFT__a URL: invalid_url inaccessible',
18-
'header: FFT__a URL: invalid_url invalid. needs to be .jpg, .pdf, .mp3 or .mp4',
18+
'header: FFT__a URL: invalid_url invalid. needs to be .jpg, .pdf, .mp3, .mp4 or .mov',
1919
'header: 500__3 There is a 500__3 without a corresponding 500__a. Value for 500__3 is value',
2020
'header: 800__6 There is no matching $6 for value value'
2121
]
@@ -30,7 +30,7 @@
3030
allow(described_class).to receive(:fft_valid_format?).with('invalid_url').and_return(false)
3131
described_class.send(:validate_fft, 'FFT__a', 'invalid_url', errors)
3232
expect(errors).to include('header: FFT__a URL: invalid_url inaccessible')
33-
expect(errors).to include('header: FFT__a URL: invalid_url invalid. needs to be .jpg, .pdf, .mp3 or .mp4')
33+
expect(errors).to include('header: FFT__a URL: invalid_url invalid. needs to be .jpg, .pdf, .mp3, .mp4 or .mov')
3434
end
3535
end
3636

@@ -79,7 +79,7 @@
7979
expect(described_class.send(:fft_valid_format?, url)).to be true
8080
end
8181

82-
it 'returns false for a URL not ending with .jpg, .pdf, .mp3, .mp4' do
82+
it 'returns false for a URL not ending with .jpg, .pdf, .mp3, .mp4, .mov' do
8383
url = 'https://example.com/document.txt'
8484
expect(described_class.send(:fft_valid_format?, url)).to be false
8585
end
@@ -93,6 +93,11 @@
9393
url = 'https://example.com/song.mp4'
9494
expect(described_class.send(:fft_valid_format?, url)).to be true
9595
end
96+
97+
it 'returns true for a URL ending with .mov' do
98+
url = 'https://example.com/video.mov'
99+
expect(described_class.send(:fft_valid_format?, url)).to be true
100+
end
96101
end
97102

98103
describe '.valid_500__3?' do

0 commit comments

Comments
 (0)