Commit 376510d
Changed files (3)
app
controllers
config
locales
spec
controllers
app/controllers/training_sessions_controller.rb
@@ -1,7 +1,7 @@
require "temporary_storage"
class TrainingSessionsController < ApplicationController
- after_action :allow_google_iframe
+ after_action :allow_google_iframe, only: [:index]
def index
@training_sessions = current_user.training_sessions.
config/locales/en.yml
@@ -48,6 +48,8 @@ en:
login_button: "Login"
register_link: "Create an account"
training_sessions:
+ drive_upload:
+ success: 'Our minions have been summoned to fetch your backup.'
index:
backup_file: 'File'
upload_backup_button: "Upload"
spec/controllers/training_sessions_controller_spec.rb
@@ -26,6 +26,7 @@ describe TrainingSessionsController do
describe "#upload" do
include_context "stronglifts_program"
let(:backup_file) { fixture_file_upload("backup.android.stronglifts") }
+ let(:translation) { I18n.translate("training_sessions.upload.success") }
before :each do
allow(UploadStrongliftsBackupJob).to receive(:perform_later)
@@ -43,8 +44,31 @@ describe TrainingSessionsController do
it "displays a friendly message" do
post :upload, backup: backup_file
- translation = I18n.translate("training_sessions.upload.success")
expect(flash[:notice]).to eql(translation)
end
end
+
+ describe "#drive_upload" do
+ let(:params) { {} }
+ let(:success_message) { I18n.translate("training_sessions.drive_upload.success") }
+
+ before :each do
+ allow(DownloadFromDriveJob).to receive(:perform_later)
+ end
+
+ it "schedules a job to suck down the latest backup from google drive" do
+ post :drive_upload, params
+ expect(DownloadFromDriveJob).to have_received(:perform_later)
+ end
+
+ it "redirects to the dashboard" do
+ post :drive_upload, params
+ expect(response).to redirect_to(dashboard_path)
+ end
+
+ it "displays a success message" do
+ post :drive_upload, params
+ expect(flash[:notice]).to eql(success_message)
+ end
+ end
end