Sha256: 5b7cf24686413ca085ab92ed78a13054d6ffade626bd72e86a37ebb56882c237
Contents?: true
Size: 1.48 KB
Versions: 11
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require "spec_helper" describe Decidim::Admin::CreateScope do let(:organization) { create :organization } let(:name) { Decidim::Faker::Localized.literal(Faker::Address.unique.state) } let(:code) { Faker::Address.unique.state_abbr } let(:scope_type) { create :scope_type } let(:form) do double( invalid?: invalid, name: name, organization: organization, code: code, scope_type: scope_type ) end let(:invalid) { false } subject { described_class.new(form) } context "when the form is not valid" do let(:invalid) { true } it "is not valid" do expect { subject.call }.to broadcast(:invalid) end end context "when the form is valid" do it "broadcasts ok" do expect { subject.call }.to broadcast(:ok) end it "creates a new scope for the organization" do expect { subject.call }.to change { organization.scopes.count }.by(1) end end context "when its a child scope" do let!(:parent_scope) { create :scope, organization: organization } subject { described_class.new(form, parent_scope) } it "broadcasts ok" do expect { subject.call }.to broadcast(:ok) end it "creates a new scope for the organization" do expect { subject.call }.to change { organization.scopes.count }.by(1) end it "creates a child scope for the parent scope" do expect { subject.call }.to change { parent_scope.children.count }.by(1) end end end
Version data entries
11 entries across 11 versions & 1 rubygems