From dbf61f4fc3c91d64dd2724c613e515692797c4d2 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 13 Apr 2025 08:17:36 +0200 Subject: [PATCH] Use _path in all cases where we are not potentially changing the domain --- app/controllers/concerns/authentication.rb | 2 +- .../cards/assignments_controller_test.rb | 6 +++--- .../cards/closures_controller_test.rb | 8 ++++---- .../comments/reactions_controller_test.rb | 6 +++--- .../cards/comments_controller_test.rb | 6 +++--- .../cards/engagements_controller_test.rb | 8 ++++---- .../cards/goldnesses_controller_test.rb | 8 ++++---- .../cards/previews_controller_test.rb | 2 +- .../cards/readings_controller_test.rb | 2 +- .../cards/taggings_controller_test.rb | 6 +++--- test/controllers/cards_controller_test.rb | 20 +++++++++---------- .../involvements_controller_test.rb | 2 +- .../collections/workflows_controller_test.rb | 2 +- .../collections_controller_test.rb | 14 ++++++------- test/controllers/events_controller_test.rb | 4 ++-- test/controllers/filters_controller_test.rb | 4 ++-- .../controllers/first_runs_controller_test.rb | 6 +++--- test/controllers/my/pins_controller_test.rb | 2 +- .../mark_all_reads_controller_test.rb | 2 +- .../notifications/trays_controller_test.rb | 2 +- test/controllers/recovers_controller_test.rb | 2 +- .../sessions/transfers_controller_test.rb | 4 ++-- test/controllers/sessions_controller_test.rb | 18 ++++++++--------- test/controllers/uploads_controller_test.rb | 4 ++-- .../users/roles_controller_test.rb | 4 ++-- test/controllers/users_controller_test.rb | 6 +++--- test/integration/card_messages.rb | 10 +++++----- test/test_helpers/session_test_helper.rb | 4 ++-- 28 files changed, 82 insertions(+), 82 deletions(-) diff --git a/app/controllers/concerns/authentication.rb b/app/controllers/concerns/authentication.rb index b097025c0..68e729f02 100644 --- a/app/controllers/concerns/authentication.rb +++ b/app/controllers/concerns/authentication.rb @@ -40,7 +40,7 @@ module Authentication def request_authentication session[:return_to_after_authenticating] = request.url - redirect_to new_session_url + redirect_to new_session_path end def after_authentication_url diff --git a/test/controllers/cards/assignments_controller_test.rb b/test/controllers/cards/assignments_controller_test.rb index c71571fdf..c92f57627 100644 --- a/test/controllers/cards/assignments_controller_test.rb +++ b/test/controllers/cards/assignments_controller_test.rb @@ -6,18 +6,18 @@ class Cards::AssignmentsControllerTest < ActionDispatch::IntegrationTest end test "new" do - get new_card_assignment_url(cards(:logo)) + get new_card_assignment_path(cards(:logo)) assert_response :success end test "create" do assert_changes "cards(:logo).assigned_to?(users(:david))", from: false, to: true do - post card_assignments_url(cards(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream + post card_assignments_path(cards(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream end assert_response :success assert_changes "cards(:logo).assigned_to?(users(:david))", from: true, to: false do - post card_assignments_url(cards(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream + post card_assignments_path(cards(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream end assert_response :success end diff --git a/test/controllers/cards/closures_controller_test.rb b/test/controllers/cards/closures_controller_test.rb index a6e964148..1729010a9 100644 --- a/test/controllers/cards/closures_controller_test.rb +++ b/test/controllers/cards/closures_controller_test.rb @@ -9,21 +9,21 @@ class Cards::ClosuresControllerTest < ActionDispatch::IntegrationTest card = cards(:logo) assert_changes -> { card.reload.closed? }, from: false, to: true do - post card_closure_url(card, reason: "Scope too big") + post card_closure_path(card, reason: "Scope too big") end assert_equal "Scope too big", card.closure.reason - assert_redirected_to collection_card_url(card.collection, card) + assert_redirected_to collection_card_path(card.collection, card) end test "destroy" do card = cards(:shipping) assert_changes -> { card.reload.closed? }, from: true, to: false do - delete card_closure_url(card) + delete card_closure_path(card) end - assert_redirected_to collection_card_url(card.collection, card) + assert_redirected_to collection_card_path(card.collection, card) end end diff --git a/test/controllers/cards/comments/reactions_controller_test.rb b/test/controllers/cards/comments/reactions_controller_test.rb index 51b17daae..79d86d62c 100644 --- a/test/controllers/cards/comments/reactions_controller_test.rb +++ b/test/controllers/cards/comments/reactions_controller_test.rb @@ -10,8 +10,8 @@ class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest test "create" do assert_turbo_stream_broadcasts @card, count: 1 do assert_difference -> { @comment.reactions.count }, 1 do - post card_comment_reactions_url(@comment.card, @comment, format: :turbo_stream), params: { reaction: { content: "Great work!" } } - assert_redirected_to card_comment_reactions_url(@comment.card, @comment) + post card_comment_reactions_path(@comment.card, @comment, format: :turbo_stream), params: { reaction: { content: "Great work!" } } + assert_redirected_to card_comment_reactions_path(@comment.card, @comment) end end end @@ -19,7 +19,7 @@ class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest test "destroy" do assert_turbo_stream_broadcasts @card, count: 1 do assert_difference -> { @comment.reactions.count }, -1 do - delete card_comment_reaction_url(@comment.card, @comment, reactions(:kevin), format: :turbo_stream) + delete card_comment_reaction_path(@comment.card, @comment, reactions(:kevin), format: :turbo_stream) assert_response :success end end diff --git a/test/controllers/cards/comments_controller_test.rb b/test/controllers/cards/comments_controller_test.rb index a9e45f838..ab9c3822a 100644 --- a/test/controllers/cards/comments_controller_test.rb +++ b/test/controllers/cards/comments_controller_test.rb @@ -7,14 +7,14 @@ class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest test "create" do assert_difference "cards(:logo).messages.comments.count", +1 do - post card_comments_url(cards(:logo), params: { comment: { body: "Agreed." } }) + post card_comments_path(cards(:logo), params: { comment: { body: "Agreed." } }) end assert_response :success end test "update" do - put card_comment_url(cards(:logo), comments(:logo_agreement_kevin)), params: { comment: { body: "I've changed my mind" } } + put card_comment_path(cards(:logo), comments(:logo_agreement_kevin)), params: { comment: { body: "I've changed my mind" } } assert_response :success assert_equal "I've changed my mind", comments(:logo_agreement_kevin).reload.body.content @@ -22,7 +22,7 @@ class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest test "update another user's comment" do assert_no_changes "comments(:logo_agreement_jz).body.content" do - put card_comment_url(cards(:logo), comments(:logo_agreement_jz)), params: { comment: { body: "I've changed my mind" } } + put card_comment_path(cards(:logo), comments(:logo_agreement_jz)), params: { comment: { body: "I've changed my mind" } } end assert_response :forbidden diff --git a/test/controllers/cards/engagements_controller_test.rb b/test/controllers/cards/engagements_controller_test.rb index d1f39a635..1e966108c 100644 --- a/test/controllers/cards/engagements_controller_test.rb +++ b/test/controllers/cards/engagements_controller_test.rb @@ -9,19 +9,19 @@ class Cards::EngagementsControllerTest < ActionDispatch::IntegrationTest card = cards(:text) assert_changes -> { card.reload.doing? }, from: false, to: true do - post card_engagement_url(card) + post card_engagement_path(card) end - assert_redirected_to collection_card_url(card.collection, card) + assert_redirected_to collection_card_path(card.collection, card) end test "destroy" do card = cards(:logo) assert_changes -> { card.reload.doing? }, from: true, to: false do - delete card_engagement_url(card) + delete card_engagement_path(card) end - assert_redirected_to collection_card_url(card.collection, card) + assert_redirected_to collection_card_path(card.collection, card) end end diff --git a/test/controllers/cards/goldnesses_controller_test.rb b/test/controllers/cards/goldnesses_controller_test.rb index 081a6ec61..b8cfb9469 100644 --- a/test/controllers/cards/goldnesses_controller_test.rb +++ b/test/controllers/cards/goldnesses_controller_test.rb @@ -9,19 +9,19 @@ class Cards::GoldnessesControllerTest < ActionDispatch::IntegrationTest card = cards(:text) assert_changes -> { card.reload.golden? }, from: false, to: true do - post card_goldness_url(card) + post card_goldness_path(card) end - assert_redirected_to collection_card_url(card.collection, card) + assert_redirected_to collection_card_path(card.collection, card) end test "destroy" do card = cards(:logo) assert_changes -> { card.reload.golden? }, from: true, to: false do - delete card_goldness_url(card) + delete card_goldness_path(card) end - assert_redirected_to collection_card_url(card.collection, card) + assert_redirected_to collection_card_path(card.collection, card) end end diff --git a/test/controllers/cards/previews_controller_test.rb b/test/controllers/cards/previews_controller_test.rb index ff6541831..17597728f 100644 --- a/test/controllers/cards/previews_controller_test.rb +++ b/test/controllers/cards/previews_controller_test.rb @@ -6,7 +6,7 @@ class Cards::PreviewsControllerTest < ActionDispatch::IntegrationTest end test "index" do - get cards_previews_url(format: :turbo_stream) + get cards_previews_path(format: :turbo_stream) assert_response :success end diff --git a/test/controllers/cards/readings_controller_test.rb b/test/controllers/cards/readings_controller_test.rb index 83da1859f..c169517e2 100644 --- a/test/controllers/cards/readings_controller_test.rb +++ b/test/controllers/cards/readings_controller_test.rb @@ -7,7 +7,7 @@ class Cards::ReadingsControllerTest < ActionDispatch::IntegrationTest test "index" do assert_changes -> { notifications(:logo_published_kevin).reload.read? }, from: false, to: true do - post card_reading_url(cards(:logo)), as: :turbo_stream + post card_reading_path(cards(:logo)), as: :turbo_stream end assert_response :success diff --git a/test/controllers/cards/taggings_controller_test.rb b/test/controllers/cards/taggings_controller_test.rb index 60271f415..ad5a8fa91 100644 --- a/test/controllers/cards/taggings_controller_test.rb +++ b/test/controllers/cards/taggings_controller_test.rb @@ -6,20 +6,20 @@ class Cards::TaggingsControllerTest < ActionDispatch::IntegrationTest end test "new" do - get new_card_tagging_url(cards(:logo)) + get new_card_tagging_path(cards(:logo)) assert_response :success end test "toggle tag on" do assert_changes "cards(:logo).tagged_with?(tags(:mobile))", from: false, to: true do - post card_taggings_url(cards(:logo)), params: { tag_title: tags(:mobile).title }, as: :turbo_stream + post card_taggings_path(cards(:logo)), params: { tag_title: tags(:mobile).title }, as: :turbo_stream end assert_response :success end test "toggle tag off" do assert_changes "cards(:logo).tagged_with?(tags(:web))", from: true, to: false do - post card_taggings_url(cards(:logo)), params: { tag_title: tags(:web).title }, as: :turbo_stream + post card_taggings_path(cards(:logo)), params: { tag_title: tags(:web).title }, as: :turbo_stream end assert_response :success end diff --git a/test/controllers/cards_controller_test.rb b/test/controllers/cards_controller_test.rb index bc1b3f7a1..e794e7898 100644 --- a/test/controllers/cards_controller_test.rb +++ b/test/controllers/cards_controller_test.rb @@ -6,41 +6,41 @@ class CardsControllerTest < ActionDispatch::IntegrationTest end test "index" do - get cards_url + get cards_path assert_response :success end test "filtered index" do - get cards_url(filters(:jz_assignments).as_params.merge(term: "haggis")) + get cards_path(filters(:jz_assignments).as_params.merge(term: "haggis")) assert_response :success end test "create" do assert_difference "Card.count", 1 do - post collection_cards_url(collections(:writebook)) + post collection_cards_path(collections(:writebook)) end - assert_redirected_to collection_card_url(collections(:writebook), Card.last) + assert_redirected_to collection_card_path(collections(:writebook), Card.last) end test "show" do - get collection_card_url(collections(:writebook), cards(:logo)) + get collection_card_path(collections(:writebook), cards(:logo)) assert_response :success end test "edit" do - get edit_collection_card_url(collections(:writebook), cards(:logo)) + get edit_collection_card_path(collections(:writebook), cards(:logo)) assert_response :success end test "update" do - patch collection_card_url(collections(:writebook), cards(:logo)), params: { + patch collection_card_path(collections(:writebook), cards(:logo)), params: { card: { title: "Logo needs to change", due_on: 1.week.from_now, image: fixture_file_upload("moon.jpg", "image/jpeg"), draft_comment: "Something more in-depth", tag_ids: [ tags(:mobile).id ] } } - assert_redirected_to collection_card_url(collections(:writebook), cards(:logo)) + assert_redirected_to collection_card_path(collections(:writebook), cards(:logo)) card = cards(:logo).reload assert_equal "Logo needs to change", card.title @@ -52,12 +52,12 @@ class CardsControllerTest < ActionDispatch::IntegrationTest end test "users can only see cards in collections they have access to" do - get collection_card_url(collections(:writebook), cards(:logo)) + get collection_card_path(collections(:writebook), cards(:logo)) assert_response :success collections(:writebook).update! all_access: false collections(:writebook).accesses.revoke_from users(:kevin) - get collection_card_url(collections(:writebook), cards(:logo)) + get collection_card_path(collections(:writebook), cards(:logo)) assert_response :not_found end end diff --git a/test/controllers/collections/involvements_controller_test.rb b/test/controllers/collections/involvements_controller_test.rb index 943f0dd58..561d6951f 100644 --- a/test/controllers/collections/involvements_controller_test.rb +++ b/test/controllers/collections/involvements_controller_test.rb @@ -10,7 +10,7 @@ class Collections::InvolvementsControllerTest < ActionDispatch::IntegrationTest collection.access_for(users(:kevin)).access_only! assert_changes -> { collection.access_for(users(:kevin)).involvement }, from: "access_only", to: "watching" do - put collection_involvement_url(collection, involvement: "watching") + put collection_involvement_path(collection, involvement: "watching") end assert_response :success diff --git a/test/controllers/collections/workflows_controller_test.rb b/test/controllers/collections/workflows_controller_test.rb index b733784fd..8fb0e8dce 100644 --- a/test/controllers/collections/workflows_controller_test.rb +++ b/test/controllers/collections/workflows_controller_test.rb @@ -8,7 +8,7 @@ class Collections::WorkflowsControllerTest < ActionDispatch::IntegrationTest test "update" do collection = collections(:writebook) - patch collection_workflow_url(collection), params: { collection: { workflow_id: workflows(:on_call).id } } + patch collection_workflow_path(collection), params: { collection: { workflow_id: workflows(:on_call).id } } assert_redirected_to cards_path(collection_ids: [ collection.id ]) assert_equal workflows(:on_call), collection.reload.workflow diff --git a/test/controllers/collections_controller_test.rb b/test/controllers/collections_controller_test.rb index 82da48186..20111c4bf 100644 --- a/test/controllers/collections_controller_test.rb +++ b/test/controllers/collections_controller_test.rb @@ -6,13 +6,13 @@ class CollectionsControllerTest < ActionDispatch::IntegrationTest end test "new" do - get new_collection_url + get new_collection_path assert_response :success end test "create" do assert_difference -> { Collection.count }, +1 do - post collections_url, params: { collection: { name: "Remodel Punch List" } } + post collections_path, params: { collection: { name: "Remodel Punch List" } } end collection = Collection.last @@ -22,12 +22,12 @@ class CollectionsControllerTest < ActionDispatch::IntegrationTest end test "edit" do - get edit_collection_url(collections(:writebook)) + get edit_collection_path(collections(:writebook)) assert_response :success end test "update" do - patch collection_url(collections(:writebook)), params: { + patch collection_path(collections(:writebook)), params: { collection: { name: "Writebook bugs", all_access: false @@ -47,7 +47,7 @@ class CollectionsControllerTest < ActionDispatch::IntegrationTest end assert_equal [ users(:kevin) ], collection.users - patch collection_url(collection), params: { collection: { name: "Bugs", all_access: true } } + patch collection_path(collection), params: { collection: { name: "Bugs", all_access: true } } assert_redirected_to cards_path(collection_ids: [ collection ]) assert collection.reload.all_access? @@ -56,8 +56,8 @@ class CollectionsControllerTest < ActionDispatch::IntegrationTest test "destroy" do assert_difference -> { Collection.count }, -1 do - delete collection_url(collections(:writebook)) - assert_redirected_to root_url + delete collection_path(collections(:writebook)) + assert_redirected_to root_path end end end diff --git a/test/controllers/events_controller_test.rb b/test/controllers/events_controller_test.rb index 01be44161..c5dcd3d0a 100644 --- a/test/controllers/events_controller_test.rb +++ b/test/controllers/events_controller_test.rb @@ -9,7 +9,7 @@ class EventsControllerTest < ActionDispatch::IntegrationTest end test "index" do - get events_url + get events_path assert_select "div.event__wrapper[style='grid-area: 17/2']" do assert_select "strong", text: "David assigned JZ to Layout is broken" @@ -19,7 +19,7 @@ class EventsControllerTest < ActionDispatch::IntegrationTest test "index with a specific timezone" do cookies[:timezone] = "America/New_York" - get events_url + get events_path assert_select "div.event__wrapper[style='grid-area: 22/2']" do assert_select "strong", text: "David assigned JZ to Layout is broken" diff --git a/test/controllers/filters_controller_test.rb b/test/controllers/filters_controller_test.rb index 979bfdd34..ecf0481d5 100644 --- a/test/controllers/filters_controller_test.rb +++ b/test/controllers/filters_controller_test.rb @@ -7,7 +7,7 @@ class FiltersControllerTest < ActionDispatch::IntegrationTest test "create" do assert_difference "users(:david).filters.count", +1 do - post filters_url, params: { + post filters_path, params: { indexed_by: "closed", assignment_status: "unassigned", tag_ids: [ tags(:mobile).id ], @@ -26,7 +26,7 @@ class FiltersControllerTest < ActionDispatch::IntegrationTest test "destroy" do assert_difference "users(:david).filters.count", -1 do - delete filter_url(filters(:jz_assignments)) + delete filter_path(filters(:jz_assignments)) end assert_redirected_to cards_path(filters(:jz_assignments).as_params) end diff --git a/test/controllers/first_runs_controller_test.rb b/test/controllers/first_runs_controller_test.rb index 9d2e99c7b..0dcec97a0 100644 --- a/test/controllers/first_runs_controller_test.rb +++ b/test/controllers/first_runs_controller_test.rb @@ -6,20 +6,20 @@ class FirstRunsControllerTest < ActionDispatch::IntegrationTest end test "show" do - get first_run_url + get first_run_path assert_response :ok assert_select "title", text: "Set up Fizzy" end test "show after completion" do Account.create! name: "Fizzy" - get first_run_url + get first_run_path assert_redirected_to root_url end test "create" do assert_difference -> { Account.count }, +1 do - post first_run_url, params: { user: { name: "New", email_address: "new@37signals.com", password: "secret123456" } } + post first_run_path, params: { user: { name: "New", email_address: "new@37signals.com", password: "secret123456" } } assert_redirected_to root_url end diff --git a/test/controllers/my/pins_controller_test.rb b/test/controllers/my/pins_controller_test.rb index cf8416445..3c8ca33e2 100644 --- a/test/controllers/my/pins_controller_test.rb +++ b/test/controllers/my/pins_controller_test.rb @@ -6,7 +6,7 @@ class My::PinsControllerTest < ActionDispatch::IntegrationTest end test "index" do - get my_pins_url + get my_pins_path assert_response :success assert_select "div", text: /#{users(:kevin).pins.first.card.title}/ diff --git a/test/controllers/notifications/mark_all_reads_controller_test.rb b/test/controllers/notifications/mark_all_reads_controller_test.rb index ea43e1be6..2fa423b3a 100644 --- a/test/controllers/notifications/mark_all_reads_controller_test.rb +++ b/test/controllers/notifications/mark_all_reads_controller_test.rb @@ -8,7 +8,7 @@ class Notifications::MarkAllReadsControllerTest < ActionDispatch::IntegrationTes test "show" do assert_changes -> { notifications(:logo_published_kevin).reload.read? }, from: false, to: true do assert_changes -> { notifications(:layout_commented_kevin).reload.read? }, from: false, to: true do - post notifications_mark_all_read_url + post notifications_mark_all_read_path end end diff --git a/test/controllers/notifications/trays_controller_test.rb b/test/controllers/notifications/trays_controller_test.rb index 7d44a3e00..d49455ae1 100644 --- a/test/controllers/notifications/trays_controller_test.rb +++ b/test/controllers/notifications/trays_controller_test.rb @@ -6,7 +6,7 @@ class Notifications::TraysControllerTest < ActionDispatch::IntegrationTest end test "show" do - get notifications_tray_url + get notifications_tray_path assert_response :success assert_select "div", text: /Layout is broken/ diff --git a/test/controllers/recovers_controller_test.rb b/test/controllers/recovers_controller_test.rb index c276fdb33..91fbf4cf2 100644 --- a/test/controllers/recovers_controller_test.rb +++ b/test/controllers/recovers_controller_test.rb @@ -10,7 +10,7 @@ class Cards::RecoversControllerTest < ActionDispatch::IntegrationTest abandoned_card.update!(title: "An edited title") unsaved_card = collections(:writebook).cards.create! creator: users(:kevin) - post card_recover_url(unsaved_card) + post card_recover_path(unsaved_card) assert_redirected_to abandoned_card assert_equal [ abandoned_card ], Card.creating diff --git a/test/controllers/sessions/transfers_controller_test.rb b/test/controllers/sessions/transfers_controller_test.rb index d8cbe9842..383154590 100644 --- a/test/controllers/sessions/transfers_controller_test.rb +++ b/test/controllers/sessions/transfers_controller_test.rb @@ -2,7 +2,7 @@ require "test_helper" class Sessions::TransfersControllerTest < ActionDispatch::IntegrationTest test "show renders when not signed in" do - get session_transfer_url("some-token") + get session_transfer_path("some-token") assert_response :success end @@ -10,7 +10,7 @@ class Sessions::TransfersControllerTest < ActionDispatch::IntegrationTest test "update establishes a session when the code is valid" do user = users(:david) - put session_transfer_url(user.transfer_id) + put session_transfer_path(user.transfer_id) assert_redirected_to root_url assert parsed_cookies.signed[:session_token] diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index 79369690e..1cf460c6c 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -5,34 +5,34 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest DISALLOWED_BROWSER = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0" test "new" do - get new_session_url + get new_session_path assert_response :success end test "new enforces browser compatibility" do - get new_session_url, env: { "HTTP_USER_AGENT" => DISALLOWED_BROWSER } + get new_session_path, env: { "HTTP_USER_AGENT" => DISALLOWED_BROWSER } assert_select "svg", message: /Your browser is not supported/ - get new_session_url, env: { "HTTP_USER_AGENT" => ALLOWED_BROWSER } + get new_session_path, env: { "HTTP_USER_AGENT" => ALLOWED_BROWSER } assert_select "svg", text: /Your browser is not supported/, count: 0 end test "create with valid credentials" do - post session_url, params: { email_address: "david@37signals.com", password: "secret123456" } - assert_redirected_to root_url + post session_path, params: { email_address: "david@37signals.com", password: "secret123456" } + assert_redirected_to root_path assert cookies[:session_token].present? end test "create with invalid credentials" do - post session_url, params: { email_address: "david@37signals.com", password: "wrong" } - assert_redirected_to new_session_url + post session_path, params: { email_address: "david@37signals.com", password: "wrong" } + assert_redirected_to new_session_path assert_not cookies[:session_token].present? end test "destroy" do sign_in_as :kevin - delete session_url - assert_redirected_to new_session_url + delete session_path + assert_redirected_to new_session_path assert_not cookies[:session_token].present? end end diff --git a/test/controllers/uploads_controller_test.rb b/test/controllers/uploads_controller_test.rb index 3cbdb3250..3f5f54af5 100644 --- a/test/controllers/uploads_controller_test.rb +++ b/test/controllers/uploads_controller_test.rb @@ -7,7 +7,7 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest test "create" do assert_changes -> { ActiveStorage::Attachment.count }, 1 do - post uploads_url(format: "json"), params: { file: fixture_file_upload("moon.jpg", "image/jpeg") }, as: :xhr + post uploads_path(format: "json"), params: { file: fixture_file_upload("moon.jpg", "image/jpeg") }, as: :xhr end assert_response :success @@ -18,7 +18,7 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest test "show" do accounts("37s").uploads.attach fixture_file_upload("moon.jpg", "image/jpeg") - get upload_url(slug: accounts("37s").uploads.last.slug) + get upload_path(slug: accounts("37s").uploads.last.slug) assert_response :redirect assert_match /\/rails\/active_storage\/.*\/moon\.jpg/, @response.redirect_url end diff --git a/test/controllers/users/roles_controller_test.rb b/test/controllers/users/roles_controller_test.rb index 37b93e334..ceaf6e2fb 100644 --- a/test/controllers/users/roles_controller_test.rb +++ b/test/controllers/users/roles_controller_test.rb @@ -8,7 +8,7 @@ class Users::RolesControllerTest < ActionDispatch::IntegrationTest test "update" do assert_not users(:david).admin? - put user_role_url(users(:david)), params: { user: { role: "admin" } } + put user_role_path(users(:david)), params: { user: { role: "admin" } } assert_redirected_to users_path assert users(:david).reload.admin? @@ -16,7 +16,7 @@ class Users::RolesControllerTest < ActionDispatch::IntegrationTest test "can't promote to special roles" do assert_no_changes -> { users(:david).reload.role } do - put user_role_url(users(:david)), params: { user: { role: "system" } } + put user_role_path(users(:david)), params: { user: { role: "system" } } end end end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 7afd6f04c..3b914ea23 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -11,7 +11,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest test "destroy" do assert_difference -> { User.active.count }, -1 do - delete user_url(users(:david)) + delete user_path(users(:david)) end assert_redirected_to users_path @@ -21,10 +21,10 @@ class UsersControllerTest < ActionDispatch::IntegrationTest test "non-admins cannot perform actions" do sign_in_as :jz - put user_url(users(:david)), params: { user: { role: "admin" } } + put user_path(users(:david)), params: { user: { role: "admin" } } assert_response :forbidden - delete user_url(users(:david)) + delete user_path(users(:david)) assert_response :forbidden end end diff --git a/test/integration/card_messages.rb b/test/integration/card_messages.rb index 6569d67d8..29eded2f0 100644 --- a/test/integration/card_messages.rb +++ b/test/integration/card_messages.rb @@ -7,34 +7,34 @@ class CardMessagesTest < ActionDispatch::IntegrationTest test "messages system" do # Create a card - post collection_cards_url(collections(:writebook)) + post collection_cards_path(collections(:writebook)) card = Card.last assert_equal 1, card.messages.count assert_predicate card.messages.last, :event_summary? assert_equal "created", card.messages.last.messageable.events.sole.action # Comment on it - post collection_card_comments_url(collections(:writebook), card), params: { comment: { body: "Agreed." } } + post collection_card_comments_path(collections(:writebook), card), params: { comment: { body: "Agreed." } } assert_equal 2, card.messages.count assert_predicate card.messages.last, :comment? assert_equal "Agreed.", card.messages.last.messageable.body # Assign it - post collection_card_assignments_url(collections(:writebook), card), params: { assignee_id: users(:kevin).id } + post collection_card_assignments_path(collections(:writebook), card), params: { assignee_id: users(:kevin).id } assert_equal 3, card.messages.count assert_predicate card.messages.last, :event_summary? assert_equal 1, card.messages.last.event_summary.events.count assert_equal "assigned", card.messages.last.messageable.events.last.action # Stage it - post card_stagings_url(card), params: { stage_id: workflow_stages(:qa_triage).id } + post card_stagings_path(card), params: { stage_id: workflow_stages(:qa_triage).id } assert_equal 3, card.messages.count assert_predicate card.messages.last, :event_summary? assert_equal 2, card.messages.last.event_summary.events.count assert_equal "staged", card.messages.last.messageable.events.last.action # Unstage it - post card_stagings_url(card), params: { stage_id: workflow_stages(:qa_triage).id } + post card_stagings_path(card), params: { stage_id: workflow_stages(:qa_triage).id } assert_equal 3, card.messages.count assert_predicate card.messages.last, :event_summary? assert_equal 3, card.messages.last.event_summary.events.count diff --git a/test/test_helpers/session_test_helper.rb b/test/test_helpers/session_test_helper.rb index 35e29d71f..ae97852a9 100644 --- a/test/test_helpers/session_test_helper.rb +++ b/test/test_helpers/session_test_helper.rb @@ -6,12 +6,12 @@ module SessionTestHelper def sign_in_as(user) cookies[:session_token] = nil user = users(user) unless user.is_a? User - post session_url, params: { email_address: user.email_address, password: "secret123456" } + post session_path, params: { email_address: user.email_address, password: "secret123456" } assert cookies[:session_token].present? end def sign_out - delete session_url + delete session_path assert_not cookies[:session_token].present? end