Sha256: 6efec80d019320052024450444760815ae8229168dd34e9dfe8eeda50d0c2f6d

Contents?: true

Size: 1.18 KB

Versions: 45

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

shared_examples_for "a scopable resource" do
  before do
    current_component.update!(settings: { scopes_enabled: true, scope_id: parent_scope.id })
  end

  context "when the scope exists" do
    it { expect(form.scope).to be_kind_of(Decidim::Scope) }
  end

  context "when the scope does not exist" do
    let(:scope_id) { 3456 }

    it { expect(form.scope).to eq(nil) }
  end

  context "when the scope is from another organization" do
    let(:scope_id) { create(:scope).id }

    it { expect(form.scope).to eq(nil) }
  end

  context "when the component has a scope" do
    context "when the scope is descendant from component scope" do
      let(:scope) { create(:scope, organization: organization, parent: parent_scope) }

      it { expect(form.scope).to eq(scope) }
    end

    context "when the scope is not descendant from component scope" do
      let(:another_scope) { create(:scope, organization: organization) }
      let(:scope) { create(:subscope, parent: another_scope) }
      let(:scope_id) { scope.id }

      it { expect(form.scope).to eq(scope) }

      it "makes the form invalid" do
        expect(form).to be_invalid
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.5 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.26.8 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.4 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.3 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.26.7 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.26.5 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.2 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.1 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.26.4 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.0 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.26.3 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.0.rc2 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.27.0.rc1 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb
decidim-core-0.26.2 lib/decidim/core/test/shared_examples/scopable_resource_examples.rb