Sha256: 03561c16e7018b08294d77897a6e9645ccde252e31de6ac8cd8bee29c66cd9f3
Contents?: true
Size: 1.62 KB
Versions: 11
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true require "spec_helper" describe Decidim::Admin::PromoteManagedUser do let(:organization) { create :organization } let!(:current_user) { create :user, :admin, organization: organization } let(:email) { "foo@example.org" } let(:form_params) do { email: email } end let(:form) do Decidim::Admin::ManagedUserPromotionForm.from_params( form_params ).with_context( current_organization: organization ) end let!(:user) { create :user, :managed, organization: organization } subject { described_class.new(form, user, current_user) } context "when everything is ok" do before do clear_enqueued_jobs end it "broadcasts ok" do expect { subject.call }.to broadcast(:ok) end it "user is invited to the application" do subject.call expect(user.reload.email).to eq(form.email) expect(ActionMailer::DeliveryJob).to have_been_enqueued.on_queue("mailers") end end context "when the form is not valid" do before do expect(form).to receive(:invalid?).and_return(true) end it "broadcasts invalid" do expect { subject.call }.to broadcast(:invalid) end end context "when the user is not managed" do let(:user) { create :user, organization: organization } it "broadcasts invalid" do expect { subject.call }.to broadcast(:invalid) end end context "when the email address already exists" do let!(:other_user) { create(:user, email: email, organization: organization) } it "broadcasts invalid" do expect { subject.call }.to broadcast(:invalid) end end end
Version data entries
11 entries across 11 versions & 1 rubygems