2018-12-13 02:53:52 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-11 22:00:43 +02:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Settings::ExportsController do
|
2017-04-13 13:02:02 +02:00
|
|
|
render_views
|
|
|
|
|
2017-04-11 22:00:43 +02:00
|
|
|
describe 'GET #show' do
|
2017-05-29 18:08:26 +02:00
|
|
|
context 'when signed in' do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in user, scope: :user
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders export' do
|
|
|
|
get :show
|
|
|
|
|
|
|
|
export = assigns(:export)
|
|
|
|
expect(export).to be_instance_of Export
|
|
|
|
expect(export.account).to eq user.account
|
2018-04-21 21:35:07 +02:00
|
|
|
expect(response).to have_http_status(200)
|
2017-05-29 18:08:26 +02:00
|
|
|
end
|
|
|
|
end
|
2017-04-13 13:02:02 +02:00
|
|
|
|
2017-05-29 18:08:26 +02:00
|
|
|
context 'when not signed in' do
|
|
|
|
it 'redirects' do
|
|
|
|
get :show
|
|
|
|
expect(response).to redirect_to '/auth/sign_in'
|
|
|
|
end
|
2017-04-11 22:00:43 +02:00
|
|
|
end
|
|
|
|
end
|
2018-12-13 02:53:52 +01:00
|
|
|
|
|
|
|
describe 'POST #create' do
|
|
|
|
before do
|
|
|
|
sign_in Fabricate(:user), scope: :user
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to settings_export_path' do
|
|
|
|
post :create
|
|
|
|
expect(response).to redirect_to(settings_export_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'queues BackupWorker job by 1' do
|
|
|
|
Sidekiq::Testing.fake! do
|
|
|
|
expect do
|
|
|
|
post :create
|
|
|
|
end.to change(BackupWorker.jobs, :size).by(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-04-11 22:00:43 +02:00
|
|
|
end
|