Sha256: 0aa2cf2ce16b55d3f6a96ff8ee388aa0f1d5153581365cfbb7cc9559b7fddfa1

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples "scope helpers" do
  let(:organization) { create(:organization) }
  let(:scopes_enabled) { true }
  let(:participatory_space_scope) { nil }
  let(:feature) { create(:feature, manifest_name: "dummy", participatory_space: participatory_space) }
  let(:scope) { create(:scope, organization: organization) }
  let(:resource) { create(:dummy_resource, feature: feature, scope: scope) }

  subject { helper.has_visible_scopes?(resource) }

  before do
    allow(helper).to receive(:current_participatory_space).and_return(participatory_space)
  end

  describe "has_visible_scopes?" do
    context "when all conditions are met" do
      it { is_expected.to be_truthy }
    end

    context "when the process has not scope enabled" do
      let(:scopes_enabled) { false }
      it { is_expected.to be_falsey }
    end

    context "when the process has a scope" do
      let(:participatory_space_scope) { create(:scope, organization: organization) }
      it { is_expected.to be_falsey }
    end

    context "when the resource has not a scope" do
      let(:scope) { nil }
      it { is_expected.to be_falsey }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.8.4 lib/decidim/core/test/shared_examples/scope_helper_examples.rb
decidim-core-0.8.3 lib/decidim/core/test/shared_examples/scope_helper_examples.rb
decidim-core-0.8.2 lib/decidim/core/test/shared_examples/scope_helper_examples.rb
decidim-core-0.8.1 lib/decidim/core/test/shared_examples/scope_helper_examples.rb
decidim-core-0.8.0 lib/decidim/core/test/shared_examples/scope_helper_examples.rb