[phase-17]Make unit test for GlossaryTerm, add test for GlossaryCategory
This commit is contained in:
parent
e053169ca4
commit
7812879965
31
test/fixtures/glossary_terms.yml
vendored
Normal file
31
test/fixtures/glossary_terms.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
red:
|
||||
id: 1
|
||||
project_id: 1
|
||||
category_id: 1
|
||||
name: red
|
||||
|
||||
green:
|
||||
id: 2
|
||||
project_id: 1
|
||||
category_id: 1
|
||||
name: green
|
||||
created_at: 2018-08-08 18:18:18
|
||||
updated_at: 2018-08-08 18:18:18
|
||||
|
||||
blue:
|
||||
id: 3
|
||||
project_id: 2
|
||||
category_id: 1
|
||||
name: blue
|
||||
created_at: 2018-08-08 18:18:18
|
||||
updated_at: 2018-08-08 18:18:18
|
||||
|
||||
clear:
|
||||
id: 4
|
||||
project_id: 1
|
||||
name: clear
|
||||
created_at: 2018-08-08 18:18:18
|
||||
updated_at: 2018-08-08 18:18:18
|
||||
|
||||
|
||||
|
@ -10,6 +10,6 @@ class GlossaryCategoryTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_valid
|
||||
assert !@category.valid?
|
||||
assert @category.valid?
|
||||
end
|
||||
end
|
||||
|
@ -1,9 +1,21 @@
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class GlossaryTermTest < ActiveSupport::TestCase
|
||||
fixtures :glossary_terms
|
||||
plugin_fixtures :glossary_terms
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
def setup
|
||||
@term = glossary_terms('red')
|
||||
end
|
||||
|
||||
def test_valid
|
||||
assert @term.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_name
|
||||
@term.name = nil
|
||||
assert_raises ActiveRecord::NotNullViolation do
|
||||
@term.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user