Sha256: 6f5d4465af86021b0a26d7e842db6acb2236e0e9c7704587d99b6f8a1a4a9844

Contents?: true

Size: 1.09 KB

Versions: 34

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

shared_context "with controller rendering the view" do
  # Fix "No route matches" errors with the view.
  before do
    controller.view_context_class.class_eval do
      # Needed for the form_for to work (through decidim_form_for)
      # The path shouldn't matter in the controller specs.
      def polymorphic_path(_record, _options)
        "/"
      end

      # Needed for the head and link_to helpers to work
      # The URL shouldn't matter in the controller specs.
      def url_for(_options)
        "/"
      end
    end
  end

  after do
    # Ensure that the customized view context class is not being kept in the
    # cache variable. Otherwise we might mess up the following specs using the
    # same controller in the same run.
    controller.class.remove_instance_variable(:@view_context_class)
  end

  # Rendering of the view is necessary to see the view renders correctly
  # when there are errors on the form. This is hard to test with a
  # system test because there is some JS blocking us to submit the form
  # with errors (e.g. too short title).
  render_views
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.5 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.26.8 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.4 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.3 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.26.7 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.26.5 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.2 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.1 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.26.4 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.0 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.26.3 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.0.rc2 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.27.0.rc1 lib/decidim/core/test/shared_examples/controller_render_views.rb
decidim-core-0.26.2 lib/decidim/core/test/shared_examples/controller_render_views.rb