diff options
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/export_user_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/workers/export_user_spec.rb b/spec/workers/export_user_spec.rb new file mode 100644 index 000000000..f6ecfba55 --- /dev/null +++ b/spec/workers/export_user_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Workers::ExportUser do + + before do + allow(User).to receive(:find).with(alice.id).and_return(alice) + end + + it 'calls export! on user with given id' do + expect(alice).to receive(:perform_export!) + Workers::ExportUser.new.perform(alice.id) + end + + it 'sends a success message when the export is successful' do + alice.stub(:export).and_return(OpenStruct.new) + expect(ExportMailer).to receive(:export_complete_for).with(alice) + Workers::ExportUser.new.perform(alice.id) + end + + it 'sends a failure message when the export fails' do + alice.stub(:export).and_return(nil) + expect(alice).to receive(:perform_export!).and_return(false) + expect(ExportMailer).to receive(:export_failure_for).with(alice) + Workers::ExportUser.new.perform(alice.id) + end +end |