exports_controller_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. end
  11. it 'renders export' do
  12. get :show
  13. export = assigns(:export)
  14. expect(export).to be_instance_of Export
  15. expect(export.account).to eq user.account
  16. expect(response).to have_http_status(200)
  17. end
  18. end
  19. context 'when not signed in' do
  20. it 'redirects' do
  21. get :show
  22. expect(response).to redirect_to '/auth/sign_in'
  23. end
  24. end
  25. end
  26. describe 'POST #create' do
  27. before do
  28. sign_in Fabricate(:user), scope: :user
  29. end
  30. it 'redirects to settings_export_path' do
  31. post :create
  32. expect(response).to redirect_to(settings_export_path)
  33. end
  34. it 'queues BackupWorker job by 1' do
  35. Sidekiq::Testing.fake! do
  36. expect do
  37. post :create
  38. end.to change(BackupWorker.jobs, :size).by(1)
  39. end
  40. end
  41. end
  42. end