Fix document validations specs
This commit is contained in:
@@ -17,8 +17,8 @@ class Document < ActiveRecord::Base
|
||||
validate :validate_attachment_size, if: -> { attachment.present? }
|
||||
validates :title, presence: true
|
||||
validates :user_id, presence: true
|
||||
# validates :documentable_id, presence: true
|
||||
# validates :documentable_type, presence: true
|
||||
validates :documentable_id, presence: true, if: -> { persisted? }
|
||||
validates :documentable_type, presence: true, if: -> { persisted? }
|
||||
|
||||
def validate_attachment_size
|
||||
if documentable.present? &&
|
||||
|
||||
@@ -46,12 +46,14 @@ shared_examples "document validations" do |documentable_factory|
|
||||
end
|
||||
|
||||
it "should not be valid without a documentable_id" do
|
||||
document.save
|
||||
document.documentable_id = nil
|
||||
|
||||
expect(document).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a documentable_type" do
|
||||
document.save
|
||||
document.documentable_type = nil
|
||||
|
||||
expect(document).to_not be_valid
|
||||
|
||||
Reference in New Issue
Block a user