Add tests for new controllers

This commit is contained in:
Jorge Manrubia
2025-09-28 21:11:07 +02:00
parent 5a4cef98c9
commit 23895e53aa
18 changed files with 199 additions and 6 deletions
@@ -0,0 +1,16 @@
require "test_helper"
class Cards::NotNowsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create" do
card = cards(:logo)
assert_changes -> { card.reload.postponed? }, from: false, to: true do
post card_not_now_path(card)
assert_card_container_rerendered(card)
end
end
end
@@ -0,0 +1,27 @@
require "test_helper"
class Cards::TriagesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create" do
card = cards(:logo)
original_column = card.column
column = columns(:writebook_in_progress)
assert_changes -> { card.reload.column }, from: original_column, to: column do
post card_triage_path(card, column_id: column.id)
assert_card_container_rerendered(card)
end
end
test "destroy" do
card = cards(:shipping)
assert_changes -> { card.reload.column }, to: nil do
delete card_triage_path(card)
assert_card_container_rerendered(card)
end
end
end
+1 -1
View File
@@ -16,7 +16,7 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
end
test "create" do
assert_difference "Card.count", 1 do
assert_difference -> { Card.count }, 1 do
post collection_cards_path(collections(:writebook))
end
assert_redirected_to card_path(Card.last)
@@ -0,0 +1,12 @@
require "test_helper"
class Collections::Columns::ClosedsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "show" do
get collection_columns_closed_path(collections(:writebook))
assert_response :success
end
end
@@ -0,0 +1,12 @@
require "test_helper"
class Collections::Columns::NotNowsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "show" do
get collection_columns_not_now_path(collections(:writebook))
assert_response :success
end
end
@@ -0,0 +1,12 @@
require "test_helper"
class Collections::Columns::StreamsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "show" do
get collection_columns_stream_path(collections(:writebook))
assert_response :success
end
end
@@ -0,0 +1,39 @@
require "test_helper"
class Collections::ColumnsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "show" do
get collection_column_path(collections(:writebook), columns(:writebook_in_progress))
assert_response :success
end
test "create" do
assert_difference -> { collections(:writebook).columns.count }, +1 do
post collection_columns_path(collections(:writebook)), params: { column: { name: "New Column" } }, as: :turbo_stream
assert_response :success
end
assert_equal "New Column", collections(:writebook).columns.last.name
end
test "update" do
column = columns(:writebook_in_progress)
assert_changes -> { column.reload.name }, from: "In progress", to: "Updated Name" do
put collection_column_path(collections(:writebook), column), params: { column: { name: "Updated Name" } }, as: :turbo_stream
assert_response :success
end
end
test "destroy" do
column = columns(:writebook_on_hold)
assert_difference -> { collections(:writebook).columns.count }, -1 do
delete collection_column_path(collections(:writebook), column), as: :turbo_stream
assert_response :success
end
end
end
@@ -10,6 +10,11 @@ class CollectionsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
test "show" do
get collection_path(collections(:writebook))
assert_response :success
end
test "create" do
assert_difference -> { Collection.count }, +1 do
post collections_path, params: { collection: { name: "Remodel Punch List" } }
@@ -0,0 +1,16 @@
require "test_helper"
class Columns::Cards::Drops::ClosuresControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create" do
card = cards(:logo)
assert_changes -> { card.reload.closed? }, from: false, to: true do
post columns_card_drops_closure_path(card), as: :turbo_stream
assert_response :success
end
end
end
@@ -0,0 +1,17 @@
require "test_helper"
class Columns::Cards::Drops::ColumnsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create" do
card = cards(:logo)
column = columns(:writebook_in_progress)
assert_changes -> { card.reload.column }, to: column do
post columns_card_drops_column_path(card, column_id: column.id), as: :turbo_stream
assert_response :success
end
end
end
@@ -0,0 +1,16 @@
require "test_helper"
class Columns::Cards::Drops::NotNowsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create" do
card = cards(:logo)
assert_changes -> { card.reload.postponed? }, from: false, to: true do
post columns_card_drops_not_now_path(card), as: :turbo_stream
assert_response :success
end
end
end
@@ -0,0 +1,16 @@
require "test_helper"
class Columns::Cards::Drops::StreamsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create" do
card = cards(:text)
assert_changes -> { card.reload.triaged? }, from: true, to: false do
post columns_card_drops_stream_path(card), as: :turbo_stream
assert_response :success
end
end
end
@@ -20,4 +20,10 @@ class Public::CollectionsControllerTest < ActionDispatch::IntegrationTest
assert_response :not_found
end
test "show works without authentication" do
sign_out
get published_collection_path(collections(:writebook))
assert_response :success
end
end
@@ -15,4 +15,3 @@ class Collection::TriageableTest < ActiveSupport::TestCase
end
end
end