Rezervacije

This commit is contained in:
2024-08-06 14:16:40 +02:00
parent 8d5a410c60
commit 6d5509856f
58 changed files with 1052 additions and 3 deletions

View File

@@ -0,0 +1,48 @@
require "test_helper"
class CustomersControllerTest < ActionDispatch::IntegrationTest
setup do
@customer = customers(:one)
end
test "should get index" do
get customers_url
assert_response :success
end
test "should get new" do
get new_customer_url
assert_response :success
end
test "should create customer" do
assert_difference("Customer.count") do
post customers_url, params: { customer: { birthyear: @customer.birthyear, email: @customer.email, name: @customer.name, notes: @customer.notes, phone: @customer.phone } }
end
assert_redirected_to customer_url(Customer.last)
end
test "should show customer" do
get customer_url(@customer)
assert_response :success
end
test "should get edit" do
get edit_customer_url(@customer)
assert_response :success
end
test "should update customer" do
patch customer_url(@customer), params: { customer: { birthyear: @customer.birthyear, email: @customer.email, name: @customer.name, notes: @customer.notes, phone: @customer.phone } }
assert_redirected_to customer_url(@customer)
end
test "should destroy customer" do
assert_difference("Customer.count", -1) do
delete customer_url(@customer)
end
assert_redirected_to customers_url
end
end

View File

@@ -0,0 +1,48 @@
require "test_helper"
class PlacesControllerTest < ActionDispatch::IntegrationTest
setup do
@place = places(:one)
end
test "should get index" do
get places_url
assert_response :success
end
test "should get new" do
get new_place_url
assert_response :success
end
test "should create place" do
assert_difference("Place.count") do
post places_url, params: { place: { company_id: @place.company_id, name: @place.name } }
end
assert_redirected_to place_url(Place.last)
end
test "should show place" do
get place_url(@place)
assert_response :success
end
test "should get edit" do
get edit_place_url(@place)
assert_response :success
end
test "should update place" do
patch place_url(@place), params: { place: { company_id: @place.company_id, name: @place.name } }
assert_redirected_to place_url(@place)
end
test "should destroy place" do
assert_difference("Place.count", -1) do
delete place_url(@place)
end
assert_redirected_to places_url
end
end

View File

@@ -0,0 +1,48 @@
require "test_helper"
class ReservationsControllerTest < ActionDispatch::IntegrationTest
setup do
@reservation = reservations(:one)
end
test "should get index" do
get reservations_url
assert_response :success
end
test "should get new" do
get new_reservation_url
assert_response :success
end
test "should create reservation" do
assert_difference("Reservation.count") do
post reservations_url, params: { reservation: { company_id: @reservation.company_id, customer_id: @reservation.customer_id, description: @reservation.description, end_time: @reservation.end_time, place_id: @reservation.place_id, start_time: @reservation.start_time, title: @reservation.title } }
end
assert_redirected_to reservation_url(Reservation.last)
end
test "should show reservation" do
get reservation_url(@reservation)
assert_response :success
end
test "should get edit" do
get edit_reservation_url(@reservation)
assert_response :success
end
test "should update reservation" do
patch reservation_url(@reservation), params: { reservation: { company_id: @reservation.company_id, customer_id: @reservation.customer_id, description: @reservation.description, end_time: @reservation.end_time, place_id: @reservation.place_id, start_time: @reservation.start_time, title: @reservation.title } }
assert_redirected_to reservation_url(@reservation)
end
test "should destroy reservation" do
assert_difference("Reservation.count", -1) do
delete reservation_url(@reservation)
end
assert_redirected_to reservations_url
end
end

15
test/fixtures/customers.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
phone: MyString
notes: MyText
email: MyString
birthyear: 1
two:
name: MyString
phone: MyString
notes: MyText
email: MyString
birthyear: 1

9
test/fixtures/places.yml vendored Normal file
View File

@@ -0,0 +1,9 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
company: one
two:
name: MyString
company: two

