Merge branch 'stable' into develop
This commit is contained in:
commit
f4454f4488
5 changed files with 78 additions and 10 deletions
|
|
@ -200,8 +200,7 @@
|
||||||
= link_to t(".request_export_photos_update"), export_photos_user_path,
|
= link_to t(".request_export_photos_update"), export_photos_user_path,
|
||||||
class: "btn btn-default btn-block"
|
class: "btn btn-default btn-block"
|
||||||
.small-horizontal-spacer
|
.small-horizontal-spacer
|
||||||
= link_to t(".download_export_photos"), download_photos_user_path, method: :post,
|
= link_to t(".download_export_photos"), download_photos_user_path, class: "btn btn-success btn-block"
|
||||||
class: "btn btn-success btn-block"
|
|
||||||
.small-horizontal-spacer
|
.small-horizontal-spacer
|
||||||
%h6
|
%h6
|
||||||
= t(".last_exported_at", timestamp: current_user.exported_photos_at)
|
= t(".last_exported_at", timestamp: current_user.exported_photos_at)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,20 @@
|
||||||
@wip
|
|
||||||
@javascript
|
@javascript
|
||||||
Feature: Download Photos
|
Feature: Download Photos
|
||||||
|
|
||||||
Scenario: Download my photos
|
Scenario: Request my photos
|
||||||
Given I am signed in
|
Given I am signed in
|
||||||
And I click on my name in the header
|
When I click on my name in the header
|
||||||
And I follow "settings"
|
When I follow "Settings"
|
||||||
Then I should be on my account settings page
|
Then I should be on my account settings page
|
||||||
And I follow "download my photos"
|
When I follow "Request my photos"
|
||||||
Then I confirm the alert
|
Then I should see a flash message indicating success
|
||||||
|
And I should see a flash message containing "We are currently processing your photos"
|
||||||
|
|
||||||
|
Scenario: Download my photos
|
||||||
|
Given I am signed in
|
||||||
|
When I did request my photos
|
||||||
|
And I click on my name in the header
|
||||||
|
When I follow "Settings"
|
||||||
|
Then I should be on my account settings page
|
||||||
|
When I follow "Download my photos"
|
||||||
|
Then I should get a zipped file
|
||||||
|
|
|
||||||
|
|
@ -219,3 +219,11 @@ end
|
||||||
When /^I click the sign in button$/ do
|
When /^I click the sign in button$/ do
|
||||||
click_link "Sign in"
|
click_link "Sign in"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^I did request my photos$/ do
|
||||||
|
@me.perform_export_photos!
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should get a zipped file$/ do
|
||||||
|
expect(DownloadHelpers.download).to end_with("zip")
|
||||||
|
end
|
||||||
|
|
|
||||||
40
features/support/download_helpers.rb
Normal file
40
features/support/download_helpers.rb
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Credits goes to Steve Richert
|
||||||
|
# http://collectiveidea.com/blog/archives/2012/01/27/testing-file-downloads-with-capybara-and-chromedriver/
|
||||||
|
module DownloadHelpers
|
||||||
|
TIMEOUT ||= 5
|
||||||
|
PATH ||= Rails.root.join("tmp/downloads")
|
||||||
|
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def downloads
|
||||||
|
Dir[PATH.join("*")]
|
||||||
|
end
|
||||||
|
|
||||||
|
def download
|
||||||
|
wait_for_download
|
||||||
|
downloads.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def download_content
|
||||||
|
wait_for_download
|
||||||
|
File.read(download)
|
||||||
|
end
|
||||||
|
|
||||||
|
def wait_for_download
|
||||||
|
Timeout.timeout(TIMEOUT) do
|
||||||
|
sleep 0.1 until downloaded?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def downloaded?
|
||||||
|
!downloading? && downloads.any?
|
||||||
|
end
|
||||||
|
|
||||||
|
def downloading?
|
||||||
|
downloads.grep(/\.part$/).any?
|
||||||
|
end
|
||||||
|
|
||||||
|
def clear_downloads
|
||||||
|
FileUtils.rm_f(downloads)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -24,7 +24,17 @@ Rails.application.routes.default_url_options[:port] = AppConfig.pod_uri.port
|
||||||
Selenium::WebDriver::Firefox::Binary.path = ENV["FIREFOX_BINARY_PATH"] || Selenium::WebDriver::Firefox::Binary.path
|
Selenium::WebDriver::Firefox::Binary.path = ENV["FIREFOX_BINARY_PATH"] || Selenium::WebDriver::Firefox::Binary.path
|
||||||
|
|
||||||
Capybara.register_driver :selenium do |app|
|
Capybara.register_driver :selenium do |app|
|
||||||
Capybara::Selenium::Driver.new(app, browser: :firefox)
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
||||||
|
# Set the download directory to "tmp/downloads"
|
||||||
|
profile["browser.download.dir"] = DownloadHelpers::PATH.to_s
|
||||||
|
# Save the file instead of opening it
|
||||||
|
profile["browser.download.folderList"] = 2
|
||||||
|
# Hide the download Manager
|
||||||
|
profile["browser.download.manager.showWhenStarting"] = false
|
||||||
|
# Suppress "open with" dialog for zipped files only
|
||||||
|
profile["browser.helperApps.neverAsk.saveToDisk"] = "application/zip"
|
||||||
|
# Start Firefox using our profile
|
||||||
|
Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.register_driver :mobile do |app|
|
Capybara.register_driver :mobile do |app|
|
||||||
|
|
@ -74,4 +84,6 @@ include HelperMethods
|
||||||
Before do
|
Before do
|
||||||
Devise.mailer.deliveries = []
|
Devise.mailer.deliveries = []
|
||||||
page.driver.browser.manage.window.resize_to(1024, 500)
|
page.driver.browser.manage.window.resize_to(1024, 500)
|
||||||
|
# Delete all files in "tmp/downloads"
|
||||||
|
DownloadHelpers.clear_downloads
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue