# frozen_string_literal: true # == Schema Information # # Table name: comments # # id :integer not null, primary key # anonymous :boolean default(FALSE) # body :string not null # deletion_reason :string default(""), not null # destroyed_content :boolean default(FALSE) # edit_reason :string # edited_at :datetime # hidden_from_users :boolean default(FALSE), not null # ip :inet # name_at_post_time :string # referrer :string default("") # show_staff_tag :boolean default(FALSE), not null # tripcode :text # user_agent :string default("") # created_at :datetime not null # updated_at :datetime not null # deleted_by_id :integer # post_id :integer # user_id :integer # # Indexes # # index_comments_on_created_at (created_at) # index_comments_on_deleted_by_id (deleted_by_id) WHERE (deleted_by_id IS NOT NULL) # index_comments_on_post_id (post_id) # index_comments_on_user_id (user_id) # # Foreign Keys # # fk_rails_... (deleted_by_id => users.id) ON DELETE => nullify ON UPDATE => cascade # fk_rails_... (post_id => posts.id) # fk_rails_... (user_id => users.id) ON DELETE => nullify ON UPDATE => cascade # require 'rails_helper' RSpec.describe Comment do it 'should be valid with valid attributes' do comment = build(:comment) expect(comment).to be_valid end it 'should be invalid with no post' do comment = build(:comment) comment.post = nil expect(comment).to_not be_valid end it 'should be invalid with no body' do comment = build(:comment) comment.body = nil expect(comment).to_not be_valid end it 'should be invalid with a blank body' do comment = build(:comment) comment.body = " \t\t\n \r\n " expect(comment).to_not be_valid end end