Sha256: 1ce006db4d522670415215742db80c1c8f287272f24bc1b260e2679c596a9305

Contents?: true

Size: 1.98 KB

Versions: 8

Compression:

Stored size: 1.98 KB

Contents

# frozen_string_literal: true

shared_context "with a component" do
  let(:manifest) { Decidim.find_component_manifest(manifest_name) }

  let(:user) { create :user, :confirmed, organization: organization }

  let!(:organization) { create(:organization, available_authorizations: %w(dummy_authorization_handler another_dummy_authorization_handler)) }

  let(:participatory_process) do
    create(:participatory_process, :with_steps, organization: organization)
  end

  let(:participatory_space) { participatory_process }

  let!(:component) do
    create(:component,
           manifest: manifest,
           participatory_space: participatory_space)
  end

  let!(:category) { create :category, participatory_space: participatory_space }
  let!(:scope) { create :scope, organization: organization }

  before do
    switch_to_host(organization.host)
  end

  def visit_component
    page.visit main_component_path(component)
  end
end

shared_context "when managing a component" do
  include_context "with a component"

  let(:current_component) { component }

  before do
    login_as user, scope: :user
    visit_component_admin
  end

  def visit_component_admin
    visit manage_component_path(component)
  end

  # Returns the config path for a given component.
  #
  # component - the Component we want to find the root path for.
  #
  # Returns a url.
  def edit_component_path(component)
    Decidim::EngineRouter.admin_proxy(component.participatory_space).edit_component_path(component.id)
  end
end

shared_context "when managing a component as an admin" do
  include_context "when managing a component"

  let(:user) do
    create :user,
           :admin,
           :confirmed,
           organization: organization
  end
end

shared_context "when managing a component as a process admin" do
  include_context "when managing a component"

  let(:user) do
    create :process_admin,
           :confirmed,
           organization: organization,
           participatory_process: participatory_process
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-dev-0.23.6 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.23.5 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.23.4 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.23.3 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.23.2 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.23.1 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.23.1.rc1 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.23.0 lib/decidim/dev/test/rspec_support/component_context.rb