2024-04-29 21:17:28 +02:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class Transactions::MerchantsControllerTest < ActionDispatch::IntegrationTest
|
|
|
|
setup do
|
|
|
|
sign_in @user = users(:family_admin)
|
|
|
|
@merchant = transaction_merchants(:netflix)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "index" do
|
2024-05-02 07:24:31 -06:00
|
|
|
get transaction_merchants_path
|
2024-04-29 21:17:28 +02:00
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "new" do
|
2024-05-02 07:24:31 -06:00
|
|
|
get new_transaction_merchant_path
|
2024-04-29 21:17:28 +02:00
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should create merchant" do
|
|
|
|
assert_difference("Transaction::Merchant.count") do
|
2024-05-02 07:24:31 -06:00
|
|
|
post transaction_merchants_url, params: { transaction_merchant: { name: "new merchant", color: "#000000" } }
|
2024-04-29 21:17:28 +02:00
|
|
|
end
|
|
|
|
|
2024-05-02 07:24:31 -06:00
|
|
|
assert_redirected_to transaction_merchants_path
|
2024-04-29 21:17:28 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "should update merchant" do
|
2024-05-02 07:24:31 -06:00
|
|
|
patch transaction_merchant_url(@merchant), params: { transaction_merchant: { name: "new name", color: "#000000" } }
|
|
|
|
assert_redirected_to transaction_merchants_path
|
2024-04-29 21:17:28 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "should destroy merchant" do
|
|
|
|
assert_difference("Transaction::Merchant.count", -1) do
|
2024-05-02 07:24:31 -06:00
|
|
|
delete transaction_merchant_url(@merchant)
|
2024-04-29 21:17:28 +02:00
|
|
|
end
|
|
|
|
|
2024-05-02 07:24:31 -06:00
|
|
|
assert_redirected_to transaction_merchants_path
|
2024-04-29 21:17:28 +02:00
|
|
|
end
|
|
|
|
end
|