Sha256: 15ba6530ce498711181e565eb655e31cbde01be8b0587168166a41dd5f56dcdb

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe Decidim::Admin::ActivateParticipatoryProcessStep do
  let(:process_step) { create :participatory_process_step }

  subject { described_class.new(process_step) }

  context "when the step is nil" do
    let(:process_step) { nil }

    it "is not valid" do
      expect { subject.call }.to broadcast(:invalid)
    end
  end

  context "when the step is active" do
    let(:process_step) { create :participatory_process_step, :active }

    it "is not valid" do
      expect { subject.call }.to broadcast(:invalid)
    end
  end

  context "when the step is not active" do
    let!(:active_step) do
      create :participatory_process_step, :active, participatory_process: process_step.participatory_process
    end

    it "is valid" do
      expect { subject.call }.to broadcast(:ok)
    end

    it "activates it" do
      subject.call
      expect(process_step).to be_active
    end

    it "deactivates the process active steps" do
      subject.call
      active_step.reload
      expect(active_step).not_to be_active
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-admin/spec/commands/activate_participatory_process_step_spec.rb