Added loads

This commit is contained in:
Jeremy Caudle
2022-02-06 15:04:32 +00:00
parent 140921ce10
commit 055b79373c
42 changed files with 944 additions and 7 deletions

View File

@@ -0,0 +1,48 @@
require "test_helper"
class CompaniesControllerTest < ActionDispatch::IntegrationTest
setup do
@company = companies(:one)
end
test "should get index" do
get companies_url
assert_response :success
end
test "should get new" do
get new_company_url
assert_response :success
end
test "should create company" do
assert_difference("Company.count") do
post companies_url, params: { company: { name: @company.name } }
end
assert_redirected_to company_url(Company.last)
end
test "should show company" do
get company_url(@company)
assert_response :success
end
test "should get edit" do
get edit_company_url(@company)
assert_response :success
end
test "should update company" do
patch company_url(@company), params: { company: { name: @company.name } }
assert_redirected_to company_url(@company)
end
test "should destroy company" do
assert_difference("Company.count", -1) do
delete company_url(@company)
end
assert_redirected_to companies_url
end
end

7
test/fixtures/companies.yml vendored Normal file
View File

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

View File

@@ -0,0 +1,14 @@
require "test_helper"
class CompanyTest < ActiveSupport::TestCase
test "compnay name can not be blank" do
c = Company.new
assert !c.save
end
test "company name must be unique" do
c = Company.new
c.name = "HiddenAgendaLtd"
assert !c.save
end
end

View File

@@ -0,0 +1,41 @@
require "application_system_test_case"
class CompaniesTest < ApplicationSystemTestCase
setup do
@company = companies(:one)
end
test "visiting the index" do
visit companies_url
assert_selector "h1", text: "Companies"
end
test "should create company" do
visit companies_url
click_on "New company"
fill_in "Name", with: @company.name
click_on "Create Company"
assert_text "Company was successfully created"
click_on "Back"
end
test "should update Company" do
visit company_url(@company)
click_on "Edit this company", match: :first
fill_in "Name", with: @company.name
click_on "Update Company"
assert_text "Company was successfully updated"
click_on "Back"
end
test "should destroy Company" do
visit company_url(@company)
click_on "Destroy this company", match: :first
assert_text "Company was successfully destroyed"
end
end