Sha256: 43d0e90aeb239dd205f98ce4a1bb684fa89521c6250a5d470d735dc0e002296c

Contents?: true

Size: 1.22 KB

Versions: 6

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

6 entries across 6 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.0.8.1 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.0.7 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.0.6 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.0.5 decidim-comments/spec/forms/comment_form_spec.rb
decidim-0.0.4 decidim-comments/spec/forms/comment_form_spec.rb