Sha256: fa23dec9d5a67cb6d1ec7ada2ae8c6b05e3cb1d234b45d515b9a2c0a1ff197c0

Contents?: true

Size: 1.1 KB

Versions: 31

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples "versions controller" do
  let(:base_params) do
    if resource.is_a?(Decidim::Participable)
      { "#{resource.model_name.singular_route_key}_slug".to_sym => resource.slug }
    else
      { "#{resource.model_name.singular_route_key}_id".to_sym => resource.id }
    end
  end

  before do
    request.env["decidim.current_organization"] = resource.organization

    if resource.is_a?(Decidim::HasComponent)
      request.env["decidim.current_participatory_space"] = resource.participatory_space
      request.env["decidim.current_component"] = resource.component
    end
  end

  describe "GET show" do
    context "with an existing version" do
      it "returns a HTTP 200" do
        get :show, params: base_params.merge(id: 1)

        expect(response).to have_http_status(:ok)
      end
    end

    context "when the resource does not exist" do
      it "raises a routing error" do
        expect do
          get :show, params: base_params.merge(id: 999_999_999)
        end.to raise_error(ActionController::RoutingError)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

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