Skip to content

Commit

Permalink
Merge pull request #29 from chonla/main
Browse files Browse the repository at this point in the history
chore: Add tests
  • Loading branch information
chonla authored Oct 29, 2024
2 parents c432f97 + b3302cf commit 945fed2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cdmm/test/controllers/cdmm_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,28 @@ class CdmmControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
test "accessing the cdmm without key will create a draft blank form" do
assert_difference("Evaluation.count") do
get evaluation_index_path

assert_response :redirect
redirect_path = response.location
form_key = redirect_path.split("/").last

ev = Evaluation.find_by(form_key: form_key)
assert_equal "draft", ev.form_status
end
end

test "get existing evaluation" do
get evaluation_show_path(:team_a_form_key)

assert_response :success
end

test "get non-exising evaluation" do
get evaluation_show_path(:no_such_a_form_key)

assert_response :not_found
end
end
14 changes: 14 additions & 0 deletions cdmm/test/controllers/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,18 @@ class HomeControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
test "root access should redirect to cdmm which will create a blank form and redirect to that form path" do
get root_path

# redirect from / to /cdmm
assert_response :redirect
assert_redirected_to evaluation_index_path
follow_redirect!
# redirect from /cdmm to /cdmm/<form-key>
assert_response :redirect
redirect_path = response.location
assert_redirected_to redirect_path
follow_redirect!
assert_response :success
end
end

0 comments on commit 945fed2

Please sign in to comment.