Scaffold job model
This commit is contained in:
70
app/controllers/jobs_controller.rb
Normal file
70
app/controllers/jobs_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class JobsController < ApplicationController
|
||||
before_action :set_job, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /jobs or /jobs.json
|
||||
def index
|
||||
@jobs = Job.all
|
||||
end
|
||||
|
||||
# GET /jobs/1 or /jobs/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /jobs/new
|
||||
def new
|
||||
@job = Job.new
|
||||
end
|
||||
|
||||
# GET /jobs/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /jobs or /jobs.json
|
||||
def create
|
||||
@job = Job.new(job_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @job.save
|
||||
format.html { redirect_to job_url(@job), notice: "Job was successfully created." }
|
||||
format.json { render :show, status: :created, location: @job }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @job.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /jobs/1 or /jobs/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @job.update(job_params)
|
||||
format.html { redirect_to job_url(@job), notice: "Job was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @job }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @job.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /jobs/1 or /jobs/1.json
|
||||
def destroy
|
||||
@job.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to jobs_url, notice: "Job was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_job
|
||||
@job = Job.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def job_params
|
||||
params.require(:job).permit(:operator_id_id, :costumer_id_id, :operator_firstname, :operator_lastname, :costumer_firstname, :costumer_lastname, :paid, :printed_at, :intern, :cost_center, :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan)
|
||||
end
|
||||
end
|
||||
2
app/helpers/jobs_helper.rb
Normal file
2
app/helpers/jobs_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module JobsHelper
|
||||
end
|
||||
4
app/models/job.rb
Normal file
4
app/models/job.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Job < ApplicationRecord
|
||||
belongs_to :operator_id
|
||||
belongs_to :costumer_id
|
||||
end
|
||||
92
app/views/jobs/_form.html.erb
Normal file
92
app/views/jobs/_form.html.erb
Normal file
@@ -0,0 +1,92 @@
|
||||
<%= form_with(model: job, class: "contents") do |form| %>
|
||||
<% if job.errors.any? %>
|
||||
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
|
||||
<h2><%= pluralize(job.errors.count, "error") %> prohibited this job from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% job.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :operator_id_id %>
|
||||
<%= form.text_field :operator_id_id, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :costumer_id_id %>
|
||||
<%= form.text_field :costumer_id_id, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :operator_firstname %>
|
||||
<%= form.text_field :operator_firstname, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :operator_lastname %>
|
||||
<%= form.text_field :operator_lastname, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :costumer_firstname %>
|
||||
<%= form.text_field :costumer_firstname, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :costumer_lastname %>
|
||||
<%= form.text_field :costumer_lastname, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :paid %>
|
||||
<%= form.check_box :paid, class: "block mt-2 h-5 w-5" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :printed_at %>
|
||||
<%= form.datetime_field :printed_at, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :intern %>
|
||||
<%= form.check_box :intern, class: "block mt-2 h-5 w-5" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :cost_center %>
|
||||
<%= form.text_field :cost_center, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :number_of_plans_a0 %>
|
||||
<%= form.number_field :number_of_plans_a0, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :number_of_plans_a1 %>
|
||||
<%= form.number_field :number_of_plans_a1, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :number_of_plans_a2 %>
|
||||
<%= form.number_field :number_of_plans_a2, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :number_of_plans_a3 %>
|
||||
<%= form.number_field :number_of_plans_a3, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :costum_qm_plan %>
|
||||
<%= form.text_field :costum_qm_plan, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
|
||||
</div>
|
||||
<% end %>
|
||||
77
app/views/jobs/_job.html.erb
Normal file
77
app/views/jobs/_job.html.erb
Normal file
@@ -0,0 +1,77 @@
|
||||
<div id="<%= dom_id job %>">
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Operator:</strong>
|
||||
<%= job.operator_id_id %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Costumer:</strong>
|
||||
<%= job.costumer_id_id %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Operator firstname:</strong>
|
||||
<%= job.operator_firstname %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Operator lastname:</strong>
|
||||
<%= job.operator_lastname %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Costumer firstname:</strong>
|
||||
<%= job.costumer_firstname %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Costumer lastname:</strong>
|
||||
<%= job.costumer_lastname %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Paid:</strong>
|
||||
<%= job.paid %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Printed at:</strong>
|
||||
<%= job.printed_at %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Intern:</strong>
|
||||
<%= job.intern %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Cost center:</strong>
|
||||
<%= job.cost_center %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Number of plans a0:</strong>
|
||||
<%= job.number_of_plans_a0 %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Number of plans a1:</strong>
|
||||
<%= job.number_of_plans_a1 %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Number of plans a2:</strong>
|
||||
<%= job.number_of_plans_a2 %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Number of plans a3:</strong>
|
||||
<%= job.number_of_plans_a3 %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Costum qm plan:</strong>
|
||||
<%= job.costum_qm_plan %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
2
app/views/jobs/_job.json.jbuilder
Normal file
2
app/views/jobs/_job.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! job, :id, :operator_id_id, :costumer_id_id, :operator_firstname, :operator_lastname, :costumer_firstname, :costumer_lastname, :paid, :printed_at, :intern, :cost_center, :number_of_plans_a0, :number_of_plans_a1, :number_of_plans_a2, :number_of_plans_a3, :costum_qm_plan, :created_at, :updated_at
|
||||
json.url job_url(job, format: :json)
|
||||
8
app/views/jobs/edit.html.erb
Normal file
8
app/views/jobs/edit.html.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">Editing job</h1>
|
||||
|
||||
<%= render "form", job: @job %>
|
||||
|
||||
<%= link_to "Show this job", @job, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to jobs", jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
21
app/views/jobs/index.html.erb
Normal file
21
app/views/jobs/index.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="w-full">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<% content_for :title, "Jobs" %>
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<h1 class="font-bold text-4xl">Jobs</h1>
|
||||
<%= link_to "New job", new_job_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
|
||||
</div>
|
||||
|
||||
<div id="jobs" class="min-w-full">
|
||||
<% @jobs.each do |job| %>
|
||||
<%= render job %>
|
||||
<p>
|
||||
<%= link_to "Show this job", job, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/jobs/index.json.jbuilder
Normal file
1
app/views/jobs/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @jobs, partial: "jobs/job", as: :job
|
||||
7
app/views/jobs/new.html.erb
Normal file
7
app/views/jobs/new.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">New job</h1>
|
||||
|
||||
<%= render "form", job: @job %>
|
||||
|
||||
<%= link_to "Back to jobs", jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
15
app/views/jobs/show.html.erb
Normal file
15
app/views/jobs/show.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="mx-auto md:w-2/3 w-full flex">
|
||||
<div class="mx-auto">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<%= render @job %>
|
||||
|
||||
<%= link_to "Edit this job", edit_job_path(@job), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to jobs", jobs_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<div class="inline-block ml-2">
|
||||
<%= button_to "Destroy this job", @job, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/jobs/show.json.jbuilder
Normal file
1
app/views/jobs/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "jobs/job", job: @job
|
||||
@@ -1,4 +1,5 @@
|
||||
Rails.application.routes.draw do
|
||||
resources :jobs
|
||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||
|
||||
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
||||
@@ -6,5 +7,5 @@ Rails.application.routes.draw do
|
||||
get "up" => "rails/health#show", as: :rails_health_check
|
||||
|
||||
# Defines the root path route ("/")
|
||||
# root "posts#index"
|
||||
root "jobs#index"
|
||||
end
|
||||
|
||||
23
db/migrate/20240727101347_create_jobs.rb
Normal file
23
db/migrate/20240727101347_create_jobs.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
class CreateJobs < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :jobs do |t|
|
||||
t.references :operator_id, null: false, foreign_key: true
|
||||
t.references :costumer_id, null: false, foreign_key: true
|
||||
t.string :operator_firstname
|
||||
t.string :operator_lastname
|
||||
t.string :costumer_firstname
|
||||
t.string :costumer_lastname
|
||||
t.boolean :paid
|
||||
t.datetime :printed_at
|
||||
t.boolean :intern
|
||||
t.string :cost_center
|
||||
t.integer :number_of_plans_a0
|
||||
t.integer :number_of_plans_a1
|
||||
t.integer :number_of_plans_a2
|
||||
t.integer :number_of_plans_a3
|
||||
t.float :costum_qm_plan
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
38
db/schema.rb
generated
Normal file
38
db/schema.rb
generated
Normal file
@@ -0,0 +1,38 @@
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# This file is the source Rails uses to define your schema when running `bin/rails
|
||||
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
||||
# be faster and is potentially less error prone than running all of your
|
||||
# migrations from scratch. Old migrations may fail to apply correctly if those
|
||||
# migrations use external dependencies or application code.
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_07_27_101347) do
|
||||
create_table "jobs", force: :cascade do |t|
|
||||
t.integer "operator_id_id", null: false
|
||||
t.integer "costumer_id_id", null: false
|
||||
t.string "operator_firstname"
|
||||
t.string "operator_lastname"
|
||||
t.string "costumer_firstname"
|
||||
t.string "costumer_lastname"
|
||||
t.boolean "paid"
|
||||
t.datetime "printed_at"
|
||||
t.boolean "intern"
|
||||
t.string "cost_center"
|
||||
t.integer "number_of_plans_a0"
|
||||
t.integer "number_of_plans_a1"
|
||||
t.integer "number_of_plans_a2"
|
||||
t.integer "number_of_plans_a3"
|
||||
t.float "costum_qm_plan"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["costumer_id_id"], name: "index_jobs_on_costumer_id_id"
|
||||
t.index ["operator_id_id"], name: "index_jobs_on_operator_id_id"
|
||||
end
|
||||
|
||||
add_foreign_key "jobs", "costumer_ids"
|
||||
add_foreign_key "jobs", "operator_ids"
|
||||
end
|
||||
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