Added vehicle scaffold
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run

This commit is contained in:
2024-08-20 19:50:29 +02:00
parent 1bd24e08d0
commit 132ea2c51d
20 changed files with 379 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
require "test_helper"
class VehiclesControllerTest < ActionDispatch::IntegrationTest
setup do
@vehicle = vehicles(:one)
end
test "should get index" do
get vehicles_url
assert_response :success
end
test "should get new" do
get new_vehicle_url
assert_response :success
end
test "should create vehicle" do
assert_difference("Vehicle.count") do
post vehicles_url, params: { vehicle: { car_brand: @vehicle.car_brand, fuel_type: @vehicle.fuel_type, license_plate: @vehicle.license_plate, model: @vehicle.model, model_year: @vehicle.model_year, type: @vehicle.type } }
end
assert_redirected_to vehicle_url(Vehicle.last)
end
test "should show vehicle" do
get vehicle_url(@vehicle)
assert_response :success
end
test "should get edit" do
get edit_vehicle_url(@vehicle)
assert_response :success
end
test "should update vehicle" do
patch vehicle_url(@vehicle), params: { vehicle: { car_brand: @vehicle.car_brand, fuel_type: @vehicle.fuel_type, license_plate: @vehicle.license_plate, model: @vehicle.model, model_year: @vehicle.model_year, type: @vehicle.type } }
assert_redirected_to vehicle_url(@vehicle)
end
test "should destroy vehicle" do
assert_difference("Vehicle.count", -1) do
delete vehicle_url(@vehicle)
end
assert_redirected_to vehicles_url
end
end

17
test/fixtures/vehicles.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
license_plate: MyString
type:
model_year: 2024-08-20 18:58:36
car_brand: MyString
model: MyString
fuel_type: MyString
two:
license_plate: MyString
type:
model_year: 2024-08-20 18:58:36
car_brand: MyString
model: MyString
fuel_type: MyString

View File

@@ -0,0 +1,7 @@
require "test_helper"
class VehicleTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@@ -0,0 +1,51 @@
require "application_system_test_case"
class VehiclesTest < ApplicationSystemTestCase
setup do
@vehicle = vehicles(:one)
end
test "visiting the index" do
visit vehicles_url
assert_selector "h1", text: "Vehicles"
end
test "should create vehicle" do
visit vehicles_url
click_on "New vehicle"
fill_in "Car brand", with: @vehicle.car_brand
fill_in "Fuel type", with: @vehicle.fuel_type
fill_in "License plate", with: @vehicle.license_plate
fill_in "Model", with: @vehicle.model
fill_in "Model year", with: @vehicle.model_year
fill_in "Type", with: @vehicle.type
click_on "Create Vehicle"
assert_text "Vehicle was successfully created"
click_on "Back"
end
test "should update Vehicle" do
visit vehicle_url(@vehicle)
click_on "Edit this vehicle", match: :first
fill_in "Car brand", with: @vehicle.car_brand
fill_in "Fuel type", with: @vehicle.fuel_type
fill_in "License plate", with: @vehicle.license_plate
fill_in "Model", with: @vehicle.model
fill_in "Model year", with: @vehicle.model_year.to_s
fill_in "Type", with: @vehicle.type
click_on "Update Vehicle"
assert_text "Vehicle was successfully updated"
click_on "Back"
end
test "should destroy Vehicle" do
visit vehicle_url(@vehicle)
click_on "Destroy this vehicle", match: :first
assert_text "Vehicle was successfully destroyed"
end
end