Sha256: fdc51730561f3b9b573fe6f0de88ac3a15151920035abf21f6319bdb0b10e310

Contents?: true

Size: 1.99 KB

Versions: 18

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

require "spec_helper"

# users of this test should delare the `subject` variable.
shared_examples "with endorsable permissions can perform actions related to endorsable" do
  let(:action_subject) { :endorsement }
  let(:resource) { create :dummy_resource, component: component }
  before do
    context[:current_settings] = double(current_settings)
    context[:resource] = resource
  end

  describe "endorsing" do
    describe "when endorsing" do
      let(:action_name) { :create }

      context "when endorsements are disabled" do
        let(:current_settings) do
          {
            endorsements_enabled: false,
            endorsements_blocked: false
          }
        end

        it { is_expected.to eq false }
      end

      context "when endorsements are blocked" do
        let(:current_settings) do
          {
            endorsements_enabled: true,
            endorsements_blocked: true
          }
        end

        it { is_expected.to eq false }
      end

      context "when user is authorized" do
        let(:current_settings) do
          {
            endorsements_enabled: true,
            endorsements_blocked: false
          }
        end

        it { is_expected.to eq true }
      end
    end
  end

  describe "unendorsing" do
    let(:action_name) { :unendorse }

    context "when endorsements are disabled" do
      let(:current_settings) do
        {
          endorsements_enabled: false,
          endorsements_blocked: false
        }
      end

      it { is_expected.to eq false }
    end

    context "when endorsements are blocked" do
      let(:current_settings) do
        {
          endorsements_enabled: true,
          endorsements_blocked: true
        }
      end

      it { is_expected.to eq false }
    end

    context "when user is authorized" do
      let(:current_settings) do
        {
          endorsements_enabled: true,
          endorsements_blocked: false
        }
      end

      it { is_expected.to eq true }
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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