Skip to content

Commit

Permalink
Convert settings/exports controller spec to system/request specs (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored Sep 19, 2024
1 parent 2946a92 commit 5a8f2fe
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 47 deletions.
47 changes: 0 additions & 47 deletions spec/controllers/settings/exports_controller_spec.rb

This file was deleted.

25 changes: 25 additions & 0 deletions spec/requests/settings/exports_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'Settings / Exports' do
context 'when not signed in' do
describe 'GET /settings/export' do
it 'redirects to sign in page' do
get settings_export_path

expect(response)
.to redirect_to new_user_session_path
end
end

describe 'POST /settings/export' do
it 'redirects to sign in page' do
post settings_export_path

expect(response)
.to redirect_to new_user_session_path
end
end
end
end
40 changes: 40 additions & 0 deletions spec/system/settings/exports_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'Export page' do
let(:user) { Fabricate :user }

before { sign_in user }

describe 'Viewing the export page' do
context 'when signed in' do
it 'shows the export page', :aggregate_failures do
visit settings_export_path

expect(page)
.to have_content(takeout_summary)
.and have_private_cache_control
end
end
end

describe 'Creating a new archive' do
it 'queues a worker and redirects' do
visit settings_export_path

expect { request_archive }
.to change(BackupWorker.jobs, :size).by(1)
expect(page)
.to have_content(takeout_summary)
end

def request_archive
click_on I18n.t('exports.archive_takeout.request')
end
end

def takeout_summary
I18n.t('settings.export')
end
end

0 comments on commit 5a8f2fe

Please sign in to comment.