Sha256: b60650adf335504c7d86e293cdad52cbd8a595b7c03c379ec4a57af578e29cf3

Contents?: true

Size: 1.63 KB

Versions: 5

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

shared_context "with menu hacks params" do
  let(:organization) { create(:organization) }
  let(:context) do
    {
      current_user: create(:user, organization: organization),
      current_organization: organization
    }
  end
  let(:params) do
    {
      raw_label: label,
      url: url,
      position: position,
      target: target,
      visibility: visibility
    }
  end
  let(:attributes) do
    {
      "label" => label,
      "url" => url,
      "position" => position,
      "target" => target,
      "visibility" => visibility
    }
  end
  let(:label) do
    {
      "en" => "Menu english",
      "ca" => "Menu catalan"
    }
  end
  let(:url) { "/some-path" }
  let(:position) { 2 }
  let(:target) { "_blank" }
  let(:visibility) { "hidden" }
  let(:menu_name) { "menu" }

  let(:another_params) do
    {
      allow_images_in_full_editor: true,
      allow_images_in_small_editor: true
    }
  end
  let(:form) do
    Decidim::DecidimAwesome::Admin::MenuForm.from_params(params).with_context(context)
  end
  let(:another_form) do
    Decidim::DecidimAwesome::Admin::ConfigForm.from_params(another_params).with_context(context)
  end
  let(:another_config) { Decidim::DecidimAwesome::Admin::UpdateConfig.new(another_form) }
end

shared_examples "forbids disabled feature" do
  let(:feature) { :menu }
  let(:features) { [feature] }
  before do
    features.each do |feat|
      allow(Decidim::DecidimAwesome.config).to receive(feat).and_return(:disabled)
    end
  end

  it "redirects with error" do
    action

    expect(flash[:alert]).not_to be_empty
    expect(response).to redirect_to("/admin/")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.7.2 lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb
decidim-decidim_awesome-0.7.0 lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb
decidim-decidim_awesome-0.6.7 lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb
decidim-decidim_awesome-0.6.6 lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb
decidim-decidim_awesome-0.6.5 lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb