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