Use _path in all cases where we are not potentially changing the domain
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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}/
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user