Sha256: b0cc2135778f9aa4557f6f884e41df78878a47d2e6e7eb72873fe66ff887c50e

Contents?: true

Size: 1.26 KB

Versions: 16

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples "accessible static pages" do
  let(:organization) do
    create(
      :organization,
      create_static_pages: false,
      force_users_to_authenticate_before_access_organization: true
    )
  end
  let!(:public_pages) { create_list(:static_page, 5, organization:, allow_public_access: true) }
  let!(:private_pages) { create_list(:static_page, 5, organization:) }
  let(:actual_page_ids) { [] }

  def expect_correct_accessible_static_pages
    expect(actual_page_ids).to match_array(expected_page_ids)
  end

  context "with a user" do
    let(:user) { create(:user, organization:) }
    let(:expected_page_ids) { public_pages.pluck(:id) + private_pages.pluck(:id) }

    it { expect_correct_accessible_static_pages }
  end

  context "without a user" do
    let(:user) { nil }
    let(:expected_page_ids) { public_pages.pluck(:id) }

    it { expect_correct_accessible_static_pages }

    context "when the organization does not force users to authenticate" do
      let(:organization) { create(:organization, create_static_pages: false) }
      let(:expected_page_ids) do
        public_pages.pluck(:id) + private_pages.pluck(:id)
      end

      it { expect_correct_accessible_static_pages }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-core-0.30.0.rc1 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.29.2 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.28.5 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.29.1 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.28.4 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.29.0 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.28.3 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.29.0.rc4 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.29.0.rc3 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.29.0.rc2 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.29.0.rc1 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.28.2 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.28.1 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.28.0 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.28.0.rc5 lib/decidim/core/test/shared_examples/static_pages_examples.rb
decidim-core-0.28.0.rc4 lib/decidim/core/test/shared_examples/static_pages_examples.rb