mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-20 07:21:12 +00:00
detect Chrome downloaded file more strictly
git-svn-id: http://svn.redmine.org/redmine/trunk@18536 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
39101580a9
commit
942eb6e06b
@ -66,15 +66,21 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
|||||||
def downloaded_files(filename='*')
|
def downloaded_files(filename='*')
|
||||||
# https://github.com/SeleniumHQ/selenium/issues/5292
|
# https://github.com/SeleniumHQ/selenium/issues/5292
|
||||||
downloaded_path = Redmine::Platform.mswin? ? DOWNLOADS_PATH : "#{ENV['HOME']}/Downloads"
|
downloaded_path = Redmine::Platform.mswin? ? DOWNLOADS_PATH : "#{ENV['HOME']}/Downloads"
|
||||||
Dir.glob("#{downloaded_path}/#{filename}").reject {|f| f=~/\.(tmp|crdownload)$/}
|
Dir.glob("#{downloaded_path}/#{filename}").
|
||||||
|
reject{|f| f=~/\.(tmp|crdownload)$/}.sort_by{|f| File.mtime(f)}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the path of the download file
|
# Returns the path of the download file
|
||||||
def downloaded_file(filename='*')
|
def downloaded_file(filename='*')
|
||||||
|
files = []
|
||||||
Timeout.timeout(5) do
|
Timeout.timeout(5) do
|
||||||
sleep 0.2 while downloaded_files(filename).empty?
|
loop do
|
||||||
|
files = downloaded_files(filename)
|
||||||
|
break if files.present?
|
||||||
|
sleep 0.2
|
||||||
end
|
end
|
||||||
downloaded_files(filename).first
|
end
|
||||||
|
files.last
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -335,7 +335,9 @@ class IssuesTest < ApplicationSystemTestCase
|
|||||||
click_on 'CSV'
|
click_on 'CSV'
|
||||||
click_on 'Export'
|
click_on 'Export'
|
||||||
|
|
||||||
csv = CSV.read(downloaded_file("issues.csv"))
|
# https://github.com/SeleniumHQ/selenium/issues/5292
|
||||||
|
# if issues.csv exists, Chrome creates issues (1).csv, issues (2).csv ...
|
||||||
|
csv = CSV.read(downloaded_file("issues*.csv"))
|
||||||
subject_index = csv.shift.index('Subject')
|
subject_index = csv.shift.index('Subject')
|
||||||
subjects = csv.map {|row| row[subject_index]}
|
subjects = csv.map {|row| row[subject_index]}
|
||||||
assert_equal subjects.sort, subjects
|
assert_equal subjects.sort, subjects
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user