19
test/fixtures/reservations.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
company: one
customer: one
place: one
title: MyString
description: MyText
start_time: 2024-08-04 08:01:12
end_time: 2024-08-04 08:01:12
two:
company: two
customer: two
place: two
title: MyString
description: MyText
start_time: 2024-08-04 08:01:12
end_time: 2024-08-04 08:01:12

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,49 @@
require "application_system_test_case"
class CustomersTest < ApplicationSystemTestCase
setup do
@customer = customers(:one)
end
test "visiting the index" do
visit customers_url
assert_selector "h1", text: "Customers"
end
test "should create customer" do
visit customers_url
click_on "New customer"
fill_in "Birthyear", with: @customer.birthyear
fill_in "Email", with: @customer.email
fill_in "Name", with: @customer.name
fill_in "Notes", with: @customer.notes
fill_in "Phone", with: @customer.phone
click_on "Create Customer"
assert_text "Customer was successfully created"
click_on "Back"
end
test "should update Customer" do
visit customer_url(@customer)
click_on "Edit this customer", match: :first
fill_in "Birthyear", with: @customer.birthyear
fill_in "Email", with: @customer.email
fill_in "Name", with: @customer.name
fill_in "Notes", with: @customer.notes
fill_in "Phone", with: @customer.phone
click_on "Update Customer"
assert_text "Customer was successfully updated"
click_on "Back"
end
test "should destroy Customer" do
visit customer_url(@customer)
click_on "Destroy this customer", match: :first
assert_text "Customer was successfully destroyed"
end
end

View File

@@ -0,0 +1,43 @@
require "application_system_test_case"
class PlacesTest < ApplicationSystemTestCase
setup do
@place = places(:one)
end
test "visiting the index" do
visit places_url
assert_selector "h1", text: "Places"
end
test "should create place" do
visit places_url
click_on "New place"
fill_in "Company", with: @place.company_id
fill_in "Name", with: @place.name
click_on "Create Place"
assert_text "Place was successfully created"
click_on "Back"
end
test "should update Place" do
visit place_url(@place)
click_on "Edit this place", match: :first
fill_in "Company", with: @place.company_id
fill_in "Name", with: @place.name
click_on "Update Place"
assert_text "Place was successfully updated"
click_on "Back"
end
test "should destroy Place" do
visit place_url(@place)
click_on "Destroy this place", match: :first
assert_text "Place was successfully destroyed"
end
end

View File

@@ -0,0 +1,53 @@
require "application_system_test_case"
class ReservationsTest < ApplicationSystemTestCase
setup do
@reservation = reservations(:one)
end
test "visiting the index" do
visit reservations_url
assert_selector "h1", text: "Reservations"
end
test "should create reservation" do
visit reservations_url
click_on "New reservation"
fill_in "Company", with: @reservation.company_id
fill_in "Customer", with: @reservation.customer_id
fill_in "Description", with: @reservation.description
fill_in "End time", with: @reservation.end_time
fill_in "Place", with: @reservation.place_id
fill_in "Start time", with: @reservation.start_time
fill_in "Title", with: @reservation.title
click_on "Create Reservation"
assert_text "Reservation was successfully created"
click_on "Back"
end
test "should update Reservation" do
visit reservation_url(@reservation)
click_on "Edit this reservation", match: :first
fill_in "Company", with: @reservation.company_id
fill_in "Customer", with: @reservation.customer_id
fill_in "Description", with: @reservation.description
fill_in "End time", with: @reservation.end_time
fill_in "Place", with: @reservation.place_id
fill_in "Start time", with: @reservation.start_time
fill_in "Title", with: @reservation.title
click_on "Update Reservation"
assert_text "Reservation was successfully updated"
click_on "Back"
end
test "should destroy Reservation" do
visit reservation_url(@reservation)
click_on "Destroy this reservation", match: :first
assert_text "Reservation was successfully destroyed"
end
end