summaryrefslogtreecommitdiff
path: root/test/models/score_test.rb
blob: a895158d8a7ea233e95aa1e1cf132d14f89527ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require "test_helper"

class ScoreTest < ActiveSupport::TestCase
  def setup
    @score = scores(:one)
  end

  test "should be valid with valid attributes" do
    assert @score.valid?
  end

  test "should have associated tartiflette" do
    @score.tartiflette = nil
    assert_not @score.valid?, "Score has no associated tartiflette."
  end

  test "should have associated scoring_criterium" do
    @score.scoring_criterium = nil
    assert_not @score.valid?, "Score has no associated scoring_criterium."
  end

  test "should have value" do
    @score.value = nil
    assert_not @score.valid?, "Score has no value."
  end

  test "value should be between 1 and 5" do
    @score.value = 3
    assert @score.valid?, "Score value is invalid."
  end

  test "value should be greater than or equal to 1" do
    @score.value = 0
    assert_not @score.valid?, "Score is less than 1."
  end

  test "value should be less than or equal to 5" do
    @score.value = 6
    assert_not @score.valid?, "Score is greater than 5."
  end
end
Copyright 2019--2025 Marius PETER