Sha256: a820e75bfe61137481c66c782b10c5244da2f87bee6ac9a786cdbe3a3f71edb7

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require "decidim/verifications/workflows"

module Decidim
  module Verifications
    module DummyVerification
      # Dummy engine to be able to test verifications.
      class Engine < ::Rails::Engine
        isolate_namespace Decidim::Verifications::DummyVerification

        paths["lib/tasks"] = nil

        routes do
          root to: proc { [200, {}, ["DUMMY VERIFICATION ENGINE"]] }
          get :edit_authorization, to: proc { [200, {}, ["CONTINUE YOUR VERIFICATION"]] }
        end
      end
    end
  end
end

Decidim::Verifications.register_workflow(:dummy_authorization_workflow) do |workflow|
  workflow.engine = Decidim::Verifications::DummyVerification::Engine
  workflow.expires_in = 1.hour
end

RSpec.configure do |config|
  config.around(:example, :with_authorization_workflows) do |example|
    begin
      previous_workflows = Decidim::Verifications.workflows.dup

      new_workflows = example.metadata[:with_authorization_workflows].map do |name|
        Decidim::Verifications.find_workflow_manifest(name)
      end

      Decidim::Verifications.reset_workflows(*new_workflows)
      Rails.application.reload_routes!

      example.run
    ensure
      Decidim::Verifications.reset_workflows(*previous_workflows)
      Rails.application.reload_routes!
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-dev-0.16.1 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.16.0 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.15.2 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.15.1 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.15.0 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.14.4 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.14.3 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.14.2 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.14.1 lib/decidim/dev/test/rspec_support/authorization.rb