Sha256: 5488f5673f0a43c8a09bd5865a8ebef91bd9b2d566512f7878be54b25646a84b

Contents?: true

Size: 1.51 KB

Versions: 9

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Assemblies
    module Admin
      describe ExportsController, type: :controller do
        routes { Decidim::Assemblies::AdminEngine.routes }

        let!(:organization) { create(:organization) }
        let!(:assembly) { create :assembly, organization: organization }
        let!(:user) { create(:user, :admin, :confirmed, organization: organization) }
        let!(:feature) { create(:feature, participatory_space: assembly, manifest_name: "dummy") }

        before do
          @request.env["decidim.current_organization"] = organization
          sign_in user, scope: :user
        end

        let(:params) do
          {
            id: "dummies",
            feature_id: feature.id,
            assembly_id: assembly.id
          }
        end

        describe "POST create" do
          context "when a format is provided" do
            it "enqueues a job with the provided format" do
              params[:format] = "csv"

              expect(ExportJob).to receive(:perform_later)
                .with(user, feature, "dummies", "csv")

              post(:create, params: params)
            end
          end

          context "when a format is not provided" do
            it "enqueues a job with the default format" do
              expect(ExportJob).to receive(:perform_later)
                .with(user, feature, "dummies", "json")

              post(:create, params: params)
            end
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-assemblies/spec/controllers/exports_controller_spec.rb
decidim-0.6.7 decidim-assemblies/spec/controllers/exports_controller_spec.rb
decidim-0.6.6 decidim-assemblies/spec/controllers/exports_controller_spec.rb
decidim-0.6.5 decidim-assemblies/spec/controllers/exports_controller_spec.rb
decidim-0.6.4 decidim-assemblies/spec/controllers/exports_controller_spec.rb
decidim-0.6.3 decidim-assemblies/spec/controllers/exports_controller_spec.rb
decidim-0.6.2 decidim-assemblies/spec/controllers/exports_controller_spec.rb
decidim-0.6.1 decidim-assemblies/spec/controllers/exports_controller_spec.rb
decidim-0.6.0 decidim-assemblies/spec/controllers/exports_controller_spec.rb