Sha256: 42fa75b0c91efcc9158347078c49f9f96fa9c227d5903c542d4358bd1ee97ae9

Contents?: true

Size: 1.22 KB

Versions: 20

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Comments
    describe CommentForm do
      let(:body) { "This is a new comment" }
      let(:alignment) { 1 }
      let(:user_group) { create(:user_group, :verified) }
      let(:user_group_id) { user_group.id }

      let(:attributes) do
        {
          "comment" => {
            "body" => body,
            "alignment" => alignment,
            "user_group_id" => user_group_id
          }
        }
      end

      subject do
        described_class.from_params(
          attributes
        )
      end

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

      context "when body is blank" do
        let(:body) { "" }

        it { is_expected.not_to be_valid }
      end

      context "when body is too long" do
        let(:body) { "c" * 1001 }

        it { is_expected.not_to be_valid }
      end

      context "when alignment is not present" do
        let(:alignment) { nil }

        it { is_expected.to be_valid }
      end

      context "when alignment is present and it is different from 0, 1 and -1" do
        let(:alignment) { 2 }

        it { is_expected.not_to be_valid }
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.6.7 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.6.6 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.6.5 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.6.4 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.6.3 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.6.2 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.6.1 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.6.0 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.5.1 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.5.0 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.4.4 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.4.3 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.4.2 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.4.1 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.4.0 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.3.2 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.3.1 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.3.0 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.2.0 decidim-comments/spec/forms/comment_form_spec.rb