All Files
(0.0%
covered at
0.0
hits/line)
20 files in total.
226 relevant lines.
0 lines covered and
226 lines missed
Controllers
(0.0%
covered at
0.0
hits/line)
5 files in total.
156 relevant lines.
0 lines covered and
156 lines missed
Channels
(100.0%
covered at
0.0
hits/line)
0 files in total.
0.0 relevant lines.
0.0 lines covered and
0.0 lines missed
File |
% covered |
Lines |
Relevant Lines |
Lines covered |
Lines missed |
Avg. Hits / Line |
Models
(0.0%
covered at
0.0
hits/line)
6 files in total.
26 relevant lines.
0 lines covered and
26 lines missed
Mailers
(0.0%
covered at
0.0
hits/line)
1 files in total.
4 relevant lines.
0 lines covered and
4 lines missed
Helpers
(0.0%
covered at
0.0
hits/line)
5 files in total.
10 relevant lines.
0 lines covered and
10 lines missed
Jobs
(0.0%
covered at
0.0
hits/line)
1 files in total.
2 relevant lines.
0 lines covered and
2 lines missed
Libraries
(100.0%
covered at
0.0
hits/line)
0 files in total.
0.0 relevant lines.
0.0 lines covered and
0.0 lines missed
File |
% covered |
Lines |
Relevant Lines |
Lines covered |
Lines missed |
Avg. Hits / Line |
Services
(0.0%
covered at
0.0
hits/line)
2 files in total.
28 relevant lines.
0 lines covered and
28 lines missed
-
class ApplicationController < ActionController::Base
-
end
-
class AutomobilesController < ApplicationController
-
before_action :set_automobile, only: [:show, :edit, :update, :destroy]
-
-
# GET /automobiles
-
# GET /automobiles.json
-
def index
-
@automobiles = Automobile.includes(:manufacture).all
-
end
-
-
# GET /automobiles/1
-
# GET /automobiles/1.json
-
def show
-
end
-
-
# GET /automobiles/new
-
def new
-
@automobile = Automobile.new
-
end
-
-
# GET /automobiles/1/edit
-
def edit
-
end
-
-
# POST /automobiles
-
# POST /automobiles.json
-
def create
-
@automobile = Automobile.new(automobile_params)
-
-
respond_to do |format|
-
if @automobile.save
-
format.html { redirect_to @automobile, notice: 'Automobile was successfully created.' }
-
format.json { render :show, status: :created, location: @automobile }
-
else
-
format.html { render :new }
-
format.json { render json: @automobile.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /automobiles/1
-
# PATCH/PUT /automobiles/1.json
-
def update
-
respond_to do |format|
-
if @automobile.update(automobile_params)
-
format.html { redirect_to @automobile, notice: 'Automobile was successfully updated.' }
-
format.json { render :show, status: :ok, location: @automobile }
-
else
-
format.html { render :edit }
-
format.json { render json: @automobile.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /automobiles/1
-
# DELETE /automobiles/1.json
-
def destroy
-
@automobile.destroy
-
respond_to do |format|
-
format.html { redirect_to automobiles_url, notice: 'Automobile was successfully destroyed.' }
-
format.json { head :no_content }
-
end
-
end
-
-
private
-
# Use callbacks to share common setup or constraints between actions.
-
def set_automobile
-
@automobile = Automobile.includes(:parts).find(params[:id])
-
end
-
-
# Never trust parameters from the scary internet, only allow the white list through.
-
def automobile_params
-
params.require(:automobile).permit(:manufacture_id, :name, :year, part_ids: [])
-
end
-
end
-
class ManufacturesController < ApplicationController
-
before_action :set_manufacture, only: [:show, :edit, :update, :destroy]
-
-
# GET /manufactures
-
# GET /manufactures.json
-
def index
-
@manufactures = Manufacture.all
-
end
-
-
# GET /manufactures/1
-
# GET /manufactures/1.json
-
def show
-
end
-
-
# GET /manufactures/new
-
def new
-
@manufacture = Manufacture.new
-
end
-
-
# GET /manufactures/1/edit
-
def edit
-
end
-
-
# POST /manufactures
-
# POST /manufactures.json
-
def create
-
@manufacture = Manufacture.new(manufacture_params)
-
-
respond_to do |format|
-
if @manufacture.save
-
format.html { redirect_to @manufacture, notice: 'Manufacture was successfully created.' }
-
format.json { render :show, status: :created, location: @manufacture }
-
else
-
format.html { render :new }
-
format.json { render json: @manufacture.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /manufactures/1
-
# PATCH/PUT /manufactures/1.json
-
def update
-
respond_to do |format|
-
if @manufacture.update(manufacture_params)
-
format.html { redirect_to @manufacture, notice: 'Manufacture was successfully updated.' }
-
format.json { render :show, status: :ok, location: @manufacture }
-
else
-
format.html { render :edit }
-
format.json { render json: @manufacture.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /manufactures/1
-
# DELETE /manufactures/1.json
-
def destroy
-
@manufacture.destroy
-
respond_to do |format|
-
format.html { redirect_to manufactures_url, notice: 'Manufacture was successfully destroyed.' }
-
format.json { head :no_content }
-
end
-
end
-
-
private
-
# Use callbacks to share common setup or constraints between actions.
-
def set_manufacture
-
@manufacture = Manufacture.find(params[:id])
-
end
-
-
# Never trust parameters from the scary internet, only allow the white list through.
-
def manufacture_params
-
params.require(:manufacture).permit(:name)
-
end
-
end
-
class RecallsController < ApplicationController
-
before_action :set_recall, only: [:show, :edit, :update, :destroy]
-
-
# GET /recalls
-
# GET /recalls.json
-
def index
-
@recalls = Recall.all
-
end
-
-
# GET /recalls/1
-
# GET /recalls/1.json
-
def show
-
end
-
-
# GET /recalls/new
-
def new
-
@recall = Recall.new
-
end
-
-
# GET /recalls/1/edit
-
def edit
-
end
-
-
# POST /recalls
-
# POST /recalls.json
-
def create
-
@recall = Recall.new(recall_params)
-
-
respond_to do |format|
-
if @recall.save
-
format.html { redirect_to @recall, notice: 'Recall was successfully created.' }
-
format.json { render :show, status: :created, location: @recall }
-
else
-
format.html { render :new }
-
format.json { render json: @recall.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /recalls/1
-
# PATCH/PUT /recalls/1.json
-
def update
-
respond_to do |format|
-
if @recall.update(recall_params)
-
format.html { redirect_to @recall, notice: 'Recall was successfully updated.' }
-
format.json { render :show, status: :ok, location: @recall }
-
else
-
format.html { render :edit }
-
format.json { render json: @recall.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /recalls/1
-
# DELETE /recalls/1.json
-
def destroy
-
@recall.destroy
-
respond_to do |format|
-
format.html { redirect_to recalls_url, notice: 'Recall was successfully destroyed.' }
-
format.json { head :no_content }
-
end
-
end
-
-
private
-
# Use callbacks to share common setup or constraints between actions.
-
def set_recall
-
@recall = Recall.find(params[:id])
-
end
-
-
# Never trust parameters from the scary internet, only allow the white list through.
-
def recall_params
-
params.require(:recall).permit(:part_id, :description)
-
end
-
end
-
class WelcomeController < ApplicationController
-
def index
-
end
-
end
-
module ApplicationHelper
-
end
-
module AutomobilesHelper
-
end
-
module ManufacturesHelper
-
end
-
class ApplicationJob < ActiveJob::Base
-
# Automatically retry jobs that encountered a deadlock
-
# retry_on ActiveRecord::Deadlocked
-
-
# Most jobs are safe to ignore if the underlying records are no longer available
-
# discard_on ActiveJob::DeserializationError
-
end
-
class ApplicationMailer < ActionMailer::Base
-
default from: 'from@example.com'
-
layout 'mailer'
-
end
-
class ApplicationRecord < ActiveRecord::Base
-
self.abstract_class = true
-
end
-
class Automobile < ApplicationRecord
-
belongs_to :manufacture
-
-
has_many :automobile_parts, dependent: :destroy
-
has_many :parts, through: :automobile_parts
-
end
-
class AutomobilePart < ApplicationRecord
-
belongs_to :automobile
-
belongs_to :part
-
end
-
class Manufacture < ApplicationRecord
-
has_many :automobiles, dependent: :destroy
-
end
-
class Part < ApplicationRecord
-
has_many :automobile_parts
-
has_many :automobiles, through: :automobile_parts
-
has_many :recalls
-
end
-
class Recall < ApplicationRecord
-
belongs_to :part
-
-
def number_of_affected_automobiles
-
part.automobiles.size # + 1
-
end
-
end
-
module Automobiles
-
class CalculatePrice
-
# Automobiles::CalculatePrice.new(automobile).call
-
# Automobiles::CalculatePrice.call(automobile)
-
-
def self.call(automobile)
-
new(automobile).call
-
end
-
-
attr_accessor :automobile
-
def initialize(automobile)
-
@automobile = automobile
-
end
-
-
def call
-
automobile.parts.sum(:price)
-
end
-
end
-
end
-
module Automobiles
-
class CalculateWeight
-
# Automobiles::CalculateWeight.new(automobile).call
-
# Automobiles::CalculateWeight.call(automobile)
-
-
def self.call(automobile)
-
new(automobile).call
-
end
-
-
attr_accessor :automobile
-
def initialize(automobile)
-
@automobile = automobile
-
end
-
-
def call
-
automobile.parts.sum(:weight)
-
end
-
end
-
end