mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 23:53:15 +01:00
Add paper validation tests
This commit is contained in:
parent
3b4f158ea5
commit
d5849c2bea
3 changed files with 19 additions and 4 deletions
|
@ -5,8 +5,7 @@ class Paper < ActiveRecord::Base
|
||||||
include Elasticsearch::Model
|
include Elasticsearch::Model
|
||||||
include Elasticsearch::Model::Callbacks
|
include Elasticsearch::Model::Callbacks
|
||||||
|
|
||||||
validates_presence_of :body, :content, :name, :originator, :paper_type, :reference, :url
|
validates_presence_of :body, :content, :name , :originator, :paper_type, :reference, :url, :published_at
|
||||||
validates_presence_of :published_at, allow_nil: true
|
|
||||||
validates :url, uniqueness: true
|
validates :url, uniqueness: true
|
||||||
|
|
||||||
settings index: { number_of_shards: 1 } do
|
settings index: { number_of_shards: 1 } do
|
||||||
|
|
16
test/models/paper_test.rb
Normal file
16
test/models/paper_test.rb
Normal 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
|
|
@ -5,7 +5,7 @@ require 'capybara/rails'
|
||||||
|
|
||||||
class ActiveSupport::TestCase
|
class ActiveSupport::TestCase
|
||||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
# 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...
|
# Add more helper methods to be used by all tests here...
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue