blob: 244c07cd50a95df4e8d6f5f6a8519b462020e176 (
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
42
43
44
45
46
47
48
49
|
require "test_helper"
class ScoresControllerTest < ActionDispatch::IntegrationTest
setup do
@tartiflette = tartiflettes(:one)
@criterium = scoring_criteria(:one)
@score = scores(:one)
end
test "should get new score form" do
get new_tartiflette_score_path(@tartiflette)
assert_response :success
assert_select "form"
assert_select "input[type=number][name=?]", "scores[#{@criterium.id}][value]"
end
test "should not create scores with invalid data" do
assert_no_difference("Score.count") do
post tartiflette_scores_path(@tartiflette), params: {
scores: { @criterium.id => { value: nil } }
}
end
assert_response :unprocessable_entity
end
test "should get edit scores form" do
get tartiflette_edit_scores_path(@tartiflette)
assert_response :success
assert_select "form"
assert_select "input[type=number][name=?]", "scores[#{@criterium.id}][value]"
end
test "should update scores for tartiflette" do
patch tartiflette_update_scores_path(@tartiflette), params: {
scores: { @score.id => { value: 5 } }
}
assert_redirected_to root_path
@score.reload
assert_equal 5, @score.value, "Score value should be updated to 5"
end
test "should not update scores with invalid data" do
patch tartiflette_update_scores_path(@tartiflette), params: {
scores: { @score.id => { value: nil } }
}
@score.reload
assert_not_equal nil, @score.value, "Score should not be updated with invalid data"
end
end
|