Sha256: b86a3c0e65be70ac842f65ed99800641542ec1ee7aedaf7086a5d4f766239ae4

Contents?: true

Size: 1.42 KB

Versions: 59

Compression:

Stored size: 1.42 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"]] }
          get :renew_authorization, to: proc { [200, {}, ["RENEW 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
  workflow.renewable = true
  workflow.time_between_renewals = 5.minutes
end

RSpec.configure do |config|
  config.around(:example, :with_authorization_workflows) do |example|
    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

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
decidim-dev-0.29.1 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.28.4 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.27.9 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.29.0 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.28.3 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.27.8 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.29.0.rc4 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.29.0.rc3 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.29.0.rc2 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.29.0.rc1 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.28.2 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.27.7 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.28.1 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.27.6 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.26.10 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.26.9 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.28.0 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.27.5 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.28.0.rc5 lib/decidim/dev/test/rspec_support/authorization.rb
decidim-dev-0.28.0.rc4 lib/decidim/dev/test/rspec_support/authorization.rb