Add paper validation tests

This commit is contained in:
Lars Henrik Mai 2015-09-27 10:25:40 +02:00
parent 3b4f158ea5
commit d5849c2bea
3 changed files with 19 additions and 4 deletions

View file

@ -5,8 +5,7 @@ class Paper < ActiveRecord::Base
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
validates_presence_of :body, :content, :name, :originator, :paper_type, :reference, :url
validates_presence_of :published_at, allow_nil: true
validates_presence_of :body, :content, :name , :originator, :paper_type, :reference, :url, :published_at
validates :url, uniqueness: true
settings index: { number_of_shards: 1 } do

16
test/models/paper_test.rb Normal file
View file

@ -0,0 +1,16 @@
require 'test_helper'
class PaperTest < ActiveSupport::TestCase
context "Validations" do
should validate_presence_of(:body)
should validate_presence_of(:content)
should validate_presence_of(:name)
should validate_presence_of(:originator)
should validate_presence_of(:paper_type)
should validate_presence_of(:reference)
should validate_presence_of(:url)
should validate_presence_of(:published_at)
end
end

View file

@ -5,7 +5,7 @@ require 'capybara/rails'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# fixtures :all
# Add more helper methods to be used by all tests here...
end