Sha256: e490e9ea05e2a84868c19164bf9f69400bb5ee7dce82cd33c79677723dc6e5fc

Contents?: true

Size: 1.72 KB

Versions: 20

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Admin
    describe ExportJob do
      let!(:feature) { create(:feature, manifest_name: "dummy") }
      let(:organization) { feature.organization }
      let!(:user) { create(:user, organization: organization) }

      it "sends an email with the result of the export" do
        ExportJob.perform_now(user, feature, "dummies", "csv")

        email = last_email
        expect(email.subject).to include("dummies")
        attachment = email.attachments.first

        expect(attachment.read.length).to be_positive
        expect(attachment.mime_type).to eq("application/zip")
        expect(attachment.filename).to match(/^dummies-[0-9]+-[0-9]+-[0-9]+-[0-9]+\.zip$/)
      end

      describe "CSV" do
        it "uses the CSV exporter" do
          export_data = double

          expect(Decidim::Exporters::CSV)
            .to(receive(:new).with(anything, DummySerializer))
            .and_return(double(export: export_data))

          expect(ExportMailer)
            .to(receive(:export).with(user, anything, export_data))
            .and_return(double(deliver_now: true))

          ExportJob.perform_now(user, feature, "dummies", "csv")
        end
      end

      describe "JSON" do
        it "uses the JSON exporter" do
          export_data = double

          expect(Decidim::Exporters::JSON)
            .to(receive(:new).with(anything, DummySerializer))
            .and_return(double(export: export_data))

          expect(ExportMailer)
            .to(receive(:export).with(user, anything, export_data))
            .and_return(double(deliver_now: true))

          ExportJob.perform_now(user, feature, "dummies", "json")
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.6.7 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.6.6 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.6.5 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.6.4 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.6.3 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.6.2 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.6.1 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.6.0 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.5.1 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.5.0 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.4.4 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.4.3 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.4.2 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.4.1 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.4.0 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.3.2 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.3.1 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.3.0 decidim-admin/spec/jobs/export_job_spec.rb
decidim-0.2.0 decidim-admin/spec/jobs/export_job_spec.rb