exports_controller_spec.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Settings::ExportsController do
  4. render_views
  5. describe 'GET #show' do
  6. context 'when signed in' do
  7. let(:user) { Fabricate(:user) }
  8. before do
  9. sign_in user, scope: :user
  10. get :show
  11. end
  12. it 'returns http success with private cache control headers', :aggregate_failures do
  13. expect(response).to have_http_status(200)
  14. expect(response.headers['Cache-Control']).to include('private, no-store')
  15. end
  16. end
  17. context 'when not signed in' do
  18. it 'redirects' do
  19. get :show
  20. expect(response).to redirect_to '/auth/sign_in'
  21. end
  22. end
  23. end
  24. describe 'POST #create' do
  25. before do
  26. sign_in Fabricate(:user), scope: :user
  27. end
  28. it 'redirects to settings_export_path' do
  29. post :create
  30. expect(response).to redirect_to(settings_export_path)
  31. end
  32. it 'queues BackupWorker job by 1' do
  33. expect do
  34. post :create
  35. end.to change(BackupWorker.jobs, :size).by(1)
  36. end
  37. end
  38. end