From 0ed0d346823a4bb64e0e41277910d849056dcad3 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 2 Jul 2022 14:51:25 +0200 Subject: [PATCH] Add tests for `ExportController#create` --- .../settings/export_controller_spec.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/controllers/settings/export_controller_spec.rb b/spec/controllers/settings/export_controller_spec.rb index cebff68f..f0a8ce43 100644 --- a/spec/controllers/settings/export_controller_spec.rb +++ b/spec/controllers/settings/export_controller_spec.rb @@ -17,4 +17,24 @@ describe Settings::ExportController, type: :controller do end end end + + describe "#create" do + subject { post :create } + + context "user signed in" do + let(:user) { FactoryBot.create(:user) } + + before { sign_in user } + + it "enqueues an ExportWorker job" do + subject + expect(ExportWorker).to have_enqueued_sidekiq_job(user.id) + end + + it "redirects to the export page" do + subject + expect(response).to redirect_to(:settings_export) + end + end + end end