Sha256: 6bb414506f66662aa34b0c2851c3649ac05c2970c8e546390f14c7f28d0f8692

Contents?: true

Size: 917 Bytes

Versions: 12

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

shared_examples "an amendment form" do
  let(:title) { "More sidewalks and less roads!" }
  let(:body) { "Everything would be better" }
  let(:emendation_params) do
    {
      title: title,
      body: body
    }
  end

  context "when everything is OK" do
    it { is_expected.to be_valid }
  end

  context "when there's no title" do
    let(:title) { nil }

    it { is_expected.to be_invalid }

    it "only adds errors to this field" do
      subject.valid?
      expect(subject.errors.attribute_names).to eq [:title]
    end
  end

  context "when the title is too long" do
    let(:body) { "A" * 200 }

    it { is_expected.to be_invalid }
  end

  context "when the body is not etiquette-compliant" do
    let(:body) { "A" }

    it { is_expected.to be_invalid }
  end

  context "when there's no body" do
    let(:body) { nil }

    it { is_expected.to be_invalid }
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.5 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.4 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.3 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.2 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.1 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.0 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.0.rc2 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb
decidim-core-0.27.0.rc1 lib/decidim/core/test/shared_examples/amendable/amendment_form_examples.rb