Sha256: 77b41f06bb26d624c09f9990b93bb7fff92b8b4a67e60a60d24eb7003c831191

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Almanac::Comment do
  it "should be possible to create a valid comment" do
    create(:comment)

    expect(Almanac::Comment.all.count).to eq(1)
  end

  it "should not be possible to create a comment without an author_name" do
    build(:comment, author_name: "").should_not be_valid
  end

  it "should not be possible to create a comment without an author_email" do
    build(:comment, author_email: "").should_not be_valid
  end

  it "should not be possible to create a comment without an body" do
    build(:comment, body: "").should_not be_valid
  end

  it "should not be possible to create a comment without a post" do
    build(:comment, post: nil).should_not be_valid
  end

  describe ".spam" do
    it "should return spam comments" do
      comments_count = 10
      spam_comments_count = 5
      post = create(:post_with_comments, comments_count: comments_count)
      create_list(:spam_comment, spam_comments_count, post_id: post.id)
      expect(Almanac::Comment.spam.count).to eq spam_comments_count
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
almanac-0.8.0 spec/models/comment_spec.rb
almanac-0.7.4 spec/models/comment_spec.rb
almanac-0.7.3 spec/models/comment_spec.rb
almanac-0.7.2 spec/models/comment_spec.rb
almanac-0.7.1 spec/models/comment_spec.rb
almanac-0.6.1 spec/models/comment_spec.rb
almanac-0.6.0 spec/models/comment_spec.rb
almanac-0.5.3 spec/models/comment_spec.rb
almanac-0.5.2 spec/models/comment_spec.rb
almanac-0.5.1 spec/models/comment_spec.rb
almanac-0.5.0 spec/models/comment_spec.rb
almanac-0.4.5 spec/models/comment_spec.rb
almanac-0.4.4 spec/models/comment_spec.rb