Sha256: 1a2b8bdf062a43990e1fa5365a9e2fc36d5db7ca856a34a1144f9b082f460d97

Contents?: true

Size: 1.79 KB

Versions: 33

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples_for "preview component with share_token" do
  context "when component is unpublished" do
    before do
      component.unpublish!
    end

    context "when no share_token is provided" do
      before do
        visit_component
      end

      it "does not allow visiting component" do
        expect(page).to have_content "You are not authorized"
        # rubocop:disable Capybara/CurrentPathExpectation
        expect(page.current_path).not_to match main_component_path(component)
        # rubocop:enable Capybara/CurrentPathExpectation
      end
    end

    context "when a share_token is provided" do
      let(:share_token) { create(:share_token, token_for: component) }
      let(:params) { { share_token: share_token.token } }

      before do
        uri = URI(main_component_path(component))
        uri.query = URI.encode_www_form(params.to_a)
        visit uri
      end

      context "when a valid share_token is provided" do
        it "allows visiting component" do
          expect(page).not_to have_content "You are not authorized"
          # rubocop:disable Capybara/CurrentPathExpectation
          expect(page.current_path).to match main_component_path(component)
          # rubocop:enable Capybara/CurrentPathExpectation
        end
      end

      context "when an invalid share_token is provided" do
        let(:share_token) { create(:share_token, :expired, token_for: component) }

        it "does not allow visiting component" do
          expect(page).to have_content "You are not authorized"
          # rubocop:disable Capybara/CurrentPathExpectation
          expect(page.current_path).not_to match main_component_path(component)
          # rubocop:enable Capybara/CurrentPathExpectation
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.8 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.7 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.5 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.4 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.3 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.2 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.1 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.0 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.0.rc2 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.26.0.rc1 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.25.2 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.25.1 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.25.0 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.25.0.rc4 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.25.0.rc3 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.25.0.rc2 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.25.0.rc1 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb
decidim-core-0.24.3 lib/decidim/core/test/shared_examples/preview_component_with_share_token_examples.rb