Sha256: ceb83229b8a396559d4184678a771830f74c39a12828e0f6621751fbb6cd1e4f

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Admin
    shared_examples_for "attachment collection form" do
      let(:name) do
        {
          en: "My attachment collection",
          es: "Mi colección de adjuntos",
          ca: "La meva colecció d'adjunts"
        }
      end
      let(:description) do
        {
          en: "My attachment collection description",
          es: "Descripción de mi colección de adjuntos",
          ca: "Descripció de la meva colecció d'adjunts"
        }
      end

      let(:attributes) do
        {
          "attachment_collection" => {
            "name_en" => name[:en],
            "name_es" => name[:es],
            "name_ca" => name[:ca],
            "description_en" => description[:en],
            "description_es" => description[:es],
            "description_ca" => description[:ca]
          }
        }
      end
      let(:organization) { create :organization }

      subject do
        described_class.from_params(
          attributes
        ).with_context(
          collection_for: collection_for,
          current_organization: organization
        )
      end

      context "with correct data" do
        it "is valid" do
          expect(subject).to be_valid
        end
      end

      context "when default language in name is missing" do
        let(:name) do
          {
            es: "Mi colección de adjuntos",
            ca: "La meva colecció d'adjunts"
          }
        end

        it { is_expected.to be_invalid }
      end

      context "when some language in description is missing" do
        let(:description) do
          {
            ca: "Descripció de la meva colecció d'adjunts"
          }
        end

        it { is_expected.to be_invalid }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-admin-0.10.1 lib/decidim/admin/test/forms/attachment_collection_form_examples.rb
decidim-admin-0.10.0 lib/decidim/admin/test/forms/attachment_collection_form_examples.rb