Scaffold job model
This commit is contained in:
48
test/controllers/jobs_controller_test.rb
Normal file
48
test/controllers/jobs_controller_test.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
require "test_helper"
|
||||
|
||||
class JobsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@job = jobs(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get jobs_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_job_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create job" do
|
||||
assert_difference("Job.count") do
|
||||
post jobs_url, params: { job: { cost_center: @job.cost_center, costum_qm_plan: @job.costum_qm_plan, costumer_firstname: @job.costumer_firstname, costumer_id_id: @job.costumer_id_id, costumer_lastname: @job.costumer_lastname, intern: @job.intern, number_of_plans_a0: @job.number_of_plans_a0, number_of_plans_a1: @job.number_of_plans_a1, number_of_plans_a2: @job.number_of_plans_a2, number_of_plans_a3: @job.number_of_plans_a3, operator_firstname: @job.operator_firstname, operator_id_id: @job.operator_id_id, operator_lastname: @job.operator_lastname, paid: @job.paid, printed_at: @job.printed_at } }
|
||||
end
|
||||
|
||||
assert_redirected_to job_url(Job.last)
|
||||
end
|
||||
|
||||
test "should show job" do
|
||||
get job_url(@job)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_job_url(@job)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update job" do
|
||||
patch job_url(@job), params: { job: { cost_center: @job.cost_center, costum_qm_plan: @job.costum_qm_plan, costumer_firstname: @job.costumer_firstname, costumer_id_id: @job.costumer_id_id, costumer_lastname: @job.costumer_lastname, intern: @job.intern, number_of_plans_a0: @job.number_of_plans_a0, number_of_plans_a1: @job.number_of_plans_a1, number_of_plans_a2: @job.number_of_plans_a2, number_of_plans_a3: @job.number_of_plans_a3, operator_firstname: @job.operator_firstname, operator_id_id: @job.operator_id_id, operator_lastname: @job.operator_lastname, paid: @job.paid, printed_at: @job.printed_at } }
|
||||
assert_redirected_to job_url(@job)
|
||||
end
|
||||
|
||||
test "should destroy job" do
|
||||
assert_difference("Job.count", -1) do
|
||||
delete job_url(@job)
|
||||
end
|
||||
|
||||
assert_redirected_to jobs_url
|
||||
end
|
||||
end
|
||||
35
test/fixtures/jobs.yml
vendored
Normal file
35
test/fixtures/jobs.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
operator_id: one
|
||||
costumer_id: one
|
||||
operator_firstname: MyString
|
||||
operator_lastname: MyString
|
||||
costumer_firstname: MyString
|
||||
costumer_lastname: MyString
|
||||
paid: false
|
||||
printed_at: 2024-07-27 12:13:47
|
||||
intern: false
|
||||
cost_center: MyString
|
||||
number_of_plans_a0: 1
|
||||
number_of_plans_a1: 1
|
||||
number_of_plans_a2: 1
|
||||
number_of_plans_a3: 1
|
||||
costum_qm_plan: 1.5
|
||||
|
||||
two:
|
||||
operator_id: two
|
||||
costumer_id: two
|
||||
operator_firstname: MyString
|
||||
operator_lastname: MyString
|
||||
costumer_firstname: MyString
|
||||
costumer_lastname: MyString
|
||||
paid: false
|
||||
printed_at: 2024-07-27 12:13:47
|
||||
intern: false
|
||||
cost_center: MyString
|
||||
number_of_plans_a0: 1
|
||||
number_of_plans_a1: 1
|
||||
number_of_plans_a2: 1
|
||||
number_of_plans_a3: 1
|
||||
costum_qm_plan: 1.5
|
||||
7
test/models/job_test.rb
Normal file
7
test/models/job_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class JobTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
69
test/system/jobs_test.rb
Normal file
69
test/system/jobs_test.rb
Normal file
@@ -0,0 +1,69 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class JobsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@job = jobs(:one)
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit jobs_url
|
||||
assert_selector "h1", text: "Jobs"
|
||||
end
|
||||
|
||||
test "should create job" do
|
||||
visit jobs_url
|
||||
click_on "New job"
|
||||
|
||||
fill_in "Cost center", with: @job.cost_center
|
||||
fill_in "Costum qm plan", with: @job.costum_qm_plan
|
||||
fill_in "Costumer firstname", with: @job.costumer_firstname
|
||||
fill_in "Costumer id", with: @job.costumer_id_id
|
||||
fill_in "Costumer lastname", with: @job.costumer_lastname
|
||||
check "Intern" if @job.intern
|
||||
fill_in "Number of plans a0", with: @job.number_of_plans_a0
|
||||
fill_in "Number of plans a1", with: @job.number_of_plans_a1
|
||||
fill_in "Number of plans a2", with: @job.number_of_plans_a2
|
||||
fill_in "Number of plans a3", with: @job.number_of_plans_a3
|
||||
fill_in "Operator firstname", with: @job.operator_firstname
|
||||
fill_in "Operator id", with: @job.operator_id_id
|
||||
fill_in "Operator lastname", with: @job.operator_lastname
|
||||
check "Paid" if @job.paid
|
||||
fill_in "Printed at", with: @job.printed_at
|
||||
click_on "Create Job"
|
||||
|
||||
assert_text "Job was successfully created"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should update Job" do
|
||||
visit job_url(@job)
|
||||
click_on "Edit this job", match: :first
|
||||
|
||||
fill_in "Cost center", with: @job.cost_center
|
||||
fill_in "Costum qm plan", with: @job.costum_qm_plan
|
||||
fill_in "Costumer firstname", with: @job.costumer_firstname
|
||||
fill_in "Costumer id", with: @job.costumer_id_id
|
||||
fill_in "Costumer lastname", with: @job.costumer_lastname
|
||||
check "Intern" if @job.intern
|
||||
fill_in "Number of plans a0", with: @job.number_of_plans_a0
|
||||
fill_in "Number of plans a1", with: @job.number_of_plans_a1
|
||||
fill_in "Number of plans a2", with: @job.number_of_plans_a2
|
||||
fill_in "Number of plans a3", with: @job.number_of_plans_a3
|
||||
fill_in "Operator firstname", with: @job.operator_firstname
|
||||
fill_in "Operator id", with: @job.operator_id_id
|
||||
fill_in "Operator lastname", with: @job.operator_lastname
|
||||
check "Paid" if @job.paid
|
||||
fill_in "Printed at", with: @job.printed_at
|
||||
click_on "Update Job"
|
||||
|
||||
assert_text "Job was successfully updated"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should destroy Job" do
|
||||
visit job_url(@job)
|
||||
click_on "Destroy this job", match: :first
|
||||
|
||||
assert_text "Job was successfully destroyed"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user