Sha256: 8620f3cccafcff97f7234077b91bb500d7fd51c9a103f95bdc37cfdff46bdce4

Contents?: true

Size: 1.79 KB

Versions: 20

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Decidim::Admin::VerifyUserGroup do
  let(:organization) { create :organization }

  describe "User group validation is pending" do
    let!(:user_group) { create(:user_group, users: [create(:user, organization: organization)]) }

    subject { described_class.new(user_group) }

    context "when the command is not valid" do
      let(:invalid) { true }

      it "broadcast invalid in return" do
        expect(user_group).to receive(:valid?).and_return(false)
        expect { subject.call }.to broadcast(:invalid)

        expect(user_group.rejected_at).to be_nil
        expect(user_group.verified_at).to be_nil
      end
    end

    context "when the command is valid" do
      it "the user group is rejected" do
        expect { subject.call }.to broadcast(:ok)

        expect(user_group.rejected_at).to be_nil
        expect(user_group.verified_at).not_to be_nil
      end
    end
  end

  describe "User group is already rejected" do
    let!(:user_group) { create(:user_group, rejected_at: Time.current, users: [create(:user, organization: organization)]) }

    subject { described_class.new(user_group) }

    context "when the command is not valid" do
      let(:invalid) { true }

      it "broadcast invalid in return and do not clean rejected_at" do
        expect(user_group).to receive(:valid?).and_return(false)
        expect { subject.call }.to broadcast(:invalid)

        expect(user_group.rejected_at).not_to be_nil
        expect(user_group.verified_at).to be_nil
      end
    end

    context "when the command is valid" do
      it "the user group is verified" do
        expect { subject.call }.to broadcast(:ok)

        expect(user_group.rejected_at).to be_nil
        expect(user_group.verified_at).not_to be_nil
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

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