Sha256: ca9e0be3dc043893f6694aa852a4be9d84966a927e256d18c78318870bf2d959

Contents?: true

Size: 1003 Bytes

Versions: 16

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

require "decidim/core/test/factories"

FactoryBot.define do
  factory :comment, class: "Decidim::Comments::Comment" do
    author { build(:user, organization: commentable.organization) }
    commentable { build(:dummy_resource) }
    root_commentable { commentable }
    body { Faker::Lorem.paragraph }

    trait :comment_on_comment do
      author { build(:user, organization: root_commentable.organization) }
      commentable do
        build(
          :comment,
          author: author,
          root_commentable: root_commentable,
          commentable: root_commentable
        )
      end
      root_commentable { build(:dummy_resource) }
    end
  end

  factory :comment_vote, class: "Decidim::Comments::CommentVote" do
    comment { build(:comment) }
    author { build(:user, organization: comment.organization) }
    weight { [-1, 1].sample }

    trait :up_vote do
      weight { 1 }
    end

    trait :down_vote do
      weight { -1 }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-comments-0.22.0 lib/decidim/comments/test/factories.rb
decidim-comments-0.21.0 lib/decidim/comments/test/factories.rb
decidim-comments-0.20.1 lib/decidim/comments/test/factories.rb
decidim-comments-0.20.0 lib/decidim/comments/test/factories.rb
decidim-comments-0.19.1 lib/decidim/comments/test/factories.rb
decidim-comments-0.18.1 lib/decidim/comments/test/factories.rb
decidim-comments-0.19.0 lib/decidim/comments/test/factories.rb
decidim-comments-0.17.2 lib/decidim/comments/test/factories.rb
decidim-comments-0.18.0 lib/decidim/comments/test/factories.rb
decidim-comments-0.17.1 lib/decidim/comments/test/factories.rb
decidim-comments-0.16.1 lib/decidim/comments/test/factories.rb
decidim-comments-0.17.0 lib/decidim/comments/test/factories.rb
decidim-comments-0.16.0 lib/decidim/comments/test/factories.rb
decidim-comments-0.15.2 lib/decidim/comments/test/factories.rb
decidim-comments-0.15.1 lib/decidim/comments/test/factories.rb
decidim-comments-0.15.0 lib/decidim/comments/test/factories.rb