Sha256: da6348607e940df2b4c4bde593cea24b279381bebe508e2f4080a94511db581c

Contents?: true

Size: 1.98 KB

Versions: 11

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_process }

  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

11 entries across 11 versions & 1 rubygems

Version Path
decidim-dev-0.22.0 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.21.0 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.20.1 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.20.0 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.19.1 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.18.1 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.19.0 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.17.2 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.18.0 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.17.1 lib/decidim/dev/test/rspec_support/component_context.rb
decidim-dev-0.17.0 lib/decidim/dev/test/rspec_support/component_context.rb