Sha256: 43b792c74df687247dd9e3004bf337b5b177a0f1608bcb977ee7be95890e2ebe
Contents?: true
Size: 1.6 KB
Versions: 12
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true require "spec_helper" module Decidim module Admin shared_examples_for "category form" do subject do described_class.from_params( attributes ).with_context( current_participatory_space: participatory_space, current_organization: organization ) end let(:name) do { en: "Name", es: "Nombre", ca: "Nom" } end let(:parent_id) { nil } let(:attributes) do { "category" => { "name_en" => name[:en], "name_es" => name[:es], "name_ca" => name[:ca], "parent_id" => parent_id } } end let(:organization) { create :organization } context "when everything is OK" do it { is_expected.to be_valid } end context "when default language in name is missing" do let(:name) do { ca: "Nom", es: "Nombre" } end it { is_expected.to be_invalid } end context "when the parent_id is set" do let!(:category) { create :category, participatory_space: participatory_space } context "and it is set to a first-class category" do let(:parent_id) { category.id } it { is_expected.to be_valid } end context "and it is set to a subcategory" do let!(:subcategory) { create :subcategory, parent: category } let(:parent_id) { subcategory.id } it { is_expected.not_to be_valid } end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems