summaryrefslogtreecommitdiff
path: root/test/controllers/scores_controller_test.rb
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-01-01 17:56:38 +0100
committerMarius Peter <marius.peter@tutanota.com>2025-01-01 17:56:38 +0100
commit75ab5498ca90bc3e3b4fecd3103dec2c0c089039 (patch)
treebfee31911ab621f4f410f435b2a9801d05795997 /test/controllers/scores_controller_test.rb
parent24fc1ac1c4bbb3e9630357b8c845698b420881af (diff)
Updated tests.
Diffstat (limited to 'test/controllers/scores_controller_test.rb')
-rw-r--r--test/controllers/scores_controller_test.rb45
1 files changed, 12 insertions, 33 deletions
diff --git a/test/controllers/scores_controller_test.rb b/test/controllers/scores_controller_test.rb
index 8fb4cb8..6a6bc9a 100644
--- a/test/controllers/scores_controller_test.rb
+++ b/test/controllers/scores_controller_test.rb
@@ -2,9 +2,9 @@ require "test_helper"
class ScoresControllerTest < ActionDispatch::IntegrationTest
setup do
- @tartiflette = Tartiflette.create!(scoring_id: 1)
- @criterium = ScoringCriterium.create!(name: "Taste", category: "Flavor")
- @score = Score.create!(tartiflette: @tartiflette, scoring_criterium: @criterium, value: 4)
+ @tartiflette = tartiflettes(:one)
+ @criterium = scoring_criteria(:one)
+ @score = scores(:one)
end
test "should get new score form" do
@@ -14,26 +14,6 @@ class ScoresControllerTest < ActionDispatch::IntegrationTest
assert_select "select[name=?]", "scores[#{@criterium.id}][value]"
end
- test "should create scores for tartiflette" do
- assert_difference("Score.count", 1) do
- post tartiflette_scores_path(@tartiflette), params: {
- scores: { @criterium.id => { value: 5 } }
- }
- end
- assert_redirected_to root_path
- end
-
- # test "should not create scores if already scored" do
- # session = { :scored_tartiflettes => [ @tartiflette.id ] }
- # assert_no_difference("Score.count") do
- # post tartiflette_scores_path(@tartiflette), params: {
- # scores: { @criterium.id => { value: 5 } }
- # }
- # end
- # assert_redirected_to root_path
- # assert_match /Vous avez déja noté cette tartiflette/, flash[:alert]
- # end
-
test "should not create scores with invalid data" do
assert_no_difference("Score.count") do
post tartiflette_scores_path(@tartiflette), params: {
@@ -52,19 +32,18 @@ class ScoresControllerTest < ActionDispatch::IntegrationTest
test "should update scores for tartiflette" do
patch tartiflette_update_scores_path(@tartiflette), params: {
- scores: { @score.id => { value: 3 } }
+ scores: { @score.id => { value: 5 } }
}
assert_redirected_to root_path
@score.reload
- assert_equal 3, @score.value
+ 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
- # assert_redirected_to tartiflette_edit_scores_path(@tartiflette)
- # 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
Copyright 2019--2025 Marius PETER