Sha256: 0fc40b779d42c5682765801dd881d9ab5010e532553a4213c7102ef8772053bc
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
# frozen_string_literal: true require "spec_helper" describe Decidim::Admin::RejectUserGroup 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.verified_at).to be_nil expect(user_group.rejected_at).not_to be_nil end end end describe "User group is already rejected" do let!(:user_group) { create(:user_group, verified_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 verified_at" do expect(user_group).to receive(:valid?).and_return(false) expect { subject.call }.to broadcast(:invalid) expect(user_group.verified_at).not_to be_nil expect(user_group.rejected_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.verified_at).to be_nil expect(user_group.rejected_at).not_to be_nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-0.2.0 | decidim-admin/spec/commands/reject_user_group_spec.rb |