All Files ( 99.89% covered at 3.83 hits/line )
150 files in total.
2815 relevant lines,
2812 lines covered and
3 lines missed.
(
99.89%
)
-
# frozen_string_literal: true
-
-
1
module Admin
-
# Admin Base Controller
-
1
class BaseController < ApplicationController
-
1
include AdminSessionAction
-
1
layout 'admin'
-
1
before_action :let_admin_user_login
-
end
-
end
-
# frozen_string_literal: true
-
-
1
module Admin
-
# Admin Sessions Controller
-
1
class SessionsController < Admin::BaseController
-
1
before_action :let_admin_user_login, only: %i[]
-
1
def index
-
1
@admin_user = AdminUser.new
-
end
-
-
1
def login
-
2
user = AdminUser.find_by(login_name: params[:admin_user][:login_name])
-
2
if user&.authenticate(params[:admin_user][:password])
-
1
login_action(user)
-
else
-
1
login_fail_action
-
end
-
end
-
-
1
def logout
-
1
reset_session
-
1
redirect_to({ action: :index }, { notice: t('controller.common.logout') })
-
end
-
-
1
private
-
-
1
def login_params
-
1
params.require(:admin_user).permit(:login_name, :password)
-
end
-
-
1
def login_action(user)
-
1
reset_session
-
1
session[:admin_user_id] = user.id
-
1
redirect_to action: :index, controller: :top
-
end
-
-
1
def login_fail_action
-
1
flash.now[:error] = t('controller.common.not_authenticated')
-
1
@admin_user = AdminUser.new login_params
-
1
render :index
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
module Admin
-
# Admin Top Controller
-
1
class TopController < Admin::BaseController
-
1
def index; end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
module Admin
-
# Admin Users Controller
-
1
class UsersController < Admin::BaseController
-
1
before_action :set_user, only: %i[show edit update destroy]
-
-
# GET /admin/users
-
# GET /admin/users.json
-
1
def index
-
1
@users = User.all
-
end
-
-
# GET /admin/users/1
-
# GET /admin/users/1.json
-
1
def show; end
-
-
# GET /admin/users/new
-
1
def new
-
1
@user = User.new
-
end
-
-
# GET /admin/users/1/edit
-
1
def edit; end
-
-
# POST /admin/users
-
# POST /admin/users.json
-
1
def create
-
4
@user = User.new(user_params)
-
-
4
respond_to do |format|
-
4
if @user.save
-
2
format.html do
-
2
redirect_to [:admin, @user],
-
notice: I18n.t('controller.common.success_on_create', model_name: User.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @user }
-
else
-
4
format.html { render :new }
-
2
format.json { render json: @user.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /admin/users/1
-
# PATCH/PUT /admin/users/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @user.update(user_params)
-
2
format.html do
-
2
redirect_to [:admin, @user],
-
notice: I18n.t('controller.common.success_on_update', model_name: User.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @user }
-
else
-
2
format.html { render :edit }
-
1
format.json { render json: @user.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /admin/users/1
-
# DELETE /admin/users/1.json
-
1
def destroy
-
2
@user.destroy
-
2
respond_to do |format|
-
4
format.html { redirect_to admin_users_url, notice: 'User was successfully destroyed.' }
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_user
-
7
@user = User.find(params[:id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def user_params
-
7
params.fetch(:user, {}).permit(:login_name, :password)
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
# ApplicationController
-
1
class ApplicationController < ActionController::Base
-
end
-
# frozen_string_literal: true
-
-
# BridgeContentInjuriesController
-
1
class BridgeContentInjuriesController < UserBaseController
-
1
before_action :set_regular_inspection
-
1
before_action :set_injury
-
1
before_action :set_bridge_content_injury, only: %i[show edit update destroy]
-
-
# GET /regular_inspections/1/injuries/1/bridge_content_injuries
-
# GET /regular_inspections/1/injuries/1/bridge_content_injuries.json
-
1
def index
-
1
@bridge_content_injuries = BridgeContentInjury.where(injury: @injury).all
-
end
-
-
# GET /regular_inspections/1/injuries/1/bridge_content_injuries/1
-
# GET /regular_inspections/1/injuries/1/bridge_content_injuries/1.json
-
1
def show; end
-
-
# GET /regular_inspections/1/injuries/1/bridge_content_injuries/new
-
1
def new
-
1
@bridge_content_injury = BridgeContentInjury.new(injury: @injury)
-
end
-
-
# GET /regular_inspections/1/injuries/1/bridge_content_injuries/1/edit
-
1
def edit; end
-
-
# POST /regular_inspections/1/injuries/1/bridge_content_injuries
-
# POST /regular_inspections/1/injuries/1/bridge_content_injuries.json
-
1
def create
-
4
@bridge_content_injury = BridgeContentInjury.new(bridge_content_injury_params)
-
4
@bridge_content_injury.injury = @injury
-
-
4
respond_to do |format|
-
4
if @bridge_content_injury.save
-
2
format.html do
-
2
redirect_to [@regular_inspection, @injury, @bridge_content_injury],
-
notice: I18n.t('controller.common.success_on_create',
-
model_name: BridgeContentInjury.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @bridge_content_injury }
-
else
-
4
format.html { render :new }
-
2
format.json { render json: @bridge_content_injury.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /regular_inspections/1/injuries/1/bridge_content_injuries/1
-
# PATCH/PUT /regular_inspections/1/injuries/1/bridge_content_injuries/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @bridge_content_injury.update(bridge_content_injury_params)
-
2
format.html do
-
2
redirect_to [@regular_inspection, @injury, @bridge_content_injury],
-
notice: I18n.t('controller.common.success_on_update',
-
model_name: BridgeContentInjury.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @bridge_content_injury }
-
else
-
2
format.html { render :edit }
-
1
format.json { render json: @bridge_content_injury.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /regular_inspections/1/injuries/1/bridge_content_injuries/1
-
# DELETE /regular_inspections/1/injuries/1/bridge_content_injuries/1.json
-
1
def destroy
-
2
@bridge_content_injury.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
-
notice: I18n.t('controller.common.success_on_destroy',
-
model_name: BridgeContentInjury.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_bridge_content_injury
-
7
@bridge_content_injury = BridgeContentInjury.joins(:bridge_content, :injury)
-
.where(injury: @injury)
-
.find(params[:id])
-
end
-
-
1
def set_regular_inspection
-
13
@regular_inspection = RegularInspection.joins(:bridge)
-
.includes(:bridge_contents)
-
.find(params[:regular_inspection_id])
-
end
-
-
1
def set_injury
-
13
@injury = Injury.includes(:bridge_content_injuries)
-
.find(params[:injury_id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def bridge_content_injury_params
-
7
params.fetch(:bridge_content_injury, {}).permit(:bridge_content_id, :seek, :ortho_geojson, :pointposition)
-
end
-
end
-
# frozen_string_literal: true
-
-
# BridgeContentsController
-
1
class BridgeContentsController < UserBaseController
-
1
before_action :set_regular_inspection
-
1
before_action :set_bridge_content, only: %i[show edit update destroy]
-
-
# GET /regular_inspections/1/bridge_contents
-
# GET /regular_inspections/1/bridge_contents.json
-
1
def index
-
1
@bridge_contents = BridgeContent.where(regular_inspection: @regular_inspection).all
-
end
-
-
# GET /regular_inspections/1/bridge_contents/1
-
# GET /regular_inspections/1/bridge_contents/1.json
-
1
def show; end
-
-
# GET /regular_inspections/1/bridge_contents/new
-
1
def new
-
1
@bridge_content = BridgeContent.new(regular_inspection: @regular_inspection)
-
end
-
-
# GET /regular_inspections/1/bridge_contents/1/edit
-
1
def edit; end
-
-
# POST /regular_inspections/1/bridge_contents
-
# POST /regular_inspections/1/bridge_contents.json
-
1
def create
-
4
@bridge_content = BridgeContent.new(bridge_content_params)
-
4
@bridge_content.regular_inspection = @regular_inspection
-
-
4
respond_to do |format|
-
4
if @bridge_content.save
-
2
format.html do
-
2
redirect_to [@regular_inspection, @bridge_content],
-
notice: I18n.t('controller.common.success_on_create', model_name: BridgeContent.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @bridge_content }
-
else
-
4
format.html { render :new }
-
2
format.json { render json: @bridge_content.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /regular_inspections/1/bridge_contents/1
-
# PATCH/PUT /regular_inspections/1/bridge_contents/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @bridge_content.update(bridge_content_params)
-
2
format.html do
-
2
redirect_to [@regular_inspection, @bridge_content],
-
notice: I18n.t('controller.common.success_on_update', model_name: BridgeContent.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @bridge_content }
-
else
-
2
format.html { render :edit }
-
1
format.json { render json: @bridge_content.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /regular_inspections/1/bridge_contents/1
-
# DELETE /regular_inspections/1/bridge_contents/1.json
-
1
def destroy
-
2
@bridge_content.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to regular_inspection_bridge_contents_url(@regular_inspection),
-
notice: I18n.t('controller.common.success_on_destroy', model_name: BridgeContent.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_bridge_content
-
7
@bridge_content = BridgeContent.where(regular_inspection: @regular_inspection)
-
.includes(:bridge_content_injury).find(params[:id])
-
end
-
-
1
def set_regular_inspection
-
13
@regular_inspection = RegularInspection.joins(:bridge).find(params[:regular_inspection_id])
-
13
@components = @regular_inspection.bridge.components
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def bridge_content_params
-
7
params.fetch(:bridge_content, {}).permit(:title, :data, :data_type, :position_entry_type, :component_id,
-
:center_x, :center_y, :center_z,
-
:euler_angle_alpha, :euler_angle_beta, :euler_angle_gamma,
-
:quaternion_one, :quaternion_two, :quaternion_three, :quaternion_four,
-
:bbox_u_r_x, :bbox_u_r_y, :bbox_u_r_z,
-
:bbox_u_l_x, :bbox_u_l_y, :bbox_u_l_z,
-
:bbox_d_r_x, :bbox_d_r_y, :bbox_d_r_z,
-
:bbox_d_l_x, :bbox_d_l_y, :bbox_d_l_z,
-
:photo_dimentions, :date_of_shooting, :projection_method,
-
:target_material, :damage_or_not, :representative_photo,
-
:pointcloud_data_id, :pointcloud_creation_name,
-
:pointcloud_created_at, :pointcloud_measurement_method,
-
:pointcloud_measurement_environment, :pointcloud_measuring_equipment,
-
:pointcloud_analysis_method, :pointcloud_software,
-
:pointcloud_crs, :pointcloud_reference_point_x,
-
:pointcloud_reference_point_y, :pointcloud_reference_point_z)
-
end
-
end
-
# frozen_string_literal: true
-
-
# BridgeMainContentsController
-
1
class BridgeMainContentsController < UserBaseController
-
1
before_action :set_regular_inspection
-
1
before_action :set_bridge_main_content, only: %i[destroy]
-
-
# POST /regular_inspections/1/bridge_main_contents
-
# POST /regular_inspections/1/bridge_main_contents.json
-
1
def create
-
4
@bridge_main_content = BridgeMainContent.new(bridge_main_content_params)
-
-
4
respond_to do |format|
-
4
if @bridge_main_content.save
-
2
format.html do
-
2
redirect_to regular_inspection_bridge_contents_url(@regular_inspection),
-
notice: I18n.t('controller.common.success_on_create',
-
model_name: BridgeMainContent.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @bridge_main_content }
-
else
-
4
format.html { redirect_to regular_inspection_bridge_contents_url(@regular_inspection) }
-
2
format.json { render json: @bridge_main_content.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /regular_inspections/1/bridge_main_contents/1
-
# DELETE /regular_inspections/1/bridge_main_contents/1.json
-
1
def destroy
-
2
@bridge_main_content.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to regular_inspection_bridge_contents_url(@regular_inspection),
-
notice: I18n.t('controller.common.success_on_destroy',
-
model_name: BridgeMainContent.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_bridge_main_content
-
2
@bridge_main_content = BridgeMainContent.find(params[:id])
-
end
-
-
1
def set_regular_inspection
-
6
@regular_inspection = RegularInspection.joins(:bridge).find(params[:regular_inspection_id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def bridge_main_content_params
-
4
params.fetch(:bridge_main_content, {}).permit(:bridge_content_id)
-
end
-
end
-
# frozen_string_literal: true
-
-
# BridgesController
-
1
class BridgesController < UserBaseController
-
1
before_action :set_bridge, only: %i[show edit update destroy]
-
-
# GET /bridges
-
# GET /bridges.json
-
1
def index
-
1
@bridges = Bridge.all
-
end
-
-
# GET /bridges/1
-
# GET /bridges/1.json
-
1
def show; end
-
-
# GET /bridges/new
-
1
def new
-
1
@bridge = Bridge.new
-
1
@bridge.location = 'POINT(140.084556 36.104611)'
-
end
-
-
# GET /bridges/1/edit
-
1
def edit; end
-
-
# POST /bridges
-
# POST /bridges.json
-
1
def create
-
4
@bridge = Bridge.new(bridge_params)
-
-
4
respond_to do |format|
-
4
if @bridge.save
-
2
format.html do
-
2
redirect_to @bridge,
-
notice: I18n.t('controller.common.success_on_create', model_name: Bridge.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @bridge }
-
else
-
4
format.html { render :new }
-
2
format.json { render json: @bridge.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /bridges/1
-
# PATCH/PUT /bridges/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @bridge.update(bridge_params)
-
2
format.html do
-
2
redirect_to @bridge,
-
notice: I18n.t('controller.common.success_on_update', model_name: Bridge.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @bridge }
-
else
-
2
format.html { render :edit }
-
1
format.json { render json: @bridge.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /bridges/1
-
# DELETE /bridges/1.json
-
1
def destroy
-
2
@bridge.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to bridges_url,
-
notice: I18n.t('controller.common.success_on_destroy', model_name: Bridge.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_bridge
-
7
@bridge = Bridge.includes(:soundnesses, :regular_inspections).find(params[:id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def bridge_params
-
7
params.fetch(:bridge, {}).permit(:title, :address, :location, :road_name, :bridge_length, :width,
-
:applicable_specifications_upper, :applicable_specifications_lower,
-
:traffic_count, :large_vehicle_mixing_rate, :year_in_service,
-
:priority, :administrator_name, :bridge_type,
-
:street_condition, :availabillity_of_alternative_route,
-
:freeway_or_public_road, :emergency_transport_road,
-
:kana_title, :bridge_identification_number, :kind_of_bridge)
-
end
-
end
-
# frozen_string_literal: true
-
-
# ComponentsController
-
1
class ComponentsController < UserBaseController
-
1
before_action :set_bridge
-
1
before_action :set_component, only: %i[show edit update destroy]
-
-
# GET /components
-
# GET /components.json
-
1
def index
-
1
@components = Component.where(bridge: @bridge).all
-
end
-
-
# GET /components/1
-
# GET /components/1.json
-
1
def show; end
-
-
# GET /components/new
-
1
def new
-
1
@component = Component.new(bridge: @bridge)
-
end
-
-
# GET /components/1/edit
-
1
def edit; end
-
-
# POST /components
-
# POST /components.json
-
1
def create
-
4
@component = Component.new(component_params)
-
4
@component.bridge = @bridge
-
-
4
respond_to do |format|
-
4
if @component.save
-
2
format.html do
-
2
redirect_to [@bridge, @component],
-
notice: I18n.t('controller.common.success_on_create', model_name: Component.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @component }
-
else
-
4
format.html { render :new }
-
2
format.json { render json: @component.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /components/1
-
# PATCH/PUT /components/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @component.update(component_params)
-
2
format.html do
-
2
redirect_to [@bridge, @component],
-
notice: I18n.t('controller.common.success_on_update', model_name: Component.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @component }
-
else
-
2
format.html { render :edit }
-
1
format.json { render json: @component.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /components/1
-
# DELETE /components/1.json
-
1
def destroy
-
2
@component.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to bridge_components_url(@bridge),
-
notice: I18n.t('controller.common.success_on_destroy', model_name: Component.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_component
-
7
@component = Component.find(params[:id])
-
end
-
-
1
def set_bridge
-
13
@bridge = Bridge.find(params[:bridge_id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def component_params
-
7
params.fetch(:component, {}).permit(:span_number, :component_category, :title)
-
end
-
end
-
# frozen_string_literal: true
-
-
# AdminSession action concern
-
1
module AdminSessionAction
-
1
extend ActiveSupport::Concern
-
-
1
def let_admin_user_login
-
15
admin_user_id = session[:admin_user_id]
-
15
unless admin_user_id.blank?
-
14
@current_admin_user ||= AdminUser.find_by(id: admin_user_id)
-
14
return unless @current_admin_user.nil?
-
end
-
1
alert = 'need to login'
-
1
redirect_to(
-
{
-
controller: 'admin/sessions',
-
action: 'index'
-
}, {
-
alert: alert
-
}
-
)
-
end
-
end
-
# frozen_string_literal: true
-
-
# User Session action concern
-
1
module UserSessionAction
-
1
extend ActiveSupport::Concern
-
-
1
def let_user_login
-
121
user_id = session[:user_id]
-
121
unless user_id.blank?
-
120
@current_user ||= User.find_by(id: user_id)
-
120
return unless @current_user.nil?
-
end
-
1
alert = 'need to login'
-
1
redirect_to(
-
{
-
controller: 'sessions',
-
action: 'index'
-
}, {
-
alert: alert
-
}
-
)
-
end
-
end
-
# frozen_string_literal: true
-
-
# DiagnosesController
-
1
class DiagnosesController < UserBaseController
-
1
before_action :set_regular_inspection
-
1
before_action :set_diagnosis, only: %i[show edit update destroy]
-
-
# GET /regular_inspections/1/diagnoses
-
# GET /regular_inspections/1/diagnoses.json
-
1
def index
-
1
@diagnoses = Diagnosis.where(regular_inspection: @regular_inspection)
-
.includes(:injury).order(:component_category).all
-
end
-
-
# GET /regular_inspections/1/diagnoses/1
-
# GET /regular_inspections/1/diagnoses/1.json
-
1
def show; end
-
-
# GET /regular_inspections/1/diagnoses/new
-
1
def new
-
1
@diagnosis = Diagnosis.new(regular_inspection: @regular_inspection)
-
end
-
-
# GET /regular_inspections/1/diagnoses/1/edit
-
1
def edit; end
-
-
# POST /regular_inspections/1/diagnoses
-
# POST /regular_inspections/1/diagnoses.json
-
1
def create
-
4
@diagnosis = Diagnosis.new(diagnosis_params)
-
4
@diagnosis.regular_inspection = @regular_inspection
-
-
4
respond_to do |format|
-
4
if @diagnosis.save
-
2
format.html do
-
2
redirect_to [@regular_inspection, @diagnosis],
-
notice: I18n.t('controller.common.success_on_create', model_name: Diagnosis.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @diagnosis }
-
else
-
4
format.html { render :new }
-
2
format.json { render json: @diagnosis.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /regular_inspections/1/diagnoses/1
-
# PATCH/PUT /regular_inspections/1/diagnoses/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @diagnosis.update(diagnosis_params)
-
2
format.html do
-
2
redirect_to [@regular_inspection, @diagnosis],
-
notice: I18n.t('controller.common.success_on_update', model_name: Diagnosis.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @diagnosis }
-
else
-
2
format.html { render :edit }
-
1
format.json { render json: @diagnosis.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /regular_inspections/1/diagnoses/1
-
# DELETE /regular_inspections/1/diagnoses/1.json
-
1
def destroy
-
2
@diagnosis.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to regular_inspection_diagnoses_url(@regular_inspection),
-
notice: I18n.t('controller.common.success_on_destroy', model_name: Diagnosis.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_diagnosis
-
7
@diagnosis = Diagnosis.find(params[:id])
-
end
-
-
1
def set_regular_inspection
-
13
@regular_inspection = RegularInspection.joins(:bridge).includes(:injuries).find(params[:regular_inspection_id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def diagnosis_params
-
7
params.fetch(:diagnosis, {}).permit(:component_category, :result, :injury_id, :remark)
-
end
-
end
-
# frozen_string_literal: true
-
-
# InjuriesController
-
1
class InjuriesController < UserBaseController
-
1
before_action :set_regular_inspection
-
1
before_action :set_injury, only: %i[show edit update destroy]
-
-
# GET /regular_inspections/1/injuries
-
# GET /regular_inspections/1/injuries.json
-
1
def index
-
1
@injuries = Injury.where(regular_inspection: @regular_inspection).all
-
end
-
-
# GET /regular_inspections/1/injuries/1
-
# GET /regular_inspections/1/injuries/1.json
-
1
def show; end
-
-
# GET /regular_inspections/1/injuries/new
-
1
def new
-
1
@injury = Injury.new(regular_inspection: @regular_inspection)
-
1
@components = Component.where(bridge: @regular_inspection.bridge)
-
end
-
-
# GET /regular_inspections/1/injuries/1/edit
-
1
def edit
-
1
@components = Component.where(bridge: @regular_inspection.bridge)
-
end
-
-
# POST /regular_inspections/1/injuries
-
# POST /regular_inspections/1/injuries.json
-
1
def create
-
4
@injury = Injury.new(injury_params)
-
4
@injury.regular_inspection = @regular_inspection
-
-
4
respond_to do |format|
-
4
if @injury.save
-
2
format.html do
-
2
redirect_to [@regular_inspection, @injury],
-
notice: I18n.t('controller.common.success_on_create', model_name: Injury.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @injury }
-
else
-
2
@components = Component.where(bridge: @regular_inspection.bridge)
-
4
format.html { render :new }
-
2
format.json { render json: @injury.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /regular_inspections/1/injuries/1
-
# PATCH/PUT /regular_inspections/1/injuries/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @injury.update(injury_params)
-
2
format.html do
-
2
redirect_to [@regular_inspection, @injury],
-
notice: I18n.t('controller.common.success_on_update', model_name: Injury.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @injury }
-
else
-
1
@components = Component.where(bridge: @regular_inspection.bridge)
-
2
format.html { render :edit }
-
1
format.json { render json: @injury.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /regular_inspections/1/injuries/1
-
# DELETE /regular_inspections/1/injuries/1.json
-
1
def destroy
-
2
@injury.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to regular_inspection_injury_url(@regular_inspection),
-
notice: I18n.t('controller.common.success_on_destroy', model_name: Injury.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_injury
-
7
@injury = Injury.where(regular_inspection: @regular_inspection).find(params[:id])
-
end
-
-
1
def set_regular_inspection
-
13
@regular_inspection = RegularInspection.joins(:bridge).find(params[:regular_inspection_id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def injury_params
-
7
params.fetch(:injury, {}).permit(:component_id, :injury_type, :injury_grade, :quantitatively_obtained_value,
-
:unit, :injury_pattern, :classification, :impression)
-
end
-
end
-
# frozen_string_literal: true
-
-
# Mlti Importers Controller
-
1
class MlitImportersController < UserBaseController
-
1
def new; end
-
-
1
def preview
-
2
update_file = preview_params[:upload_file]
-
2
@bridge = MlitImporter.import(update_file)
-
2
render :new unless @bridge.valid?
-
end
-
-
1
def create
-
4
@bridge = Bridge.new(bridge_params)
-
-
4
respond_to do |format|
-
4
if @bridge.save
-
2
format.html do
-
2
redirect_to @bridge,
-
notice: I18n.t('controller.common.success_on_create', model_name: Bridge.model_name.human)
-
end
-
else
-
4
format.html { render :new }
-
end
-
end
-
end
-
-
1
private
-
-
1
def preview_params
-
2
params.permit(:upload_file)
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def bridge_params
-
4
params.fetch(:bridge, {}).permit(:title, :address, :location, :road_name)
-
end
-
end
-
# frozen_string_literal: true
-
-
# Regular Inspections Controller
-
1
class RegularInspectionsController < UserBaseController
-
1
before_action :set_regular_inspection, only: %i[show edit update destroy]
-
-
# GET /regular_inspections
-
# GET /regular_inspections.json
-
1
def index
-
1
@regular_inspections = RegularInspection.joins(:bridge).all
-
end
-
-
# GET /regular_inspections/1
-
# GET /regular_inspections/1.json
-
1
def show; end
-
-
# GET /regular_inspections/new
-
1
def new
-
1
@regular_inspection = RegularInspection.new
-
end
-
-
# GET /regular_inspections/1/edit
-
1
def edit; end
-
-
# POST /regular_inspections
-
# POST /regular_inspections.json
-
1
def create
-
4
@regular_inspection = RegularInspection.new(regular_inspection_params)
-
-
4
respond_to do |format|
-
4
if @regular_inspection.save
-
2
format.html do
-
2
redirect_to @regular_inspection,
-
notice: I18n.t('controller.common.success_on_create',
-
model_name: RegularInspection.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @regular_inspection }
-
else
-
4
format.html { render :new }
-
2
format.json { render json: @regular_inspection.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /regular_inspections/1
-
# PATCH/PUT /regular_inspections/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @regular_inspection.update(regular_inspection_params)
-
2
format.html do
-
2
redirect_to @regular_inspection,
-
notice: I18n.t('controller.common.success_on_update',
-
model_name: RegularInspection.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @regular_inspection }
-
else
-
2
format.html { render :edit }
-
1
format.json { render json: @regular_inspection.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /regular_inspections/1
-
# DELETE /regular_inspections/1.json
-
1
def destroy
-
2
@regular_inspection.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to regular_inspections_url,
-
notice: I18n.t('controller.common.success_on_destroy',
-
model_name: RegularInspection.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
def download_image_metadata
-
1
@regular_inspection = RegularInspection.includes(:bridge_contents).find(params[:regular_inspection_id])
-
1
send_data(
-
render_to_string(
-
partial: 'regular_inspections/download_image_metadata.csv'
-
),
-
filename: 'image_metadata.csv',
-
type: 'csv'
-
)
-
end
-
-
1
def download_pointcloud_metadata
-
1
@regular_inspection = RegularInspection.includes(:bridge_contents).find(params[:regular_inspection_id])
-
1
send_data(
-
render_to_string(
-
partial: 'regular_inspections/download_pointcloud_metadata.csv'
-
),
-
filename: 'pointcloud_metadata.csv',
-
type: 'csv'
-
)
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_regular_inspection
-
7
@regular_inspection = RegularInspection.includes([:diagnoses, { injuries: [:component] }])
-
.order('diagnoses.component_category')
-
.order('components.component_category').find(params[:id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def regular_inspection_params
-
7
params.fetch(:regular_inspection, {}).permit(:bridge_id, :title, :person_responsible, :periodic_inspection_date,
-
:record_updated_date, :start_date, :end_date)
-
end
-
end
-
# frozen_string_literal: true
-
-
# SoundnessesController
-
1
class SoundnessesController < UserBaseController
-
1
before_action :set_bridge
-
1
before_action :set_soundness, only: %i[show edit update destroy]
-
-
# GET /bridges/1/soundnesses
-
# GET /bridges/1/soundnesses.json
-
1
def index
-
1
@soundnesses = Soundness.where(bridge: @bridge).all
-
end
-
-
# GET /bridges/1/soundnesses/1
-
# GET /bridges/1/soundnesses/1.json
-
1
def show; end
-
-
# GET /bridges/1/soundnesses/new
-
1
def new
-
1
@soundness = Soundness.new(bridge: @bridge)
-
end
-
-
# GET /bridges/1/soundnesses/1/edit
-
1
def edit; end
-
-
# POST /bridges/1/soundnesses
-
# POST /bridges/1/soundnesses.json
-
1
def create
-
4
@soundness = Soundness.new(soundness_params)
-
4
@soundness.bridge = @bridge
-
-
4
respond_to do |format|
-
4
if @soundness.save
-
2
format.html do
-
2
redirect_to [@bridge, @soundness],
-
notice: I18n.t('controller.common.success_on_create', model_name: Soundness.model_name.human)
-
end
-
2
format.json { render :show, status: :created, location: @soundness }
-
else
-
4
format.html { render :new }
-
2
format.json { render json: @soundness.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# PATCH/PUT /soundnesses/1
-
# PATCH/PUT /soundnesses/1.json
-
1
def update
-
3
respond_to do |format|
-
3
if @soundness.update(soundness_params)
-
2
format.html do
-
2
redirect_to [@bridge, @soundness],
-
notice: I18n.t('controller.common.success_on_update', model_name: Soundness.model_name.human)
-
end
-
2
format.json { render :show, status: :ok, location: @soundness }
-
else
-
2
format.html { render :edit }
-
1
format.json { render json: @soundness.errors, status: :unprocessable_entity }
-
end
-
end
-
end
-
-
# DELETE /soundnesses/1
-
# DELETE /soundnesses/1.json
-
1
def destroy
-
2
@soundness.destroy
-
2
respond_to do |format|
-
2
format.html do
-
2
redirect_to bridge_soundnesses_url(@bridge),
-
notice: I18n.t('controller.common.success_on_destroy', model_name: Soundness.model_name.human)
-
end
-
2
format.json { head :no_content }
-
end
-
end
-
-
1
private
-
-
# Use callbacks to share common setup or constraints between actions.
-
1
def set_soundness
-
7
@soundness = Soundness.find(params[:id])
-
end
-
-
1
def set_bridge
-
13
@bridge = Bridge.find(params[:bridge_id])
-
end
-
-
# Only allow a list of trusted parameters through.
-
1
def soundness_params
-
7
params.fetch(:soundness, {}).permit(:evaluation_at, :evaluation, :overall_evaluation)
-
end
-
end
-
# frozen_string_literal: true
-
-
# StatusController
-
1
class StatusController < ActionController::Base
-
1
def index
-
2
payload = {
-
bridge_count: 0,
-
message: nil
-
}
-
begin
-
2
payload[:bridge_count] = Bridge.count
-
1
render json: payload, status: :ok
-
rescue => e # rubocop:disable Style/RescueStandardError
-
1
payload[:message] = e.message
-
1
render json: payload, status: :internal_server_error
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
# TopController path=/
-
1
class TopController < UserBaseController
-
1
def index
-
1
@bridges = Bridge.includes(:soundnesses)
-
1
@matrix = Dashboard.matrix(@bridges)
-
1
@overall_evaluations = Dashboard.sorted_overall_evaluations
-
1
@soundness_chart = Dashboard.soundness_chart(@bridges)
-
1
@priority_chart = Dashboard.priority_chart(@bridges)
-
1
@kind_of_bridge_chart = Dashboard.kind_of_bridge_chart(@bridges)
-
end
-
end
-
# frozen_string_literal: true
-
-
# User Base Controller
-
1
class UserBaseController < ApplicationController
-
1
include UserSessionAction
-
1
layout 'user'
-
1
before_action :let_user_login
-
end
-
# frozen_string_literal: true
-
-
# ApplicationHelper
-
1
module ApplicationHelper
-
end
-
# frozen_string_literal: true
-
-
# ApplicationJob
-
1
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
-
# frozen_string_literal: true
-
-
# GameTileJob
-
1
class GameTileJob < ApplicationJob
-
1
queue_as :default
-
-
1
def perform(bridge_content_id)
-
3
bridge_content = BridgeContent.find_by_id(bridge_content_id)
-
3
return if bridge_content.nil?
-
-
3
return unless bridge_content.data_type.to_i == BridgeContent.data_types[:ortho]
-
-
3
exec_perform(bridge_content)
-
end
-
-
1
private
-
-
1
def exec_perform(bridge_content)
-
3
bridge_content.data.open do |file|
-
3
target_dir = Rails.root.join('public', 'ortho_images', bridge_content.id.to_s)
-
3
target_dir = File.join('/tmp', 'ortho_images', bridge_content.id.to_s) if Rails.env == 'test'
-
3
FileUtils.rm_rf(target_dir)
-
3
game_tile = GameTile.new(file.path, target_dir)
-
3
zoom_range = game_tile.make
-
3
bridge_content.ortho_tile_info = { min_zoom: zoom_range.first, max_zoom: zoom_range.last }
-
3
bridge_content.save
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
# AdminUser model
-
1
class AdminUser < ApplicationRecord
-
1
include UserImplement
-
-
1
has_secure_password
-
1
validates :login_name, presence: true, uniqueness: true
-
1
validates :password_digest, presence: true
-
1
validates :password,
-
length: { minimum: 8, if: :validate_password? },
-
confirmation: { if: :validate_password? }
-
1
validates :password,
-
format: {
-
with: /\A(?=.*?[a-z])(?=.*?\d)[a-z\d]{2,100}\z/i,
-
message: I18n.t('errors.attributes.password.invalid'),
-
if: :validate_password?
-
}, confirmation: { if: :validate_password? }
-
end
-
# frozen_string_literal: true
-
-
# ApplicationRecord
-
1
class ApplicationRecord < ActiveRecord::Base
-
1
self.abstract_class = true
-
end
-
# frozen_string_literal: true
-
-
# Bridge class
-
1
class Bridge < ApplicationRecord
-
1
include AttrJson::Record
-
1
include AttrJson::Record::QueryScopes
-
1
attr_json_config(default_container_attribute: :other_data)
-
-
1
has_many :soundnesses
-
1
has_many :regular_inspections
-
1
has_many :components
-
-
1
validates :title, presence: true
-
1
validates :address, presence: true
-
1
validates :location, presence: true
-
-
1
attr_json :road_name, :string
-
1
attr_json :bridge_length, :integer
-
1
attr_json :width, :float
-
# 適用示方書
-
1
attr_json :applicable_specifications_upper, :string
-
1
attr_json :applicable_specifications_lower, :string
-
# 交通量
-
1
attr_json :traffic_count, :string
-
# 大型車混入率
-
1
attr_json :large_vehicle_mixing_rate, :string
-
# 供用年
-
1
attr_json :year_in_service, :integer
-
# 重要度
-
1
attr_json :priority, :integer, default: 0
-
# 管理者名
-
1
attr_json :administrator_name, :string
-
# 橋梁形式
-
1
attr_json :bridge_type, :string
-
# 路下条件
-
1
attr_json :street_condition, :string
-
# 代替路の有無
-
1
attr_json :availabillity_of_alternative_route, :integer
-
# 自専道or一般道
-
1
attr_json :freeway_or_public_road, :integer
-
# 緊急輸送道路
-
1
attr_json :emergency_transport_road, :boolean
-
# フリガナ
-
1
attr_json :kana_title, :string
-
# 橋梁ID
-
1
attr_json :bridge_identification_number, :string
-
# 橋種
-
1
attr_json :kind_of_bridge, :integer, default: 0
-
-
1
enum priority_type: {
-
priority_unselected: 0,
-
priority_a: 1,
-
priority_b: 2,
-
priority_c: 3
-
}
-
-
1
enum availabillity_of_alternative_route_type: {
-
unknown: 0,
-
available: 1,
-
unavailable: 2
-
}
-
-
1
enum freeway_or_public_road_type: {
-
unselected: 0,
-
freeway: 1,
-
public_road: 2
-
}
-
-
1
enum kind_of_bridge_type: {
-
others: 0,
-
concrete: 1,
-
steel: 2,
-
mixing: 3
-
}
-
-
1
def full_title
-
16
return title if kana_title.blank?
-
-
2
"#{title} (#{kana_title})"
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'exifr/jpeg'
-
-
# rubocop:disable Metrics/ClassLength
-
# BridgeContent Model
-
1
class BridgeContent < ApplicationRecord
-
1
after_commit :pointcloud_update
-
1
before_save :check_pointcloud_is_update
-
1
after_commit :ortho_image_update
-
1
before_save :check_ortho_is_update
-
1
after_commit :check_image_has_exif
-
-
1
belongs_to :regular_inspection
-
1
belongs_to :component, optional: true
-
1
has_one :bridge_main_content
-
1
has_one :bridge_content_injury
-
1
validates :title, presence: true
-
1
has_one_attached :data
-
1
validates :data, presence: true
-
1
store_accessor :metadata, :data_type
-
1
store_accessor :metadata, :ortho_tile_info
-
1
store_accessor :metadata, :ortho_metadata
-
1
store_accessor :metadata, :pointcloud_info
-
1
store_accessor :metadata, :pointcloud_metadata
-
# image metadata
-
1
store_accessor :metadata, :position_entry_type
-
1
store_accessor :metadata, :center_x
-
1
store_accessor :metadata, :center_y
-
1
store_accessor :metadata, :center_z
-
1
store_accessor :metadata, :euler_angle_alpha
-
1
store_accessor :metadata, :euler_angle_beta
-
1
store_accessor :metadata, :euler_angle_gamma
-
1
store_accessor :metadata, :quaternion_one
-
1
store_accessor :metadata, :quaternion_two
-
1
store_accessor :metadata, :quaternion_three
-
1
store_accessor :metadata, :quaternion_four
-
1
store_accessor :metadata, :bbox_u_r_x
-
1
store_accessor :metadata, :bbox_u_r_y
-
1
store_accessor :metadata, :bbox_u_r_z
-
1
store_accessor :metadata, :bbox_u_l_x
-
1
store_accessor :metadata, :bbox_u_l_y
-
1
store_accessor :metadata, :bbox_u_l_z
-
1
store_accessor :metadata, :bbox_d_r_x
-
1
store_accessor :metadata, :bbox_d_r_y
-
1
store_accessor :metadata, :bbox_d_r_z
-
1
store_accessor :metadata, :bbox_d_l_x
-
1
store_accessor :metadata, :bbox_d_l_y
-
1
store_accessor :metadata, :bbox_d_l_z
-
1
store_accessor :metadata, :photo_dimentions
-
1
store_accessor :metadata, :date_of_shooting
-
1
store_accessor :metadata, :projection_method
-
1
store_accessor :metadata, :target_material
-
1
store_accessor :metadata, :damage_or_not
-
1
store_accessor :metadata, :representative_photo
-
# point cloud metadata
-
1
store_accessor :metadata, :pointcloud_data_id
-
1
store_accessor :metadata, :pointcloud_creation_name
-
1
store_accessor :metadata, :pointcloud_created_at
-
1
store_accessor :metadata, :pointcloud_measurement_method
-
1
store_accessor :metadata, :pointcloud_measurement_environment
-
1
store_accessor :metadata, :pointcloud_measuring_equipment
-
1
store_accessor :metadata, :pointcloud_analysis_method
-
1
store_accessor :metadata, :pointcloud_software
-
1
store_accessor :metadata, :pointcloud_crs
-
1
store_accessor :metadata, :pointcloud_reference_point_x
-
1
store_accessor :metadata, :pointcloud_reference_point_y
-
1
store_accessor :metadata, :pointcloud_reference_point_z
-
-
1
enum data_type: {
-
unselected: 0,
-
image: 1,
-
movie: 2,
-
damage_diagram: 3,
-
ortho: 4,
-
pointcloud: 5
-
}
-
-
1
enum position_entry_type: {
-
center_photo: 0,
-
center_camera: 1,
-
photo_bbox: 2
-
}
-
-
1
enum projection_method: {
-
center_projection: 0,
-
orthographic_projection: 1
-
}
-
-
1
enum target_material: {
-
main_girder: 'Mg',
-
cross_member: 'Cr',
-
slab: 'Ds',
-
substructure: 'SB',
-
bearing_h: 'Bh',
-
bearing_m: 'Bm',
-
bearing_c: 'Bh',
-
top_plate: 'Ct',
-
side_wall: 'Sw',
-
bottom_plate: 'Cb'
-
}
-
-
1
enum damage_or_not: {
-
damage: 1,
-
not_damage: 0
-
}
-
-
1
enum representative_photo: {
-
representative: 1,
-
others: 0
-
}
-
-
1
def main_content?
-
2
return true unless bridge_main_content.nil?
-
-
1
false
-
end
-
-
1
private
-
-
1
def check_ortho_is_update
-
55
return unless data_type.to_i == BridgeContent.data_types[:ortho]
-
-
6
self.ortho_tile_info = nil if data.changed?
-
end
-
-
1
def ortho_image_update
-
57
return unless data_type.to_i == BridgeContent.data_types[:ortho]
-
-
6
GameTileJob.perform_later(id) if ortho_tile_info.nil?
-
end
-
-
1
def check_pointcloud_is_update
-
55
return unless data_type.to_i == BridgeContent.data_types[:pointcloud]
-
-
self.pointcloud_info = nil if data.changed?
-
end
-
-
1
def pointcloud_update
-
57
return unless data_type.to_i == BridgeContent.data_types[:pointcloud]
-
-
PointcloudJob.perform_later(id) if pointcloud_info.nil?
-
end
-
-
# rubocop:disable Metrics/AbcSize
-
1
def check_image_has_exif
-
57
return unless data_type.to_i == BridgeContent.data_types[:image]
-
-
2
return unless date_of_shooting.blank?
-
-
1
return unless data.content_type == 'image/jpeg'
-
-
# read exif
-
1
data.open do |file|
-
1
exif = EXIFR::JPEG.new(file.path)
-
1
break unless exif.exif?
-
-
1
break if exif.date_time.nil?
-
-
1
self.date_of_shooting = exif.date_time.strftime('%Y/%m/%d %H:%M:%S')
-
1
save
-
end
-
end
-
# rubocop:enable Metrics/AbcSize
-
end
-
# rubocop:enable Metrics/ClassLength
-
# frozen_string_literal: true
-
-
# BridgeContentInjury
-
1
class BridgeContentInjury < ApplicationRecord
-
1
include AttrJson::Record
-
1
attr_json_config(default_container_attribute: :other_data)
-
-
1
belongs_to :bridge_content
-
1
belongs_to :injury
-
-
1
validates_with BridgeContentInjurySameOriginValidator
-
-
# 動画 seek
-
1
attr_json :seek, :integer
-
# オルソ geojson
-
1
attr_json :ortho_geojson, :string
-
1
attr_json :pointposition, :string
-
end
-
# frozen_string_literal: true
-
-
# BridgeMainContent
-
1
class BridgeMainContent < ApplicationRecord
-
1
belongs_to :bridge_content
-
end
-
# frozen_string_literal: true
-
-
# Component model
-
1
class Component < ApplicationRecord
-
1
belongs_to :bridge
-
1
validates :bridge, presence: true
-
1
validates :span_number, presence: true
-
1
validates :component_category, presence: true
-
-
1
def show_name
-
10
I18n.t('activerecord.attributes.component.span_number') +
-
" #{span_number} " +
-
I18n.t("enums.component.category.#{Component.categories.invert[component_category]}") +
-
title
-
end
-
-
1
enum category: {
-
superstructure_main_girder: 1,
-
superstructure_horizontal_grider: 2,
-
superstructure_slab: 3,
-
substructure: 4,
-
support_structure: 5,
-
other: 6
-
}
-
end
-
# frozen_string_literal: true
-
-
# location implement
-
1
module LocationImplement
-
# 35°37′37″ -> 35.62694444444445
-
1
def self.sexagesimal_to_float(value)
-
17
coordinate, others = value.split('°')
-
17
minutes, others = others.split('′')
-
17
seconds = others.split('″')[0]
-
17
coordinate.to_i + minutes.to_f / 60 + seconds.to_f / 3600
-
end
-
-
# 35.35.62694444 -> 35°37′37″
-
1
def self.float_to_sexagesimal(value)
-
1
coordinate_whole = value.to_i
-
1
coordinate_decimal = value - coordinate_whole
-
1
minutes = coordinate_decimal * 60
-
1
minutes_whole = minutes.to_i
-
1
minutes_decimal = minutes - minutes_whole
-
1
seconds = (minutes_decimal * 60).round.to_i
-
1
"#{coordinate_whole}°#{minutes_whole}′#{seconds}″"
-
end
-
end
-
# frozen_string_literal: true
-
-
# user implement
-
1
module UserImplement
-
1
extend ActiveSupport::Concern
-
-
1
private
-
-
1
def validate_password?
-
764
password.present? || password_confirmation.present?
-
end
-
end
-
# frozen_string_literal: true
-
-
# Dashboard class
-
1
class Dashboard
-
1
class << self
-
1
def matrix(bridges)
-
3
bridges = bridges.order('soundnesses.evaluation_at')
-
3
make_matrix(bridges)
-
end
-
-
1
def sorted_overall_evaluations
-
24
overall_evaluations = Soundness.overall_evaluations.map { |k, _| k }
-
4
unselected = overall_evaluations.shift
-
4
overall_evaluations << unselected
-
4
overall_evaluations.reverse
-
end
-
-
1
def soundness_chart(bridges)
-
2
bridges = bridges.order('soundnesses.evaluation_at')
-
2
values = {}
-
12
sorted_overall_evaluations.each { |k| values[k.to_s] = 0 }
-
2
bridges.each do |bridge|
-
4
soundness = bridge.soundnesses.last
-
4
if soundness.nil?
-
1
values['unselected'] += 1
-
else
-
3
values[soundness.overall_evaluation] += 1
-
end
-
end
-
2
values
-
end
-
-
1
def priority_chart(bridges)
-
10
priority_types = Bridge.priority_types.map { |k, _| k }
-
2
values = {}
-
10
priority_types.each { |k| values[k.to_s] = 0 }
-
2
bridges.each do |bridge|
-
4
key = Bridge.priority_types.invert[bridge.priority]
-
4
if !key.nil?
-
4
values[key] += 1
-
else
-
values['priority_unselected'] += 1
-
end
-
end
-
2
values
-
end
-
-
1
def kind_of_bridge_chart(bridges)
-
6
year_in_services = bridges.map(&:year_in_service).filter { |k| !k.nil? }.sort.uniq
-
2
return {} if year_in_services.empty?
-
-
1
make_kind_of_bridge_chart(year_in_services)
-
end
-
-
1
private
-
-
1
def matrix_item(bridge)
-
8
soundness = bridge.soundnesses.last
-
8
return nil, nil, bridge if soundness.nil?
-
-
6
year = soundness.evaluation_at.strftime('%Y')
-
6
overall_evaluation = soundness.overall_evaluation
-
6
[year, overall_evaluation, bridge]
-
end
-
-
1
def make_matrix(bridges)
-
3
matrix = {}
-
3
bridges.each do |bridge|
-
8
year, overall_evaluation, bridge = matrix_item(bridge)
-
8
next if year.nil?
-
-
6
matrix[year] = {} if matrix[year].nil?
-
6
matrix[year][overall_evaluation] = [] if matrix[year][overall_evaluation].nil?
-
6
matrix[year][overall_evaluation] << bridge
-
end
-
3
matrix
-
end
-
-
1
def make_kind_of_bridge_chart(year_in_services)
-
1
start_year = year_in_services[0]
-
1
end_year = year_in_services[-1]
-
1
values = init_kind_of_bridge_chart(start_year, end_year)
-
1
year_in_services.each do |year_in_service|
-
2
targets = Bridge.jsonb_contains(year_in_service: year_in_service)
-
2
targets.each do |bridge|
-
2
values[year_in_service][Bridge.kind_of_bridge_types.invert[bridge.kind_of_bridge].to_s] += 1
-
end
-
end
-
1
values
-
end
-
-
1
def init_kind_of_bridge_chart(start_year, end_year)
-
1
values = {}
-
1
Range.new(start_year, end_year).each do |year|
-
32
sub_values = {}
-
32
Bridge.kind_of_bridge_types.each do |k, _|
-
128
sub_values[k.to_s] = 0
-
end
-
32
values[year] = sub_values
-
end
-
1
values
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
# Injury model
-
1
class Diagnosis < ApplicationRecord
-
1
include AttrJson::Record
-
1
attr_json_config(default_container_attribute: :other_data)
-
-
1
belongs_to :regular_inspection
-
1
belongs_to :injury, optional: true
-
-
1
validates :component_category, presence: true, uniqueness: { scope: [:regular_inspection] }
-
1
validates :result, presence: true
-
1
validates :injury, presence: true, if: :need_injury?
-
1
validates_with SameComponentCategoryValidator
-
-
1
enum diagnosis_result: {
-
unselected: 0,
-
one: 1,
-
two: 2,
-
three: 3,
-
four: 4
-
}
-
-
1
private
-
-
1
def need_injury?
-
36
if result == 2 || result == 3
-
8
true
-
else
-
28
false
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'fileutils'
-
1
require 'tmpdir'
-
1
require 'tempfile'
-
-
# GameTile class
-
1
class GameTile
-
1
attr_accessor :file, :tile_dir, :base_zoom, :width, :height
-
-
1
TILE_SIZE = 256
-
-
1
def initialize(file, tile_dir)
-
4
self.file = file
-
4
self.tile_dir = tile_dir
-
end
-
-
1
def make
-
4
zoom_range, base_zoom = zooms
-
4
self.base_zoom = base_zoom
-
4
zoom_range.each do |zoom|
-
12
make_tile(zoom)
-
end
-
4
zoom_range
-
end
-
-
1
private
-
-
1
def zooms
-
4
self.width = `identify -ping -format "%w" #{file}`.to_i
-
4
self.height = `identify -ping -format "%h" #{file}`.to_i
-
4
base = width > height ? width : height
-
4
max_zoom = (Math.log(base) / Math.log(2)).ceil
-
4
min_zoom = 8
-
4
[min_zoom..(max_zoom + 1), max_zoom]
-
end
-
-
1
def calculate_params(zoom)
-
12
scale = (2**(zoom - base_zoom)).to_f
-
12
width = (self.width * scale).to_i
-
12
height = (self.height * scale).to_i
-
12
tiles_per_column = (width.to_f / TILE_SIZE).ceil
-
12
tiles_per_row = (height.to_f / TILE_SIZE).ceil
-
12
[scale, tiles_per_column, tiles_per_row]
-
end
-
-
1
def make_marge_file(scale, tiles_per_column, tiles_per_row)
-
# make resize image
-
12
tmp = Tempfile.new(['tmp', '.png'])
-
12
tmp.close
-
12
`vips resize #{file} #{tmp.path} #{scale}`
-
# make background image
-
12
bg_width = tiles_per_column * TILE_SIZE
-
12
bg_height = tiles_per_row * TILE_SIZE
-
12
bg_file = Tempfile.new(['bg', '.png'])
-
12
bg_file.close
-
12
`vips black #{bg_file.path} #{bg_width} #{bg_height}`
-
# make marge image
-
12
merge_file = Tempfile.new(['merge', '.png'])
-
12
merge_file.close
-
12
`vips insert #{bg_file.path} #{tmp.path} #{merge_file.path} 0 0`
-
12
tmp.delete
-
12
bg_file.delete
-
12
merge_file
-
end
-
-
1
def crap_images(working_dir, zoom, merge_file)
-
12
vips_opts = "--suffix .png --tile-size 256 --basename image_#{zoom} --depth one --overlap 0 --background 0"
-
12
`vips dzsave #{merge_file.path} #{working_dir}/image #{vips_opts}`
-
12
merge_file.delete
-
end
-
-
1
def generate_tiles(working_dir, zoom)
-
12
search_file = File.join(working_dir, "image_#{zoom}_files", '0', '*.png')
-
12
total_tiles = Dir[search_file]
-
12
total_tiles.each do |file_path|
-
40
base_name = File.basename(file_path, '.png')
-
40
target = File.join(tile_dir, zoom.to_s, "#{base_name}.png")
-
40
`cp -f #{file_path} #{target}`
-
end
-
end
-
-
1
def make_tile(zoom)
-
12
scale, tiles_per_column, tiles_per_row = calculate_params(zoom)
-
-
12
output_dir = File.join(tile_dir, zoom.to_s)
-
12
FileUtils.mkdir_p(output_dir) unless File.exist?(output_dir)
-
-
12
Dir.mktmpdir do |working_dir|
-
12
merge_file = make_marge_file(scale, tiles_per_column, tiles_per_row)
-
12
crap_images(working_dir, zoom, merge_file)
-
12
generate_tiles(working_dir, zoom)
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
# Injury model
-
1
class Injury < ApplicationRecord
-
1
include AttrJson::Record
-
1
attr_json_config(default_container_attribute: :other_data)
-
-
1
belongs_to :regular_inspection
-
1
belongs_to :component
-
1
has_many :bridge_content_injuries
-
-
1
enum grade: {
-
unselected: 0,
-
a: 1,
-
b: 2,
-
c: 3,
-
d: 4,
-
e: 5
-
}
-
-
1
def show_name
-
4
I18n.t("enums.component.category.#{Component.categories.invert[component.component_category]}") +
-
" #{injury_type} #{injury_grade}"
-
end
-
-
# 定量的に取得した値
-
1
attr_json :quantitatively_obtained_value, :string
-
# 単位
-
1
attr_json :unit, :string
-
# 損傷パターン
-
1
attr_json :injury_pattern, :string
-
# 分類
-
1
attr_json :classification, :string
-
# 所見
-
1
attr_json :impression, :string
-
end
-
# frozen_string_literal: true
-
-
# Mlit Importer class
-
1
class MlitImporter
-
# for human_attribute_name
-
1
include ActiveModel::Model
-
1
attr_accessor :upload_file
-
-
1
class << self
-
1
def import(file)
-
8
import_from_excel_file(file)
-
end
-
-
1
private
-
-
1
def import_from_excel_file(file)
-
8
xlsx = Roo::Spreadsheet.open(file)
-
8
bridge = Bridge.new
-
# read first sheet
-
8
sheet = xlsx.sheet(0)
-
8
title = sheet.cell(6, 1)
-
8
bridge.title = title
-
8
address = sheet.cell(6, 6)
-
8
bridge.address = address
-
8
latitude_string = sheet.cell(4, 11)
-
8
longitude_string = sheet.cell(5, 11)
-
8
latitude = LocationImplement.sexagesimal_to_float(latitude_string)
-
8
longitude = LocationImplement.sexagesimal_to_float(longitude_string)
-
8
bridge.location = "POINT(#{longitude} #{latitude})"
-
8
road_name = sheet.cell(6, 4)
-
8
bridge.road_name = road_name
-
8
bridge
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
# RegularInspection class
-
1
class RegularInspection < ApplicationRecord
-
1
include AttrJson::Record
-
1
attr_json_config(default_container_attribute: :other_data)
-
-
1
belongs_to :bridge
-
1
has_many :bridge_contents
-
1
has_many :injuries
-
1
has_many :diagnoses
-
1
validates :bridge, presence: true
-
1
validates :title, presence: true
-
-
# 点検担当者
-
1
attr_json :person_responsible, :string
-
# 定期点検実施年月日
-
1
attr_json :periodic_inspection_date, :date
-
# 調書更新年月日
-
1
attr_json :record_updated_date, :date
-
# 開始日
-
1
attr_json :start_date, :date
-
# 終了日
-
1
attr_json :end_date, :date
-
end
-
# frozen_string_literal: true
-
-
# Soundness Model
-
1
class Soundness < ApplicationRecord
-
1
belongs_to :bridge
-
-
1
validates :evaluation, presence: true
-
1
validates :evaluation_at, presence: true
-
-
1
enum overall_evaluation: {
-
unselected: 0,
-
one: 1,
-
two: 2,
-
three: 3,
-
four: 4
-
}
-
end
-
# frozen_string_literal: true
-
-
# User model
-
1
class User < ApplicationRecord
-
1
include UserImplement
-
-
1
has_secure_password
-
-
1
validates :login_name, presence: true, uniqueness: true
-
1
validates :password_digest, presence: true
-
1
validates :password,
-
length: { minimum: 8, if: :validate_password? },
-
confirmation: { if: :validate_password? }
-
1
validates :password,
-
format: {
-
with: /\A(?=.*?[a-z])(?=.*?\d)[a-z\d]{2,100}\z/i,
-
message: I18n.t('errors.attributes.password.invalid'),
-
if: :validate_password?
-
}, confirmation: { if: :validate_password? }
-
end
-
# frozen_string_literal: true
-
-
# BridgeContentInjurySameOriginValidator
-
1
class BridgeContentInjurySameOriginValidator < ActiveModel::Validator
-
1
def validate(record)
-
26
return unless record.injury && record.bridge_content
-
-
23
return if record.injury.regular_inspection == record.bridge_content.regular_inspection
-
-
1
record.errors.add :injury_id, :is_not_same_origin
-
end
-
end
-
# frozen_string_literal: true
-
-
# SameComponentCategoryValidator
-
1
class SameComponentCategoryValidator < ActiveModel::Validator
-
1
def validate(record)
-
36
return if record.injury.nil?
-
-
15
return if record.injury.component.component_category == record.component_category
-
-
1
record.errors.add :injury_id, :injury_component_category_is_not_same
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require_relative 'boot'
-
-
1
require 'rails'
-
# Pick the frameworks you want:
-
1
require 'active_model/railtie'
-
1
require 'active_job/railtie'
-
1
require 'active_record/railtie'
-
1
require 'active_storage/engine'
-
1
require 'action_controller/railtie'
-
1
require 'action_mailer/railtie'
-
1
require 'action_mailbox/engine'
-
1
require 'action_text/engine'
-
1
require 'action_view/railtie'
-
1
require 'action_cable/engine'
-
1
require 'sprockets/railtie'
-
# require "rails/test_unit/railtie"
-
-
# Require the gems listed in Gemfile, including any gems
-
# you've limited to :test, :development, or :production.
-
1
Bundler.require(*Rails.groups)
-
-
1
module Ha4db
-
# Our Application
-
1
class Application < Rails::Application
-
1
config.i18n.default_locale = :ja
-
# Initialize configuration defaults for originally generated Rails version.
-
1
config.load_defaults 6.0
-
-
# Settings in config/environments/* take precedence over those specified here.
-
# Application configuration can go into files in config/initializers
-
# -- all .rb files in that directory are automatically loaded after loading
-
# the framework and any gems in your application.
-
-
# Don't generate system test files.
-
1
config.generators.system_tests = nil
-
-
# For material components for web
-
1
config.action_view.field_error_proc = proc do |html_tag, _|
-
17
html_tag.html_safe
-
end
-
-
# active job
-
1
config.active_job.queue_adapter = :sidekiq
-
-
# use vips
-
1
config.active_storage.variant_processor = :vips
-
end
-
end
-
# frozen_string_literal: true
-
-
1
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
-
-
1
require 'bundler/setup' # Set up gems listed in the Gemfile.
-
1
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
-
# frozen_string_literal: true
-
-
# Load the Rails application.
-
1
require_relative 'application'
-
-
# Initialize the Rails application.
-
1
Rails.application.initialize!
-
# frozen_string_literal: true
-
-
# The test environment is used exclusively to run your application's
-
# test suite. You never need to work with it otherwise. Remember that
-
# your test database is "scratch space" for the test suite and is wiped
-
# and recreated between test runs. Don't rely on the data there!
-
-
1
Rails.application.configure do
-
# Settings specified here will take precedence over those in config/application.rb.
-
-
1
config.cache_classes = false
-
1
config.action_view.cache_template_loading = true
-
-
# Do not eager load code on boot. This avoids loading your whole application
-
# just for the purpose of running a single test. If you are using a tool that
-
# preloads Rails for running tests, you may have to set it to true.
-
1
config.eager_load = false
-
-
# Configure public file server for tests with Cache-Control for performance.
-
1
config.public_file_server.enabled = true
-
1
config.public_file_server.headers = {
-
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
-
}
-
-
# Show full error reports and disable caching.
-
1
config.consider_all_requests_local = true
-
1
config.action_controller.perform_caching = false
-
1
config.cache_store = :null_store
-
-
# Raise exceptions instead of rendering exception templates.
-
1
config.action_dispatch.show_exceptions = false
-
-
# Disable request forgery protection in test environment.
-
1
config.action_controller.allow_forgery_protection = false
-
-
# Store uploaded files on the local file system in a temporary directory.
-
1
config.active_storage.service = :test
-
-
1
config.action_mailer.perform_caching = false
-
-
# Tell Action Mailer not to deliver emails to the real world.
-
# The :test delivery method accumulates sent emails in the
-
# ActionMailer::Base.deliveries array.
-
1
config.action_mailer.delivery_method = :test
-
-
# Print deprecation notices to the stderr.
-
1
config.active_support.deprecation = :stderr
-
-
# Raises error for missing translations.
-
# config.action_view.raise_on_missing_translations = true
-
end
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# ActiveSupport::Reloader.to_prepare do
-
# ApplicationController.renderer.defaults.merge!(
-
# http_host: 'example.org',
-
# https: false
-
# )
-
# end
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# Version of your assets, change this if you want to expire all your assets.
-
1
Rails.application.config.assets.version = '1.0'
-
-
# Add additional assets to the asset load path.
-
# Rails.application.config.assets.paths << Emoji.images_path
-
# Add Yarn node_modules folder to the asset load path.
-
1
Rails.application.config.assets.paths << Rails.root.join('node_modules')
-
-
# Precompile additional assets.
-
# application.js, application.css, and all non-JS/CSS in the app/assets
-
# folder are already added.
-
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
-
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
-
-
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
-
# Rails.backtrace_cleaner.remove_silencers!
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# Define an application-wide content security policy
-
# For further information see the following documentation
-
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
-
-
# Rails.application.config.content_security_policy do |policy|
-
# policy.default_src :self, :https
-
# policy.font_src :self, :https, :data
-
# policy.img_src :self, :https, :data
-
# policy.object_src :none
-
# policy.script_src :self, :https
-
# policy.style_src :self, :https
-
# # If you are using webpack-dev-server then specify webpack-dev-server host
-
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
-
-
# # Specify URI for violation reports
-
# # policy.report_uri "/csp-violation-report-endpoint"
-
# end
-
-
# If you are using UJS then enable automatic nonce generation
-
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
-
-
# Set the nonce only to specific directives
-
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
-
-
# Report CSP violations to a specified URI
-
# For further information see the following documentation:
-
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
-
# Rails.application.config.content_security_policy_report_only = true
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# Specify a serializer for the signed and encrypted cookie jars.
-
# Valid options are :json, :marshal, and :hybrid.
-
1
Rails.application.config.action_dispatch.cookies_serializer = :json
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# Configure sensitive parameters which will be filtered from the log file.
-
1
Rails.application.config.filter_parameters += [:password]
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# Add new inflection rules using the following format. Inflections
-
# are locale specific, and you may define rules for as many different
-
# locales as you wish. All of these examples are active by default:
-
# ActiveSupport::Inflector.inflections(:en) do |inflect|
-
# inflect.plural /^(ox)$/i, '\1en'
-
# inflect.singular /^(ox)en/i, '\1'
-
# inflect.irregular 'person', 'people'
-
# inflect.uncountable %w( fish sheep )
-
# end
-
-
# These inflection rules are supported but not enabled by default:
-
# ActiveSupport::Inflector.inflections(:en) do |inflect|
-
# inflect.acronym 'RESTful'
-
# end
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# Add new mime types for use in respond_to blocks:
-
# Mime::Type.register "text/richtext", :rtf
-
# frozen_string_literal: true
-
-
# Be sure to restart your server when you modify this file.
-
-
# This file contains settings for ActionController::ParamsWrapper which
-
# is enabled by default.
-
-
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
-
1
ActiveSupport.on_load(:action_controller) do
-
2
wrap_parameters format: [:json]
-
end
-
-
# To enable root element in JSON for ActiveRecord objects.
-
# ActiveSupport.on_load(:active_record) do
-
# self.include_root_in_json = true
-
# end
-
# frozen_string_literal: true
-
-
# rubocop:disable Metrics/BlockLength
-
1
Rails.application.routes.draw do
-
1
resources :regular_inspections do
-
1
resources :bridge_contents
-
1
resources :injuries do
-
1
resources :bridge_content_injuries
-
end
-
1
resources :diagnoses
-
1
resources :bridge_main_contents, only: %i[create destroy]
-
1
get 'download_image_metadata'
-
1
get 'download_pointcloud_metadata'
-
end
-
1
resource :mlit_importer, only: %i[new create] do
-
1
post 'preview'
-
end
-
1
resources :bridges do
-
1
resources :components
-
1
resources :soundnesses
-
end
-
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
-
1
root to: 'top#index'
-
1
get 'top/index'
-
-
1
get 'sessions/index'
-
1
post 'sessions/login'
-
1
get 'sessions/logout'
-
-
# admin
-
1
namespace :admin do
-
1
get 'sessions/index'
-
1
post 'sessions/login'
-
1
get 'sessions/logout'
-
1
get 'top/index'
-
1
resources :users
-
end
-
-
1
get 'status', to: 'status#index', format: :json
-
-
# sidekiq
-
1
require 'sidekiq/web'
-
1
mount Sidekiq::Web => '/sidekiq'
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
FactoryBot.define do
-
1
factory :admin_user do
-
35
login_name { Faker::Internet.user_name }
-
34
password { 'passw0rd' }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
FactoryBot.define do
-
1
factory :bridge_content_injury do
-
1
bridge_content
-
1
injury
-
25
seek { 0 }
-
end
-
end
-
# frozen_string_literal: true
-
-
# BridgeContent Factorybot
-
1
FactoryBot.define do
-
1
factory :bridge_content do
-
1
regular_inspection
-
67
component { nil }
-
67
sequence(:title) { |i| "Bridge Contents #{i}" }
-
1
after(:build) do |bridge_content|
-
66
bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testimage.jpg'))
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
FactoryBot.define do
-
1
factory :bridge_main_content do
-
1
bridge_content
-
end
-
end
-
# frozen_string_literal: true
-
-
1
FactoryBot.define do
-
1
factory :bridge do
-
269
sequence(:title) { |i| "Bridge #{i}" }
-
269
location { 'POINT(139.895697 35.325315)' }
-
269
sequence(:address) { |i| "Address #{i}" }
-
269
bridge_length { 10 }
-
269
width { 4.4 }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
FactoryBot.define do
-
1
factory :component do
-
1
bridge
-
90
sequence(:title) { |i| "title #{i}" }
-
90
span_number { 1 }
-
89
component_category { Component.categories[:superstructure_main_girder] }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
FactoryBot.define do
-
1
factory :diagnosis do
-
1
regular_inspection
-
31
component_category { Component.categories[:superstructure_main_girder] }
-
32
result { Diagnosis.diagnosis_results[:one] }
-
16
injury { nil }
-
32
sequence(:remark) { |i| "remark #{i}" }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
FactoryBot.define do
-
1
factory :injury do
-
1
regular_inspection
-
1
component
-
67
sequence(:injury_type) { |i| "Injury type #{i}" }
-
67
injury_grade { Injury.grades[:a] }
-
end
-
end
-
# frozen_string_literal: true
-
-
# RegularInspection Factorybot
-
1
FactoryBot.define do
-
1
factory :regular_inspection do
-
1
bridge
-
148
sequence(:title) { |i| "Inspection #{i}" }
-
150
sequence(:person_responsible) { |i| "Person responsible #{i}" }
-
150
periodic_inspection_date { Faker::Date.backward(days: 14) }
-
150
record_updated_date { Faker::Date.backward(days: 14) }
-
150
start_date { Faker::Date.backward(days: 20) }
-
150
end_date { Faker::Date.backward(days: 10) }
-
end
-
end
-
# frozen_string_literal: true
-
-
# Soundness Factorybot
-
1
FactoryBot.define do
-
1
factory :soundness do
-
1
bridge
-
46
sequence(:evaluation) { |i| "Soundness evaluation #{i}" }
-
27
evaluation_at { Faker::Date.backward(days: 14) }
-
27
overall_evaluation { Soundness.overall_evaluations[:one] }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
FactoryBot.define do
-
1
factory :user do
-
143
login_name { Faker::Internet.user_name }
-
142
password { 'passw0rd' }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# Specs in this file have access to a helper object that includes
-
# the ApplicationHelper. For example:
-
#
-
# describe ApplicationHelper do
-
# describe "string concat" do
-
# it "concats two strings with spaces" do
-
# expect(helper.concat_strings("this","that")).to eq("this that")
-
# end
-
# end
-
# end
-
1
RSpec.describe ApplicationHelper, type: :helper do
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe GameTileJob, type: :job do
-
1
describe 'create' do
-
1
before do
-
2
@bridge_content = FactoryBot.create(:bridge_content,
-
data: Rails.root.join('spec', 'testdata', 'ortho_image.png'),
-
data_type: BridgeContent.data_types[:ortho])
-
2
GameTileJob.perform_now(@bridge_content.id)
-
end
-
1
it '8/0_0.png' do
-
1
expect(Dir).to exist(File.join('/tmp', 'ortho_images', @bridge_content.id.to_s, '8'))
-
1
check_file = File.join('/tmp', 'ortho_images', @bridge_content.id.to_s, '8/0_0.png')
-
1
expect(File).to exist(check_file)
-
end
-
-
1
it 'metadata' do
-
1
@bridge_content.reload
-
1
expect(@bridge_content.ortho_tile_info['min_zoom']).to eq(8)
-
1
expect(@bridge_content.ortho_tile_info['max_zoom']).to eq(10)
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe AdminUser, type: :model do
-
1
before do
-
16
@admin_user = FactoryBot.build(:admin_user)
-
end
-
-
14
subject { @admin_user }
-
-
2
it { should respond_to(:login_name) }
-
2
it { should respond_to(:password_digest) }
-
2
it { should respond_to(:password) }
-
2
it { should respond_to(:password_confirmation) }
-
2
it { should respond_to(:authenticate) }
-
-
2
it { should be_valid }
-
-
1
describe 'when login_name is not present' do
-
2
before { @admin_user.login_name = ' ' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when login_name is already taken' do
-
1
before do
-
1
with_same_login_name = @admin_user.dup
-
1
with_same_login_name.save
-
end
-
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when password is not present' do
-
1
before do
-
1
@admin_user = FactoryBot.build(:admin_user, password: '', password_confirmation: '')
-
end
-
2
it { should_not be_valid }
-
end
-
-
1
describe "when password doesn't match confirmation" do
-
2
before { @admin_user.password_confirmation = 'mismatch' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe "with a password that's too short" do
-
2
before { @admin_user.password = @admin_user.password_confirmation = 'aaaaaa1' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'return value of authenticate method' do
-
4
before { @admin_user.save }
-
4
let(:found_admin) { AdminUser.find_by(login_name: @admin_user.login_name) }
-
-
1
describe 'with valid password' do
-
2
it { should eq found_admin.authenticate(@admin_user.password) }
-
end
-
-
1
describe 'with invalid password' do
-
3
let(:admin_for_invalid_password) { found_admin.authenticate('invalid') }
-
-
2
it { should_not eq admin_for_invalid_password }
-
2
specify { expect(admin_for_invalid_password).to be_falsey }
-
end
-
end
-
-
1
describe 'when password format is invalid' do
-
1
it 'should be invalid' do
-
1
passwords = %w[a*8 11111111 abcd_1234]
-
1
passwords.each do |invalid_password|
-
3
@admin_user.password = @admin_user.password_confirmation = invalid_password
-
3
expect(@admin_user).not_to be_valid
-
end
-
1
@admin_user.password = @admin_user.password_confirmation = 'abcd 1234'
-
1
expect(@admin_user).not_to be_valid
-
end
-
end
-
-
1
describe 'when password format is valid' do
-
1
it 'should be valid' do
-
1
passwords = %w[abcd1234 AbcdEFG1 1234567A]
-
1
passwords.each do |valid_password|
-
3
@admin_user.password = @admin_user.password_confirmation = valid_password
-
3
expect(@admin_user).to be_valid
-
end
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe BridgeContentInjury, type: :model do
-
1
before do
-
5
regular_inspection = FactoryBot.create(:regular_inspection)
-
5
injury = FactoryBot.create(:injury, regular_inspection: regular_inspection)
-
5
bridge_content = FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
-
5
@bridge_content_injury = FactoryBot.create(:bridge_content_injury, bridge_content: bridge_content, injury: injury)
-
end
-
-
6
subject { @bridge_content_injury }
-
-
2
it { should respond_to(:injury) }
-
2
it { should respond_to(:bridge_content) }
-
2
it { should respond_to(:seek) }
-
-
2
it { should be_valid }
-
-
1
describe 'when result to two, it to be invalid' do
-
1
before do
-
1
@bridge_content_injury.injury = FactoryBot.create(:injury)
-
end
-
2
it { should_not be_valid }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe BridgeContent, type: :model do
-
1
before do
-
13
@bridge_content = FactoryBot.build(:bridge_content)
-
end
-
-
7
subject { @bridge_content }
-
-
2
it { should respond_to(:title) }
-
2
it { should respond_to(:data) }
-
2
it { should respond_to(:regular_inspection) }
-
2
it { should respond_to(:component) }
-
2
it { should be_valid }
-
-
1
describe 'when title is not present' do
-
2
before { @bridge_content.title = ' ' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'bridge_content.data.content_type is image/jpeg' do
-
2
subject { @bridge_content.data.content_type }
-
2
it { should eq('image/jpeg') }
-
end
-
-
1
describe 'bridge_content.data.content_type is image/png' do
-
1
before do
-
1
@bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testimage.png'))
-
end
-
2
subject { @bridge_content.data.content_type }
-
2
it { should eq('image/png') }
-
end
-
-
1
describe 'bridge_content.data.content_type is image/png' do
-
1
before do
-
1
@bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testmovie.mp4'))
-
end
-
2
subject { @bridge_content.data.content_type }
-
2
it { should eq('video/mp4') }
-
end
-
-
1
describe 'bridge_content.data_type to ortho' do
-
1
before do
-
1
@bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'ortho_image.png'))
-
1
@bridge_content.data_type = BridgeContent.data_types[:ortho]
-
1
perform_enqueued_jobs do
-
1
@bridge_content.save
-
end
-
end
-
1
it 'create new tiles' do
-
1
check_file = File.join('/tmp', 'ortho_images', @bridge_content.id.to_s, '8/0_0.png')
-
1
expect(File).to exist(check_file)
-
end
-
end
-
-
1
describe 'image/jpeg with exif' do
-
1
before do
-
1
@bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testexif.jpg'))
-
1
@bridge_content.data_type = BridgeContent.data_types[:image]
-
1
@bridge_content.save
-
end
-
1
it 'date_of_shooting will be update' do
-
1
expect(@bridge_content.date_of_shooting).to eq('2008/07/31 15:56:49')
-
end
-
end
-
-
1
describe 'main_content?' do
-
1
it 'default is false' do
-
1
expect(@bridge_content.main_content?).to eq(false)
-
end
-
1
it 'if have main_content, to be true' do
-
1
bridge_main_content = FactoryBot.create(:bridge_main_content, bridge_content: @bridge_content)
-
1
@bridge_content.bridge_main_content = bridge_main_content
-
1
expect(@bridge_content.main_content?).to eq(true)
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe BridgeMainContent, type: :model do
-
1
before do
-
2
@bridge_main_content = FactoryBot.build(:bridge_main_content)
-
end
-
-
3
subject { @bridge_main_content }
-
-
2
it { should respond_to(:bridge_content) }
-
2
it { should be_valid }
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe Bridge, type: :model do
-
1
before do
-
14
@bridge = FactoryBot.build(:bridge)
-
end
-
-
13
subject { @bridge }
-
-
2
it { should respond_to(:title) }
-
2
it { should respond_to(:address) }
-
2
it { should respond_to(:location) }
-
2
it { should respond_to(:soundnesses) }
-
2
it { should respond_to(:regular_inspections) }
-
2
it { should respond_to(:components) }
-
2
it { should respond_to(:bridge_length) }
-
2
it { should respond_to(:width) }
-
-
2
it { should be_valid }
-
-
1
describe 'when title is not present' do
-
2
before { @bridge.title = ' ' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when address is not present' do
-
2
before { @bridge.address = ' ' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when location is not present' do
-
2
before { @bridge.location = nil }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'full_title function' do
-
1
describe 'without kana_title' do
-
2
before { @bridge.title = 'test' }
-
2
it { expect(@bridge.full_title).to eq('test') }
-
end
-
1
describe 'with kana_title' do
-
1
before do
-
1
@bridge.title = 'test'
-
1
@bridge.kana_title = 'kana'
-
end
-
2
it { expect(@bridge.full_title).to eq('test (kana)') }
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe Component, type: :model do
-
1
before do
-
6
@bridge = FactoryBot.create(:bridge)
-
6
@component = FactoryBot.build(:component, bridge: @bridge)
-
end
-
-
7
subject { @component }
-
-
2
it { should respond_to(:bridge) }
-
2
it { should respond_to(:title) }
-
2
it { should respond_to(:component_category) }
-
2
it { should respond_to(:show_name) }
-
-
2
it { should be_valid }
-
-
1
describe 'when bridge is not present' do
-
2
before { @component.bridge = nil }
-
2
it { should_not be_valid }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe LocationImplement do
-
1
describe 'sexagesimal_to_float' do
-
1
it 'value 35°37′37″ returns 35.62694444444445' do
-
1
expect(LocationImplement.sexagesimal_to_float('35°37′37″')).to eq(35.62694444444445)
-
end
-
end
-
-
1
describe 'float_to_sexagesimal' do
-
1
it 'value 35.62694444 returns 35°37′37″' do
-
1
expect(LocationImplement.float_to_sexagesimal(35.62694444)).to eq('35°37′37″')
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe Dashboard, type: :model do
-
1
before do
-
6
@bridge1 = FactoryBot.create(:bridge, year_in_service: 1981, kind_of_bridge: 1)
-
6
@bridge2 = FactoryBot.create(:bridge)
-
6
@bridge3 = FactoryBot.create(:bridge)
-
6
@bridge4 = FactoryBot.create(:bridge, year_in_service: 2012, kind_of_bridge: 2)
-
6
FactoryBot.create(:soundness, bridge: @bridge1, evaluation_at: '2018/05/21', overall_evaluation: 'one')
-
6
FactoryBot.create(:soundness, bridge: @bridge2, evaluation_at: '2018/05/21', overall_evaluation: 'two')
-
6
FactoryBot.create(:soundness, bridge: @bridge3, evaluation_at: '2018/05/21', overall_evaluation: 'three')
-
6
@bridges = Bridge.includes(:soundnesses)
-
end
-
-
1
describe 'matrix_item' do
-
1
context 'call matrix' do
-
1
it 'return values' do
-
1
result = Dashboard.matrix(@bridges)
-
1
expect(result['2018']).not_to eq(nil)
-
1
expect(result['2018']['one']).not_to eq(nil)
-
1
expect(result['2018']['one']).to eq([@bridge1])
-
end
-
1
context 'with newer values' do
-
1
before do
-
1
FactoryBot.create(:soundness, bridge: @bridge1, evaluation_at: '2020/05/21', overall_evaluation: 'two')
-
end
-
1
it 'return newer values' do
-
1
result = Dashboard.matrix(@bridges)
-
1
expect(result['2018']).not_to eq(nil)
-
1
expect(result['2018']['one']).to eq(nil)
-
1
expect(result['2020']).not_to eq(nil)
-
1
expect(result['2020']['two']).to eq([@bridge1])
-
end
-
end
-
end
-
end
-
-
1
describe 'sorted_overall_evaluations' do
-
1
it 'return sorted value' do
-
1
result = Dashboard.sorted_overall_evaluations
-
1
expect(result).to eq(%w[unselected four three two one])
-
end
-
end
-
-
1
describe 'soundness_chart' do
-
1
it 'return chart values' do
-
1
result = Dashboard.soundness_chart(@bridges)
-
1
expect(result['unselected']).to eq(1)
-
1
expect(result['one']).to eq(1)
-
1
expect(result['two']).to eq(1)
-
1
expect(result['three']).to eq(1)
-
end
-
end
-
-
1
describe 'priority_chart' do
-
1
it 'return priority values' do
-
1
result = Dashboard.priority_chart(@bridges)
-
1
expect(result['priority_unselected']).to eq(4)
-
end
-
end
-
-
1
describe 'kind_of_bridge_chart' do
-
1
it 'return kink_of_bridge values' do
-
1
result = Dashboard.kind_of_bridge_chart(@bridges)
-
1
expect(result[1981]['concrete']).to eq(1)
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe Diagnosis, type: :model do
-
1
before do
-
11
@bridge = FactoryBot.create(:bridge)
-
11
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
-
11
@diagnosis = FactoryBot.create(:diagnosis, regular_inspection: @regular_inspection)
-
end
-
-
11
subject { @diagnosis }
-
-
2
it { should respond_to(:regular_inspection) }
-
2
it { should respond_to(:component_category) }
-
2
it { should respond_to(:result) }
-
2
it { should respond_to(:injury) }
-
2
it { should respond_to(:remark) }
-
-
2
it { should be_valid }
-
-
1
describe 'when result to two, it to be invalid' do
-
2
before { @diagnosis.result = Diagnosis.diagnosis_results[:two] }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when result to four, it to be valid' do
-
2
before { @diagnosis.result = Diagnosis.diagnosis_results[:four] }
-
2
it { should be_valid }
-
end
-
-
1
describe 'when result to two with injury' do
-
3
before { @diagnosis.result = Diagnosis.diagnosis_results[:two] }
-
1
describe 'with same component_category' do
-
1
before do
-
1
injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection)
-
1
@diagnosis.injury = injury
-
end
-
2
it { should be_valid }
-
end
-
1
describe 'with other component_category' do
-
1
before do
-
1
component = FactoryBot.create(:component, bridge: @bridge, component_category: Component.categories[:other])
-
1
injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: component)
-
1
@diagnosis.injury = injury
-
end
-
2
it { should_not be_valid }
-
end
-
end
-
-
1
describe 'when result to two with same component_category' do
-
1
before do
-
1
@new_diagnosis = FactoryBot.build(:diagnosis, regular_inspection: @regular_inspection)
-
end
-
2
subject { @new_diagnosis }
-
2
it { should_not be_valid }
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
OUTPUT_PATH = '/tmp/out'
-
1
INPUT_FILE = Rails.root.join('spec', 'testdata', 'ortho_image.png')
-
-
1
RSpec.describe GameTile, type: :model do
-
1
describe 'make tile' do
-
1
before do
-
1
game_tile = GameTile.new(INPUT_FILE, OUTPUT_PATH)
-
1
@result = game_tile.make
-
end
-
-
1
it 'generate tiles' do
-
1
check_file = File.join(OUTPUT_PATH, '8/0_0.png')
-
1
expect(File).to exist(check_file)
-
1
check_file = File.join(OUTPUT_PATH, '9/0_0.png')
-
1
expect(File).to exist(check_file)
-
1
check_file = File.join(OUTPUT_PATH, '9/0_1.png')
-
1
expect(File).to exist(check_file)
-
1
check_file = File.join(OUTPUT_PATH, '9/1_0.png')
-
1
expect(File).not_to exist(check_file)
-
1
expect(@result.first).to be(8)
-
1
expect(@result.last).to be(10)
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe Injury, type: :model do
-
1
before do
-
7
@bridge = FactoryBot.create(:bridge)
-
7
@component = FactoryBot.create(:component, bridge: @bridge)
-
7
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
-
7
@injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: @component)
-
end
-
-
8
subject { @injury }
-
-
2
it { should respond_to(:regular_inspection) }
-
2
it { should respond_to(:component) }
-
2
it { should respond_to(:injury_type) }
-
2
it { should respond_to(:injury_grade) }
-
-
2
it { should be_valid }
-
-
1
describe 'when regular_inspection is not present' do
-
2
before { @injury.regular_inspection = nil }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when component is not present' do
-
2
before { @injury.component = nil }
-
2
it { should_not be_valid }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe MlitImporter, type: :model do
-
1
describe 'import' do
-
1
context 'with mlit-testdata-001.xlsx' do
-
1
it 'can read file' do
-
1
file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001.xlsx')
-
1
bridge = MlitImporter.import(file)
-
1
expect(bridge.title).to eq('テスト橋')
-
1
expect(bridge.address).to eq('千葉県千葉市若葉区テスト橋')
-
1
expect(bridge.location.latitude).to eq(35.62694444444445)
-
1
expect(bridge.location.longitude).to eq(140.16611111111112)
-
1
expect(bridge.valid?).to eq(true)
-
end
-
end
-
-
1
context 'with mlit-testdata-001-invalid.xlsx' do
-
1
it 'cannot read file' do
-
1
file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001-invalid.xlsx')
-
1
bridge = MlitImporter.import(file)
-
1
expect(bridge.title).to eq(nil)
-
1
expect(bridge.address).to eq('千葉県千葉市若葉区テスト橋')
-
1
expect(bridge.location.latitude).to eq(35.62694444444445)
-
1
expect(bridge.location.longitude).to eq(140.16611111111112)
-
1
expect(bridge.valid?).to eq(false)
-
end
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe RegularInspection, type: :model do
-
1
before do
-
9
@bridge = FactoryBot.create(:bridge)
-
9
@regular_inspection = FactoryBot.build(:regular_inspection, bridge: @bridge)
-
end
-
-
10
subject { @regular_inspection }
-
-
2
it { should respond_to(:title) }
-
2
it { should respond_to(:person_responsible) }
-
2
it { should respond_to(:periodic_inspection_date) }
-
2
it { should respond_to(:record_updated_date) }
-
2
it { should respond_to(:start_date) }
-
2
it { should respond_to(:end_date) }
-
-
2
it { should be_valid }
-
-
1
describe 'when bridge is not present' do
-
2
before { @regular_inspection.bridge = nil }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when title is not present' do
-
2
before { @regular_inspection.title = ' ' }
-
2
it { should_not be_valid }
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe Soundness, type: :model do
-
1
before do
-
9
@soundness = FactoryBot.build(:soundness)
-
end
-
-
8
subject { @soundness }
-
-
2
it { should respond_to(:bridge) }
-
2
it { should respond_to(:evaluation) }
-
2
it { should respond_to(:evaluation_at) }
-
2
it { should respond_to(:overall_evaluation) }
-
2
it { should be_valid }
-
-
1
describe 'when evaluation is not present' do
-
2
before { @soundness.evaluation = ' ' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when evaluation_at is not present' do
-
2
before { @soundness.evaluation_at = nil }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'overall_evaluation' do
-
1
describe 'enable to change by integer' do
-
2
before { @soundness.overall_evaluation = 2 }
-
2
subject { @soundness.two? }
-
2
it { should eq(true) }
-
end
-
end
-
-
1
describe 'count' do
-
1
it 'up to 1' do
-
1
soundness = Soundness.new(bridge: FactoryBot.create(:bridge))
-
1
soundness.evaluation = 'test'
-
1
soundness.evaluation_at = '2020/10/15'
-
1
expect do
-
1
soundness.save
-
end.to change(Soundness, :count).by(1)
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe User, type: :model do
-
1
before do
-
16
@user = FactoryBot.build(:user)
-
end
-
-
14
subject { @user }
-
-
2
it { should respond_to(:login_name) }
-
2
it { should respond_to(:password_digest) }
-
2
it { should respond_to(:password) }
-
2
it { should respond_to(:password_confirmation) }
-
2
it { should respond_to(:authenticate) }
-
-
2
it { should be_valid }
-
-
1
describe 'when login_name is not present' do
-
2
before { @user.login_name = ' ' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when login_name is already taken' do
-
1
before do
-
1
with_same_login_name = @user.dup
-
1
with_same_login_name.save
-
end
-
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'when password is not present' do
-
1
before do
-
1
@user = FactoryBot.build(:user, password: '', password_confirmation: '')
-
end
-
2
it { should_not be_valid }
-
end
-
-
1
describe "when password doesn't match confirmation" do
-
2
before { @user.password_confirmation = 'mismatch' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe "with a password that's too short" do
-
2
before { @user.password = @user.password_confirmation = 'aaaaaa1' }
-
2
it { should_not be_valid }
-
end
-
-
1
describe 'return value of authenticate method' do
-
4
before { @user.save }
-
4
let(:found_user) { User.find_by(login_name: @user.login_name) }
-
-
1
describe 'with valid password' do
-
2
it { should eq found_user.authenticate(@user.password) }
-
end
-
-
1
describe 'with invalid password' do
-
3
let(:for_invalid_password) { found_user.authenticate('invalid') }
-
-
2
it { should_not eq for_invalid_password }
-
2
specify { expect(for_invalid_password).to be_falsey }
-
end
-
end
-
-
1
describe 'when password format is invalid' do
-
1
it 'should be invalid' do
-
1
passwords = %w[a*8 11111111 abcd_1234]
-
1
passwords.each do |invalid_password|
-
3
@user.password = @user.password_confirmation = invalid_password
-
3
expect(@user).not_to be_valid
-
end
-
1
@user.password = @user.password_confirmation = 'abcd 1234'
-
1
expect(@user).not_to be_valid
-
end
-
end
-
-
1
describe 'when password format is valid' do
-
1
it 'should be valid' do
-
1
passwords = %w[abcd1234 AbcdEFG1 1234567A]
-
1
passwords.each do |valid_password|
-
3
@user.password = @user.password_confirmation = valid_password
-
3
expect(@user).to be_valid
-
end
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'Admin::Sessions', type: :request do # rubocop:disable Metrics/BlockLength
-
1
describe 'GET /admin/sessions/index' do
-
1
it 'show index view' do
-
1
get admin_sessions_index_path
-
1
expect(response).to have_http_status(200)
-
end
-
end
-
-
1
describe 'POST /admin/sessions/login' do
-
1
before do
-
2
@admin_user = FactoryBot.create(:admin_user)
-
end
-
-
1
it 'enable to login' do
-
1
post admin_sessions_login_path, params: {
-
admin_user: {
-
login_name: @admin_user.login_name,
-
password: @admin_user.password
-
}
-
}
-
1
expect(response).to redirect_to admin_top_index_path
-
end
-
-
1
it 'fail with invalid password' do
-
1
post admin_sessions_login_path, params: {
-
admin_user: {
-
login_name: @admin_user.login_name,
-
password: 'pass0000'
-
}
-
}
-
1
expect(response).to have_http_status(200)
-
1
expect(response.body).to include 'password'
-
1
expect(response.body).to include @admin_user.login_name
-
end
-
end
-
-
1
describe 'POST /admin/sessions/logout' do
-
1
it 'enable to logout' do
-
1
get admin_sessions_logout_path
-
1
expect(response).to redirect_to admin_sessions_index_path
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'Admin::Tops', type: :request do
-
1
before do
-
2
@admin_user = FactoryBot.create(:admin_user)
-
2
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ admin_user_id: @admin_user.id })
-
end
-
1
describe 'GET /admin/top/index' do
-
1
it 'enable to access' do
-
1
get admin_top_index_path
-
1
expect(response).to have_http_status(200)
-
end
-
-
1
it 'fail without login' do
-
1
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ admin_user_id: '' })
-
1
get admin_top_index_path
-
1
expect(response).to redirect_to admin_sessions_index_path
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/admin/users', type: :request do
-
1
before do
-
13
@admin_user = FactoryBot.create(:admin_user)
-
13
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ admin_user_id: @admin_user.id })
-
end
-
-
# Admin::User. As you add validations to Admin::User, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
10
{
-
login_name: 'user',
-
password: 'passw0rd'
-
}
-
end
-
-
1
let(:invalid_attributes) do
-
{
-
3
login_name: Faker::Internet.user_name,
-
password: 'pass'
-
}
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
User.create! valid_attributes
-
1
get admin_users_url
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
user = User.create! valid_attributes
-
1
get admin_user_url(user)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_admin_user_url
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
user = User.create! valid_attributes
-
1
get edit_admin_user_url(user)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new User' do
-
1
expect do
-
1
post admin_users_url, params: { user: valid_attributes }
-
end.to change(User, :count).by(1)
-
end
-
-
1
it 'redirects to the created admin_user' do
-
1
post admin_users_url, params: { user: valid_attributes }
-
1
user = User.last
-
1
expect(response).to redirect_to(admin_user_url(user))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new User' do
-
1
expect do
-
1
post admin_users_url, params: { user: invalid_attributes }
-
end.to change(User, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post admin_users_url, params: { user: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
{
-
login_name: 'user1',
-
password: 'passw0rd'
-
}
-
end
-
-
1
it 'updates the requested user' do
-
1
user = User.create! valid_attributes
-
1
patch admin_user_url(user), params: { user: new_attributes }
-
1
user.reload
-
1
expect(user.login_name).to eq 'user1'
-
end
-
-
1
it 'redirects to the user' do
-
1
user = User.create! valid_attributes
-
1
patch admin_user_url(user), params: { user: new_attributes }
-
1
user.reload
-
1
expect(response).to redirect_to(admin_user_url(user))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
user = User.create! valid_attributes
-
1
patch admin_user_url(user), params: { user: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested admin_user' do
-
1
user = User.create! valid_attributes
-
1
expect do
-
1
delete admin_user_url(user)
-
end.to change(User, :count).by(-1)
-
end
-
-
1
it 'redirects to the admin_users list' do
-
1
user = User.create! valid_attributes
-
1
delete admin_user_url(user)
-
1
expect(response).to redirect_to(admin_users_url)
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/bridge_content_injuries', type: :request do
-
1
before do
-
13
@user = FactoryBot.create(:user)
-
13
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
13
@bridge = FactoryBot.create(:bridge)
-
13
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
-
13
@component = FactoryBot.create(:component, bridge: @bridge)
-
13
@injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: @component)
-
13
@bridge_content = FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection)
-
end
-
-
# BridgeContentInjury. As you add validations to BridgeContentInjury, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
10
FactoryBot.build(:bridge_content_injury, injury: @injury, bridge_content: @bridge_content).attributes
-
end
-
-
1
let(:invalid_attributes) do
-
3
bridge_content_injury = FactoryBot.build(:bridge_content_injury, injury: @injury, bridge_content: @bridge_content)
-
3
bridge_content_injury.bridge_content = nil
-
3
bridge_content_injury.attributes
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
BridgeContentInjury.create! valid_attributes
-
1
get regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
bridge_content_injury = BridgeContentInjury.create! valid_attributes
-
1
get regular_inspection_injury_bridge_content_injury_url(@regular_inspection, @injury, bridge_content_injury)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_regular_inspection_injury_bridge_content_injury_url(@regular_inspection, @injury)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
bridge_content_injury = BridgeContentInjury.create! valid_attributes
-
1
get edit_regular_inspection_injury_bridge_content_injury_url(@regular_inspection, @injury, bridge_content_injury)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new BridgeContentInjury' do
-
1
expect do
-
1
post regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
-
params: { bridge_content_injury: valid_attributes }
-
end.to change(BridgeContentInjury, :count).by(1)
-
end
-
-
1
it 'redirects to the created bridge_content_injury' do
-
1
post regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
-
params: { bridge_content_injury: valid_attributes }
-
1
expect(response).to redirect_to(
-
regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
-
@injury,
-
BridgeContentInjury.last)
-
)
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new BridgeContentInjury' do
-
1
expect do
-
1
post regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
-
params: { bridge_content_injury: invalid_attributes }
-
end.to change(BridgeContentInjury, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
-
params: { bridge_content_injury: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
@new_bridge_content = FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection)
-
2
bridge_content_injury = FactoryBot.build(:bridge_content_injury, bridge_content: @new_bridge_content).attributes
-
2
bridge_content_injury['seek'] = 2
-
2
bridge_content_injury
-
end
-
-
1
it 'updates the requested bridge_content_injury' do
-
1
bridge_content_injury = BridgeContentInjury.create! valid_attributes
-
1
patch regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
-
@injury,
-
bridge_content_injury),
-
params: { bridge_content_injury: new_attributes }
-
1
bridge_content_injury.reload
-
1
expect(bridge_content_injury.bridge_content).to eq(@new_bridge_content)
-
1
expect(bridge_content_injury.seek).to eq(2)
-
end
-
-
1
it 'redirects to the bridge_content_injury' do
-
1
bridge_content_injury = BridgeContentInjury.create! valid_attributes
-
1
patch regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
-
@injury,
-
bridge_content_injury),
-
params: { bridge_content_injury: new_attributes }
-
1
bridge_content_injury.reload
-
1
expect(response).to redirect_to(
-
regular_inspection_injury_bridge_content_injury_url(@regular_inspection, @injury, bridge_content_injury)
-
)
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
bridge_content_injury = BridgeContentInjury.create! valid_attributes
-
1
patch regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
-
@injury,
-
bridge_content_injury),
-
params: { bridge_content_injury: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested bridge_content_injury' do
-
1
bridge_content_injury = BridgeContentInjury.create! valid_attributes
-
1
expect do
-
1
delete regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
-
@injury,
-
bridge_content_injury)
-
end.to change(BridgeContentInjury, :count).by(-1)
-
end
-
-
1
it 'redirects to the bridge_content_injuries list' do
-
1
bridge_content_injury = BridgeContentInjury.create! valid_attributes
-
1
delete regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
-
@injury,
-
bridge_content_injury)
-
1
expect(response).to redirect_to(
-
regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury)
-
)
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/bridge_contents', type: :request do
-
1
before do
-
13
@user = FactoryBot.create(:user)
-
13
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
13
@regular_inspection = FactoryBot.create(:regular_inspection)
-
end
-
-
# BridgeContent. As you add validations to BridgeContent, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
10
attributes = FactoryBot.build(:bridge_content, regular_inspection: @regular_inspection).attributes
-
10
attributes['data'] = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testimage.jpg'))
-
10
attributes
-
end
-
-
1
let(:invalid_attributes) do
-
3
attributes = FactoryBot.build(:bridge_content, regular_inspection: @regular_inspection).attributes
-
3
attributes['title'] = ''
-
3
attributes
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
BridgeContent.create! valid_attributes
-
1
get regular_inspection_bridge_contents_url(@regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
bridge_content = BridgeContent.create! valid_attributes
-
1
get regular_inspection_bridge_content_url(@regular_inspection, bridge_content)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_regular_inspection_bridge_content_url(@regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
bridge_content = BridgeContent.create! valid_attributes
-
1
get edit_regular_inspection_bridge_content_url(@regular_inspection, bridge_content)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new BridgeContent' do
-
1
expect do
-
1
post regular_inspection_bridge_contents_url(@regular_inspection), params: { bridge_content: valid_attributes }
-
end.to change(BridgeContent, :count).by(1)
-
end
-
-
1
it 'redirects to the created bridge_content' do
-
1
post regular_inspection_bridge_contents_url(@regular_inspection), params: { bridge_content: valid_attributes }
-
1
expect(response).to redirect_to(regular_inspection_bridge_content_url(@regular_inspection, BridgeContent.last))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new BridgeContent' do
-
1
expect do
-
1
post regular_inspection_bridge_contents_url(@regular_inspection),
-
params: { bridge_content: invalid_attributes }
-
end.to change(BridgeContent, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post regular_inspection_bridge_contents_url(@regular_inspection), params: { bridge_content: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
attributes = valid_attributes
-
2
attributes['data'] = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testmovie.mp4'))
-
2
attributes
-
end
-
-
1
it 'updates the requested bridge_content' do
-
1
bridge_content = BridgeContent.create! valid_attributes
-
1
patch regular_inspection_bridge_content_url(@regular_inspection, bridge_content),
-
params: { bridge_content: new_attributes }
-
1
bridge_content.reload
-
1
expect(bridge_content.data.content_type).to eq('video/mp4')
-
end
-
-
1
it 'redirects to the bridge_content' do
-
1
bridge_content = BridgeContent.create! valid_attributes
-
1
patch regular_inspection_bridge_content_url(@regular_inspection, bridge_content),
-
params: { bridge_content: new_attributes }
-
1
bridge_content.reload
-
1
expect(response).to redirect_to(regular_inspection_bridge_content_url(@regular_inspection, bridge_content))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
bridge_content = BridgeContent.create! valid_attributes
-
1
patch regular_inspection_bridge_content_url(@regular_inspection, bridge_content),
-
params: { bridge_content: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested bridge_content' do
-
1
bridge_content = BridgeContent.create! valid_attributes
-
1
expect do
-
1
delete regular_inspection_bridge_content_url(@regular_inspection, bridge_content)
-
end.to change(BridgeContent, :count).by(-1)
-
end
-
-
1
it 'redirects to the bridge_contents list' do
-
1
bridge_content = BridgeContent.create! valid_attributes
-
1
delete regular_inspection_bridge_content_url(@regular_inspection, bridge_content)
-
1
expect(response).to redirect_to(regular_inspection_bridge_contents_url(@regular_inspection))
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe 'BridgeMainContents', type: :request do
-
1
before do
-
6
@user = FactoryBot.create(:user)
-
6
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
6
@bridge = FactoryBot.create(:bridge)
-
6
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
-
6
@bridge_content = FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection)
-
end
-
-
# BridgeMainContent. As you add validations to BridgeMainContent, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
4
FactoryBot.build(:bridge_main_content,
-
bridge_content: @bridge_content).attributes
-
end
-
-
1
let(:invalid_attributes) do
-
2
invalid_value = FactoryBot.build(:bridge_main_content)
-
2
invalid_value.bridge_content = nil
-
2
invalid_value.attributes
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new Injury' do
-
1
expect do
-
1
post regular_inspection_bridge_main_contents_url(@regular_inspection),
-
params: { bridge_main_content: valid_attributes }
-
end.to change(BridgeMainContent, :count).by(1)
-
end
-
-
1
it 'redirects to bridge_contents index' do
-
1
post regular_inspection_bridge_main_contents_url(@regular_inspection),
-
params: { bridge_main_content: valid_attributes }
-
1
expect(response).to redirect_to(regular_inspection_bridge_contents_url(@regular_inspection))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new Injury' do
-
1
expect do
-
1
post regular_inspection_bridge_main_contents_url(@regular_inspection),
-
params: { bridge_main_content: invalid_attributes }
-
end.to change(BridgeMainContent, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post regular_inspection_bridge_main_contents_url(@regular_inspection),
-
params: { bridge_main_content: invalid_attributes }
-
1
expect(response).to redirect_to(regular_inspection_bridge_contents_url(@regular_inspection))
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested bridge_main_content' do
-
1
bridge_main_content = BridgeMainContent.create! valid_attributes
-
1
expect do
-
1
delete regular_inspection_bridge_main_content_url(@regular_inspection, bridge_main_content)
-
end.to change(BridgeMainContent, :count).by(-1)
-
end
-
-
1
it 'redirects to the injuries list' do
-
1
bridge_main_content = BridgeMainContent.create! valid_attributes
-
1
delete regular_inspection_bridge_main_content_url(@regular_inspection, bridge_main_content)
-
1
expect(response).to redirect_to(regular_inspection_bridge_contents_url(@regular_inspection))
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/bridges', type: :request do
-
1
before do
-
13
@user = FactoryBot.create(:user)
-
13
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
end
-
-
# Bridge. As you add validations to Bridge, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
10
bridge = FactoryBot.build(:bridge).attributes
-
10
bridge['bridge_length'] = bridge['other_data']['bridge_length']
-
10
bridge['width'] = bridge['other_data']['width']
-
10
bridge
-
end
-
-
1
let(:invalid_attributes) do
-
3
bridge = FactoryBot.build(:bridge)
-
3
bridge.title = ''
-
3
bridge.attributes
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
Bridge.create! valid_attributes
-
1
get bridges_url
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
bridge = Bridge.create! valid_attributes
-
1
get bridge_url(bridge)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_bridge_url
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
bridge = Bridge.create! valid_attributes
-
1
get edit_bridge_url(bridge)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new Bridge' do
-
1
expect do
-
1
post bridges_url, params: { bridge: valid_attributes }
-
end.to change(Bridge, :count).by(1)
-
end
-
-
1
it 'redirects to the created bridge' do
-
1
post bridges_url, params: { bridge: valid_attributes }
-
1
expect(response).to redirect_to(bridge_url(Bridge.last))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new Bridge' do
-
1
expect do
-
1
post bridges_url, params: { bridge: invalid_attributes }
-
end.to change(Bridge, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post bridges_url, params: { bridge: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
bridge = FactoryBot.build(:bridge).attributes
-
2
bridge['bridge_length'] = 20
-
2
bridge['width'] = 6.5
-
2
bridge['emergency_transport_road'] = true
-
2
bridge['title'] = 'title'
-
2
bridge['kana_title'] = 'kana'
-
2
bridge
-
end
-
-
1
it 'updates the requested bridge' do
-
1
new_params = new_attributes
-
1
bridge = Bridge.create! valid_attributes
-
1
patch bridge_url(bridge), params: { bridge: new_params }
-
1
bridge.reload
-
1
expect(bridge.title).to eq(new_params['title'])
-
1
expect(bridge.bridge_length).to eq(20)
-
1
expect(bridge.width).to eq(6.5)
-
1
expect(bridge.emergency_transport_road).to eq(true)
-
1
expect(bridge.full_title).to eq('title (kana)')
-
end
-
-
1
it 'redirects to the bridge' do
-
1
bridge = Bridge.create! valid_attributes
-
1
patch bridge_url(bridge), params: { bridge: new_attributes }
-
1
bridge.reload
-
1
expect(response).to redirect_to(bridge_url(bridge))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
bridge = Bridge.create! valid_attributes
-
1
patch bridge_url(bridge), params: { bridge: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested bridge' do
-
1
bridge = Bridge.create! valid_attributes
-
1
expect do
-
1
delete bridge_url(bridge)
-
end.to change(Bridge, :count).by(-1)
-
end
-
-
1
it 'redirects to the bridges list' do
-
1
bridge = Bridge.create! valid_attributes
-
1
delete bridge_url(bridge)
-
1
expect(response).to redirect_to(bridges_url)
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/components', type: :request do
-
1
before do
-
13
@user = FactoryBot.create(:user)
-
13
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
13
@bridge = FactoryBot.create(:bridge)
-
end
-
-
# Component. As you add validations to Component, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
10
FactoryBot.build(:component, bridge: @bridge).attributes
-
end
-
-
1
let(:invalid_attributes) do
-
3
component = FactoryBot.build(:component, bridge: @bridge)
-
3
component.component_category = nil
-
3
component.attributes
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
Component.create! valid_attributes
-
1
get bridge_components_url(@bridge)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
component = Component.create! valid_attributes
-
1
get bridge_component_url(@bridge, component)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_bridge_component_url(@bridge)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
component = Component.create! valid_attributes
-
1
get edit_bridge_component_url(@bridge, component)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new Component' do
-
1
expect do
-
1
post bridge_components_url(@bridge), params: { component: valid_attributes }
-
end.to change(Component, :count).by(1)
-
end
-
-
1
it 'redirects to the created component' do
-
1
post bridge_components_url(@bridge), params: { component: valid_attributes }
-
1
expect(response).to redirect_to(bridge_component_url(@bridge, Component.last))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new Component' do
-
1
expect do
-
1
post bridge_components_url(@bridge), params: { component: invalid_attributes }
-
end.to change(Component, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post bridge_components_url(@bridge), params: { component: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
component = FactoryBot.build(:component, bridge: @bridge)
-
2
component.component_category = Component.categories[:other]
-
2
component.attributes
-
end
-
-
1
it 'updates the requested component' do
-
1
component = Component.create! valid_attributes
-
1
patch bridge_component_url(@bridge, component), params: { component: new_attributes }
-
1
component.reload
-
1
expect(component.component_category).to eq(6)
-
end
-
-
1
it 'redirects to the component' do
-
1
component = Component.create! valid_attributes
-
1
patch bridge_component_url(@bridge, component), params: { component: new_attributes }
-
1
component.reload
-
1
expect(response).to redirect_to(bridge_component_url(@bridge, component))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
component = Component.create! valid_attributes
-
1
patch bridge_component_url(@bridge, component), params: { component: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested component' do
-
1
component = Component.create! valid_attributes
-
1
expect do
-
1
delete bridge_component_url(@bridge, component)
-
end.to change(Component, :count).by(-1)
-
end
-
-
1
it 'redirects to the components list' do
-
1
component = Component.create! valid_attributes
-
1
delete bridge_component_url(@bridge, component)
-
1
expect(response).to redirect_to(bridge_components_url(@bridge))
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/diagnoses', type: :request do
-
1
before do
-
13
@user = FactoryBot.create(:user)
-
13
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
13
@bridge = FactoryBot.create(:bridge)
-
13
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
-
13
@component = FactoryBot.create(:component, bridge: @bridge)
-
13
@injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: @component)
-
end
-
-
# Diagnosis. As you add validations to Diagnosis, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
10
FactoryBot.build(:diagnosis, regular_inspection: @regular_inspection, injury: @injury).attributes
-
end
-
-
1
let(:invalid_attributes) do
-
3
regular_inspection = FactoryBot.build(:diagnosis, regular_inspection: @regular_inspection, injury: @injury)
-
3
regular_inspection.injury = nil
-
3
regular_inspection.result = Diagnosis.diagnosis_results[:two]
-
3
regular_inspection.attributes
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
Diagnosis.create! valid_attributes
-
1
get regular_inspection_diagnoses_url(@regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
diagnosis = Diagnosis.create! valid_attributes
-
1
get regular_inspection_diagnosis_url(@regular_inspection, diagnosis)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_regular_inspection_diagnosis_url(@regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
diagnosis = Diagnosis.create! valid_attributes
-
1
get edit_regular_inspection_diagnosis_url(@regular_inspection, diagnosis)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new Diagnosis' do
-
1
expect do
-
1
post regular_inspection_diagnoses_url(@regular_inspection), params: { diagnosis: valid_attributes }
-
end.to change(Diagnosis, :count).by(1)
-
end
-
-
1
it 'redirects to the created diagnosis' do
-
1
post regular_inspection_diagnoses_url(@regular_inspection), params: { diagnosis: valid_attributes }
-
1
expect(response).to redirect_to(regular_inspection_diagnosis_url(@regular_inspection, Diagnosis.last))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new Diagnosis' do
-
1
expect do
-
1
post regular_inspection_diagnoses_url(@regular_inspection), params: { diagnosis: invalid_attributes }
-
end.to change(Diagnosis, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post regular_inspection_diagnoses_url(@regular_inspection), params: { diagnosis: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
regular_inspection = FactoryBot.build(:diagnosis, regular_inspection: @regular_inspection, injury: @injury)
-
2
regular_inspection.result = Diagnosis.diagnosis_results[:three]
-
2
regular_inspection.attributes
-
end
-
-
1
it 'updates the requested diagnosis' do
-
1
diagnosis = Diagnosis.create! valid_attributes
-
1
patch regular_inspection_diagnosis_url(@regular_inspection, diagnosis), params: { diagnosis: new_attributes }
-
1
diagnosis.reload
-
1
expect(diagnosis.result).to eq(Diagnosis.diagnosis_results[:three])
-
end
-
-
1
it 'redirects to the diagnosis' do
-
1
diagnosis = Diagnosis.create! valid_attributes
-
1
patch regular_inspection_diagnosis_url(@regular_inspection, diagnosis), params: { diagnosis: new_attributes }
-
1
diagnosis.reload
-
1
expect(response).to redirect_to(regular_inspection_diagnosis_url(@regular_inspection, diagnosis))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
diagnosis = Diagnosis.create! valid_attributes
-
1
patch regular_inspection_diagnosis_url(@regular_inspection, diagnosis),
-
params: { diagnosis: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested diagnosis' do
-
1
diagnosis = Diagnosis.create! valid_attributes
-
1
expect do
-
1
delete regular_inspection_diagnosis_url(@regular_inspection, diagnosis)
-
end.to change(Diagnosis, :count).by(-1)
-
end
-
-
1
it 'redirects to the diagnoses list' do
-
1
diagnosis = Diagnosis.create! valid_attributes
-
1
delete regular_inspection_diagnosis_url(@regular_inspection, diagnosis)
-
1
expect(response).to redirect_to(regular_inspection_diagnoses_url(@regular_inspection))
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/injuries', type: :request do
-
1
before do
-
13
@user = FactoryBot.create(:user)
-
13
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
13
@bridge = FactoryBot.create(:bridge)
-
13
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
-
13
@component = FactoryBot.create(:component, bridge: @bridge)
-
end
-
-
# Injury. As you add validations to Injury, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
10
FactoryBot.build(:injury, regular_inspection: @regular_inspection, component: @component).attributes
-
end
-
-
1
let(:invalid_attributes) do
-
3
invalid_value = FactoryBot.build(:injury, regular_inspection: @regular_inspection, component: @component)
-
3
invalid_value.component = nil
-
3
invalid_value.attributes
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
Injury.create! valid_attributes
-
1
get regular_inspection_injuries_url(@regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
injury = Injury.create! valid_attributes
-
1
get regular_inspection_injury_url(@regular_inspection, injury)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_regular_inspection_injury_url(@regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
injury = Injury.create! valid_attributes
-
1
get edit_regular_inspection_injury_url(@regular_inspection, injury)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new Injury' do
-
1
expect do
-
1
post regular_inspection_injuries_url(@regular_inspection), params: { injury: valid_attributes }
-
end.to change(Injury, :count).by(1)
-
end
-
-
1
it 'redirects to the created injury' do
-
1
post regular_inspection_injuries_url(@regular_inspection), params: { injury: valid_attributes }
-
1
expect(response).to redirect_to(regular_inspection_injury_url(@regular_inspection, Injury.last))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new Injury' do
-
1
expect do
-
1
post regular_inspection_injuries_url(@regular_inspection), params: { injury: invalid_attributes }
-
end.to change(Injury, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post regular_inspection_injuries_url(@regular_inspection), params: { injury: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
new_value = FactoryBot.build(:injury, regular_inspection: @regular_inspection, component: @component).attributes
-
2
new_value['injury_type'] = 'test!'
-
2
new_value['unit'] = 'm'
-
2
new_value
-
end
-
-
1
it 'updates the requested injury' do
-
1
injury = Injury.create! valid_attributes
-
1
patch regular_inspection_injury_url(@regular_inspection, injury), params: { injury: new_attributes }
-
1
injury.reload
-
1
expect(injury.injury_type).to eq('test!')
-
1
expect(injury.unit).to eq('m')
-
end
-
-
1
it 'redirects to the injury' do
-
1
injury = Injury.create! valid_attributes
-
1
patch regular_inspection_injury_url(@regular_inspection, injury), params: { injury: new_attributes }
-
1
injury.reload
-
1
expect(response).to redirect_to(regular_inspection_injury_url(@regular_inspection, injury))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
injury = Injury.create! valid_attributes
-
1
patch regular_inspection_injury_url(@regular_inspection, injury), params: { injury: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested injury' do
-
1
injury = Injury.create! valid_attributes
-
1
expect do
-
1
delete regular_inspection_injury_url(@regular_inspection, injury)
-
end.to change(Injury, :count).by(-1)
-
end
-
-
1
it 'redirects to the injuries list' do
-
1
injury = Injury.create! valid_attributes
-
1
delete regular_inspection_injury_url(@regular_inspection, injury)
-
1
expect(response).to redirect_to(regular_inspection_injury_url(@regular_inspection))
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe 'MlitImporters', type: :request do
-
1
before do
-
7
@user = FactoryBot.create(:user)
-
7
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
end
-
-
1
let(:valid_attributes) do
-
2
file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001.xlsx')
-
2
MlitImporter.import(file).attributes
-
end
-
-
1
let(:invalid_attributes) do
-
2
file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001-invalid.xlsx')
-
2
MlitImporter.import(file).attributes
-
end
-
-
1
describe 'GET /new' do
-
1
it 'returns http success' do
-
1
get new_mlit_importer_url
-
1
expect(response).to have_http_status(:success)
-
end
-
end
-
-
1
describe 'GET /preview' do
-
1
it 'returns http success' do
-
1
file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001.xlsx')
-
1
post preview_mlit_importer_url, params: {
-
upload_file: Rack::Test::UploadedFile.new(file)
-
}
-
1
expect(response).to have_http_status(:success)
-
1
expect(response.body).to include('bridge[title]')
-
end
-
-
1
it 'render new' do
-
1
file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001-invalid.xlsx')
-
1
post preview_mlit_importer_url, params: {
-
upload_file: Rack::Test::UploadedFile.new(file)
-
}
-
1
expect(response).to have_http_status(:success)
-
1
expect(response.body).to include('file')
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
describe 'with valid data' do
-
1
it 'creates a new Bridge' do
-
1
expect do
-
1
post mlit_importer_url, params: { bridge: valid_attributes }
-
end.to change(Bridge, :count).by(1)
-
end
-
-
1
it 'redirects to the created bridge' do
-
1
post mlit_importer_url, params: { bridge: valid_attributes }
-
1
expect(response).to redirect_to(bridge_url(Bridge.last))
-
end
-
end
-
-
1
describe 'with invalid data' do
-
1
it 'cannot creates a new Bridge' do
-
1
expect do
-
1
post mlit_importer_url, params: { bridge: invalid_attributes }
-
end.to change(Bridge, :count).by(0)
-
end
-
-
1
it 'render new page' do
-
1
post mlit_importer_url, params: { bridge: invalid_attributes }
-
1
expect(response.body).to include('file')
-
end
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/regular_inspections', type: :request do
-
1
before do
-
15
@user = FactoryBot.create(:user)
-
15
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
15
@bridge = FactoryBot.create(:bridge)
-
end
-
# RegularInspection. As you add validations to RegularInspection, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
12
FactoryBot.build(:regular_inspection, bridge: @bridge).attributes
-
end
-
-
1
let(:invalid_attributes) do
-
3
regular_inspection = FactoryBot.build(:regular_inspection, bridge: @bridge)
-
3
regular_inspection.title = ''
-
3
regular_inspection.attributes
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
RegularInspection.create! valid_attributes
-
1
get regular_inspections_url
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
get regular_inspection_url(regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_regular_inspection_url
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
get edit_regular_inspection_url(regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new RegularInspection' do
-
1
expect do
-
1
post regular_inspections_url, params: { regular_inspection: valid_attributes }
-
end.to change(RegularInspection, :count).by(1)
-
end
-
-
1
it 'redirects to the created regular_inspection' do
-
1
post regular_inspections_url, params: { regular_inspection: valid_attributes }
-
1
expect(response).to redirect_to(regular_inspection_url(RegularInspection.last))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new RegularInspection' do
-
1
expect do
-
1
post regular_inspections_url, params: { regular_inspection: invalid_attributes }
-
end.to change(RegularInspection, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post regular_inspections_url, params: { regular_inspection: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
FactoryBot.build(:regular_inspection, bridge: @bridge, title: 'test!').attributes
-
end
-
-
1
it 'updates the requested regular_inspection' do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
patch regular_inspection_url(regular_inspection), params: { regular_inspection: new_attributes }
-
1
regular_inspection.reload
-
1
expect(regular_inspection.title).to eq('test!')
-
end
-
-
1
it 'redirects to the regular_inspection' do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
patch regular_inspection_url(regular_inspection), params: { regular_inspection: new_attributes }
-
1
regular_inspection.reload
-
1
expect(response).to redirect_to(regular_inspection_url(regular_inspection))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
patch regular_inspection_url(regular_inspection), params: { regular_inspection: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested regular_inspection' do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
expect do
-
1
delete regular_inspection_url(regular_inspection)
-
end.to change(RegularInspection, :count).by(-1)
-
end
-
-
1
it 'redirects to the regular_inspections list' do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
delete regular_inspection_url(regular_inspection)
-
1
expect(response).to redirect_to(regular_inspections_url)
-
end
-
end
-
-
1
describe 'GET /bridge_id/download_image_metadata' do
-
1
it 'download simple template' do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
get regular_inspection_download_image_metadata_url(regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /bridge_id/download_pointcloud_metadata' do
-
1
it 'download simple template' do
-
1
regular_inspection = RegularInspection.create! valid_attributes
-
1
get regular_inspection_download_pointcloud_metadata_url(regular_inspection)
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'Sessions', type: :request do
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe '/soundnesses', type: :request do
-
1
before do
-
13
@user = FactoryBot.create(:user)
-
13
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
13
@bridge = FactoryBot.create(:bridge)
-
end
-
# Soundness. As you add validations to Soundness, be sure to
-
# adjust the attributes here as well.
-
1
let(:valid_attributes) do
-
10
FactoryBot.build(:soundness, bridge: @bridge).attributes
-
end
-
-
1
let(:invalid_attributes) do
-
3
attributes = FactoryBot.build(:soundness, bridge: @bridge).attributes
-
3
attributes['evaluation'] = ''
-
3
attributes
-
end
-
-
1
describe 'GET /index' do
-
1
it 'renders a successful response' do
-
1
Soundness.create! valid_attributes
-
1
get bridge_soundnesses_url(@bridge)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /show' do
-
1
it 'renders a successful response' do
-
1
soundness = Soundness.create! valid_attributes
-
1
get bridge_soundness_url(@bridge, soundness)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /new' do
-
1
it 'renders a successful response' do
-
1
get new_bridge_soundness_url(@bridge)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'GET /edit' do
-
1
it 'render a successful response' do
-
1
soundness = Soundness.create! valid_attributes
-
1
get edit_bridge_soundness_url(@bridge, soundness)
-
1
expect(response).to be_successful
-
end
-
end
-
-
1
describe 'POST /create' do
-
1
context 'with valid parameters' do
-
1
it 'creates a new Soundness' do
-
1
expect do
-
1
post bridge_soundnesses_url(@bridge), params: { soundness: valid_attributes }
-
end.to change(Soundness, :count).by(1)
-
end
-
-
1
it 'redirects to the created soundness' do
-
1
post bridge_soundnesses_url(@bridge), params: { soundness: valid_attributes }
-
1
expect(response).to redirect_to(bridge_soundness_url(@bridge, Soundness.last))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it 'does not create a new Soundness' do
-
1
expect do
-
1
post bridge_soundnesses_url(@bridge), params: { soundness: invalid_attributes }
-
end.to change(Soundness, :count).by(0)
-
end
-
-
1
it "renders a successful response (i.e. to display the 'new' template)" do
-
1
post bridge_soundnesses_url(@bridge), params: { soundness: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'PATCH /update' do
-
1
context 'with valid parameters' do
-
1
let(:new_attributes) do
-
2
attributes = valid_attributes
-
2
attributes['evaluation'] = 'new text'
-
2
attributes
-
end
-
-
1
it 'updates the requested soundness' do
-
1
soundness = Soundness.create! valid_attributes
-
1
patch bridge_soundness_url(@bridge, soundness), params: { soundness: new_attributes }
-
1
soundness.reload
-
1
expect(soundness.evaluation).to eq('new text')
-
end
-
-
1
it 'redirects to the soundness' do
-
1
soundness = Soundness.create! valid_attributes
-
1
patch bridge_soundness_url(@bridge, soundness), params: { soundness: new_attributes }
-
1
soundness.reload
-
1
expect(response).to redirect_to(bridge_soundness_url(@bridge, soundness))
-
end
-
end
-
-
1
context 'with invalid parameters' do
-
1
it "renders a successful response (i.e. to display the 'edit' template)" do
-
1
soundness = Soundness.create! valid_attributes
-
1
patch bridge_soundness_url(@bridge, soundness), params: { soundness: invalid_attributes }
-
1
expect(response).to be_successful
-
end
-
end
-
end
-
-
1
describe 'DELETE /destroy' do
-
1
it 'destroys the requested soundness' do
-
1
soundness = Soundness.create! valid_attributes
-
1
expect do
-
1
delete bridge_soundness_url(@bridge, soundness)
-
end.to change(Soundness, :count).by(-1)
-
end
-
-
1
it 'redirects to the soundnesses list' do
-
1
soundness = Soundness.create! valid_attributes
-
1
delete bridge_soundness_url(@bridge, soundness)
-
1
expect(response).to redirect_to(bridge_soundnesses_url(@bridge))
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# This spec was generated by rspec-rails when you ran the scaffold generator.
-
# It demonstrates how one might use RSpec to test the controller code that
-
# was generated by Rails when you ran the scaffold generator.
-
#
-
# It assumes that the implementation code is generated by the rails scaffold
-
# generator. If you are using any extension libraries to generate different
-
# controller code, this generated spec may or may not pass.
-
#
-
# It only uses APIs available in rails and/or rspec-rails. There are a number
-
# of tools you can use to make these specs even more expressive, but we're
-
# sticking to rails and rspec-rails APIs to keep things simple and stable.
-
-
1
RSpec.describe '/status.json', type: :request do
-
1
before do
-
2
@bridge = FactoryBot.create(:bridge)
-
end
-
-
1
describe 'GET /status.json' do
-
1
it 'renders a successful response' do
-
1
get '/status.json'
-
1
expect(response).to be_successful
-
1
expect(response_body['bridge_count']).to eq(1)
-
1
expect(response_body['message']).to be_nil
-
end
-
-
1
it 'raise error, message is not null' do
-
1
allow(Bridge).to receive(:count).and_raise('some error')
-
1
get '/status.json'
-
1
expect(response).not_to be_successful
-
1
expect(response_body['bridge_count']).to eq(0)
-
1
expect(response_body['message']).to eq('some error')
-
end
-
end
-
-
1
def response_body
-
4
JSON.parse(response.body)
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'Tops', type: :request do
-
1
before do
-
2
@user = FactoryBot.create(:user)
-
2
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
-
end
-
1
describe 'GET /top/index' do
-
1
it 'enable to access' do
-
1
get top_index_path
-
1
expect(response).to have_http_status(200)
-
end
-
-
1
it 'fail without login' do
-
1
allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: '' })
-
1
get top_index_path
-
1
expect(response).to redirect_to sessions_index_path
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe Admin::UsersController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(get: '/admin/users').to route_to('admin/users#index')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(get: '/admin/users/new').to route_to('admin/users#new')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(get: '/admin/users/1').to route_to('admin/users#show', id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(get: '/admin/users/1/edit').to route_to('admin/users#edit', id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(post: '/admin/users').to route_to('admin/users#create')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(put: '/admin/users/1').to route_to('admin/users#update', id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(patch: '/admin/users/1').to route_to('admin/users#update', id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(delete: '/admin/users/1').to route_to('admin/users#destroy', id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe BridgeContentInjuriesController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(
-
get: '/regular_inspections/1/injuries/1/bridge_content_injuries'
-
).to route_to('bridge_content_injuries#index', regular_inspection_id: '1', injury_id: '1')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(
-
get: '/regular_inspections/1/injuries/1/bridge_content_injuries/new'
-
).to route_to('bridge_content_injuries#new', regular_inspection_id: '1', injury_id: '1')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(
-
get: '/regular_inspections/1/injuries/1/bridge_content_injuries/1'
-
).to route_to('bridge_content_injuries#show', regular_inspection_id: '1', injury_id: '1', id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(
-
get: '/regular_inspections/1/injuries/1/bridge_content_injuries/1/edit'
-
).to route_to('bridge_content_injuries#edit', regular_inspection_id: '1', injury_id: '1', id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(
-
post: '/regular_inspections/1/injuries/1/bridge_content_injuries'
-
).to route_to('bridge_content_injuries#create', regular_inspection_id: '1', injury_id: '1')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(
-
put: '/regular_inspections/1/injuries/1/bridge_content_injuries/1'
-
).to route_to('bridge_content_injuries#update', regular_inspection_id: '1', injury_id: '1', id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(
-
patch: '/regular_inspections/1/injuries/1/bridge_content_injuries/1'
-
).to route_to('bridge_content_injuries#update', regular_inspection_id: '1', injury_id: '1', id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(
-
delete: '/regular_inspections/1/injuries/1/bridge_content_injuries/1'
-
).to route_to('bridge_content_injuries#destroy', regular_inspection_id: '1', injury_id: '1', id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe BridgeContentsController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(
-
get: '/regular_inspections/1/bridge_contents'
-
).to route_to('bridge_contents#index', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(
-
get: '/regular_inspections/1/bridge_contents/new'
-
).to route_to('bridge_contents#new', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(
-
get: '/regular_inspections/1/bridge_contents/1'
-
).to route_to('bridge_contents#show', regular_inspection_id: '1', id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(
-
get: '/regular_inspections/1/bridge_contents/1/edit'
-
).to route_to('bridge_contents#edit', regular_inspection_id: '1', id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(
-
post: '/regular_inspections/1/bridge_contents'
-
).to route_to('bridge_contents#create', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(
-
put: '/regular_inspections/1/bridge_contents/1'
-
).to route_to('bridge_contents#update', regular_inspection_id: '1', id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(
-
patch: '/regular_inspections/1/bridge_contents/1'
-
).to route_to('bridge_contents#update', regular_inspection_id: '1', id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(
-
delete: '/regular_inspections/1/bridge_contents/1'
-
).to route_to('bridge_contents#destroy', regular_inspection_id: '1', id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe BridgeMainContentsController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #create' do
-
1
expect(
-
post: '/regular_inspections/1/bridge_main_contents'
-
).to route_to('bridge_main_contents#create', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(
-
delete: '/regular_inspections/1/bridge_main_contents/1'
-
).to route_to('bridge_main_contents#destroy', regular_inspection_id: '1', id: '1')
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe BridgesController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(get: '/bridges').to route_to('bridges#index')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(get: '/bridges/new').to route_to('bridges#new')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(get: '/bridges/1').to route_to('bridges#show', id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(get: '/bridges/1/edit').to route_to('bridges#edit', id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(post: '/bridges').to route_to('bridges#create')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(put: '/bridges/1').to route_to('bridges#update', id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(patch: '/bridges/1').to route_to('bridges#update', id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(delete: '/bridges/1').to route_to('bridges#destroy', id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe ComponentsController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(get: '/bridges/1/components').to route_to('components#index', bridge_id: '1')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(get: '/bridges/1/components/new').to route_to('components#new', bridge_id: '1')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(get: '/bridges/1/components/1').to route_to('components#show', bridge_id: '1', id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(get: '/bridges/1/components/1/edit').to route_to('components#edit', bridge_id: '1', id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(post: '/bridges/1/components').to route_to('components#create', bridge_id: '1')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(put: '/bridges/1/components/1').to route_to('components#update', bridge_id: '1', id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(patch: '/bridges/1/components/1').to route_to('components#update', bridge_id: '1', id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(delete: '/bridges/1/components/1').to route_to('components#destroy', bridge_id: '1', id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe DiagnosesController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(get: '/regular_inspections/1/diagnoses').to route_to('diagnoses#index', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(get: '/regular_inspections/1/diagnoses/new').to route_to('diagnoses#new', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(get: '/regular_inspections/1/diagnoses/1').to route_to('diagnoses#show',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(get: '/regular_inspections/1/diagnoses/1/edit').to route_to('diagnoses#edit',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(post: '/regular_inspections/1/diagnoses').to route_to('diagnoses#create', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(put: '/regular_inspections/1/diagnoses/1').to route_to('diagnoses#update',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(patch: '/regular_inspections/1/diagnoses/1').to route_to('diagnoses#update',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(delete: '/regular_inspections/1/diagnoses/1').to route_to('diagnoses#destroy',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe InjuriesController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(get: '/regular_inspections/1/injuries').to route_to('injuries#index', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(get: '/regular_inspections/1/injuries/new').to route_to('injuries#new', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(get: '/regular_inspections/1/injuries/1').to route_to('injuries#show', regular_inspection_id: '1', id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(get: '/regular_inspections/1/injuries/1/edit').to route_to('injuries#edit',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(post: '/regular_inspections/1/injuries').to route_to('injuries#create', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(put: '/regular_inspections/1/injuries/1').to route_to('injuries#update',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(patch: '/regular_inspections/1/injuries/1').to route_to('injuries#update',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(delete: '/regular_inspections/1/injuries/1').to route_to('injuries#destroy',
-
regular_inspection_id: '1',
-
id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe RegularInspectionsController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(get: '/regular_inspections').to route_to('regular_inspections#index')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(get: '/regular_inspections/new').to route_to('regular_inspections#new')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(get: '/regular_inspections/1').to route_to('regular_inspections#show', id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(get: '/regular_inspections/1/edit').to route_to('regular_inspections#edit', id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(post: '/regular_inspections').to route_to('regular_inspections#create')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(put: '/regular_inspections/1').to route_to('regular_inspections#update', id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(patch: '/regular_inspections/1').to route_to('regular_inspections#update', id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(delete: '/regular_inspections/1').to route_to('regular_inspections#destroy', id: '1')
-
end
-
-
1
it 'routes to #download_image_metadata' do
-
1
expect(
-
get: '/regular_inspections/1/download_image_metadata'
-
).to route_to('regular_inspections#download_image_metadata', regular_inspection_id: '1')
-
end
-
-
1
it 'routes to #download_pointcloud_metadata' do
-
1
expect(
-
get: '/regular_inspections/1/download_pointcloud_metadata'
-
).to route_to('regular_inspections#download_pointcloud_metadata', regular_inspection_id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
# rubocop:disable Metrics/BlockLength
-
1
RSpec.describe SoundnessesController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(get: '/bridges/1/soundnesses').to route_to('soundnesses#index', bridge_id: '1')
-
end
-
-
1
it 'routes to #new' do
-
1
expect(get: '/bridges/1/soundnesses/new').to route_to('soundnesses#new', bridge_id: '1')
-
end
-
-
1
it 'routes to #show' do
-
1
expect(get: '/bridges/1/soundnesses/1').to route_to('soundnesses#show', bridge_id: '1', id: '1')
-
end
-
-
1
it 'routes to #edit' do
-
1
expect(get: '/bridges/1/soundnesses/1/edit').to route_to('soundnesses#edit', bridge_id: '1', id: '1')
-
end
-
-
1
it 'routes to #create' do
-
1
expect(post: '/bridges/1/soundnesses').to route_to('soundnesses#create', bridge_id: '1')
-
end
-
-
1
it 'routes to #update via PUT' do
-
1
expect(put: '/bridges/1/soundnesses/1').to route_to('soundnesses#update', bridge_id: '1', id: '1')
-
end
-
-
1
it 'routes to #update via PATCH' do
-
1
expect(patch: '/bridges/1/soundnesses/1').to route_to('soundnesses#update', bridge_id: '1', id: '1')
-
end
-
-
1
it 'routes to #destroy' do
-
1
expect(delete: '/bridges/1/soundnesses/1').to route_to('soundnesses#destroy', bridge_id: '1', id: '1')
-
end
-
end
-
end
-
# rubocop:enable Metrics/BlockLength
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe StatusController, type: :routing do
-
1
describe 'routing' do
-
1
it 'routes to #index' do
-
1
expect(get: '/status.json').to route_to('status#index', format: 'json')
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'admin/users/edit', type: :view do
-
1
before(:each) do
-
1
@user = assign(:user, FactoryBot.create(:user))
-
end
-
-
1
it 'renders the edit user form' do
-
1
render
-
1
assert_select 'form[action=?][method=?]', admin_user_path(@user), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'admin/users/index', type: :view do
-
1
before(:each) do
-
1
assign(:users, [
-
FactoryBot.create(:user),
-
FactoryBot.create(:user)
-
])
-
end
-
-
1
it 'renders a list of admin/users' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'admin/users/new', type: :view do
-
1
before(:each) do
-
1
assign(:user, User.new)
-
end
-
-
1
it 'renders new user form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', admin_users_path, 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'admin/users/show', type: :view do
-
1
before(:each) do
-
1
@user = assign(:user, FactoryBot.create(:user))
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridge_content_injuries/edit', type: :view do
-
1
before(:each) do
-
1
@regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
-
1
@bridge_content = FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection)
-
1
@injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: @regular_inspection))
-
1
@bridge_content_injury = assign(:bridge_content_injury,
-
FactoryBot.create(:bridge_content_injury,
-
bridge_content: @bridge_content,
-
injury: @injury))
-
end
-
-
1
it 'renders the edit bridge_content_injury form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]',
-
regular_inspection_injury_bridge_content_injury_path(@regular_inspection,
-
@injury,
-
@bridge_content_injury), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridge_content_injuries/index', type: :view do
-
1
before(:each) do
-
1
regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
-
1
bridge_content1 = FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
-
1
bridge_content2 = FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
-
1
injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: regular_inspection))
-
1
assign(:bridge_content_injuries, [
-
FactoryBot.create(:bridge_content_injury, bridge_content: bridge_content1, injury: injury),
-
FactoryBot.create(:bridge_content_injury, bridge_content: bridge_content2, injury: injury)
-
])
-
end
-
-
1
it 'renders a list of bridge_content_injuries' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridge_content_injuries/new', type: :view do
-
1
before(:each) do
-
1
@regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
-
1
@injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: @regular_inspection))
-
1
assign(:bridge_content_injury, BridgeContentInjury.new(injury: @injury))
-
end
-
-
1
it 'renders new bridge_content_injury form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]',
-
regular_inspection_injury_bridge_content_injuries_path(@regular_inspection, @injury),
-
'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridge_content_injuries/show', type: :view do
-
1
before(:each) do
-
1
regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
-
1
bridge_content = FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
-
1
injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: regular_inspection))
-
1
assign(:bridge_content_injury,
-
FactoryBot.create(:bridge_content_injury, bridge_content: bridge_content, injury: injury))
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridge_contents/edit', type: :view do
-
1
before(:each) do
-
1
assign(:components, [])
-
1
@regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
-
1
@bridge_content = assign(:bridge_content,
-
FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection))
-
end
-
-
1
it 'renders the edit bridge_content form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]',
-
regular_inspection_bridge_content_path(@regular_inspection, @bridge_content), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridge_contents/index', type: :view do
-
1
before(:each) do
-
1
regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
-
1
assign(:bridge_contents, [
-
FactoryBot.create(:bridge_content, regular_inspection: regular_inspection),
-
FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
-
])
-
end
-
-
1
it 'renders a list of bridge_contents' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridge_contents/new', type: :view do
-
1
before(:each) do
-
1
assign(:components, [])
-
1
@regular_inspection = FactoryBot.create(:regular_inspection)
-
1
assign(:regular_inspection, @regular_inspection)
-
1
assign(:bridge_content, BridgeContent.new(regular_inspection: @regular_inspection))
-
end
-
-
1
it 'renders new bridge_content form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', regular_inspection_bridge_contents_path(@regular_inspection), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridge_contents/show', type: :view do
-
1
before(:each) do
-
1
regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
-
1
assign(:bridge_content, FactoryBot.create(:bridge_content, regular_inspection: regular_inspection))
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridges/edit', type: :view do
-
1
before(:each) do
-
1
@bridge = FactoryBot.create(:bridge)
-
end
-
-
1
it 'renders the edit bridge form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', bridge_path(@bridge), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridges/index', type: :view do
-
1
before(:each) do
-
1
assign(:bridges, [
-
FactoryBot.create(:bridge),
-
FactoryBot.create(:bridge)
-
])
-
end
-
-
1
it 'renders a list of bridges' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridges/new', type: :view do
-
1
before(:each) do
-
1
bridge = Bridge.new
-
1
bridge.location = 'POINT(140.084556 36.104611)'
-
1
assign(:bridge, bridge)
-
end
-
-
1
it 'renders new bridge form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', bridges_path, 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'bridges/show', type: :view do
-
1
before(:each) do
-
1
@bridge = FactoryBot.create(:bridge)
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'components/edit', type: :view do
-
1
before(:each) do
-
1
@bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
@component = assign(:component, FactoryBot.create(:component, bridge: @bridge))
-
end
-
-
1
it 'renders the edit component form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', bridge_component_path(@bridge, @component), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'components/index', type: :view do
-
1
before(:each) do
-
1
bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
assign(:components, [
-
FactoryBot.create(:component, bridge: bridge),
-
FactoryBot.create(:component, bridge: bridge)
-
])
-
end
-
-
1
it 'renders a list of components' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'components/new', type: :view do
-
1
before(:each) do
-
1
@bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
assign(:component, Component.new(bridge: @bridge))
-
end
-
-
1
it 'renders new component form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', bridge_components_path(@bridge), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'components/show', type: :view do
-
1
before(:each) do
-
1
bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
@component = assign(:component, FactoryBot.create(:component, bridge: bridge))
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'diagnoses/edit', type: :view do
-
1
before(:each) do
-
1
@regular_inspection = FactoryBot.create(:regular_inspection)
-
1
assign(:regular_inspection, @regular_inspection)
-
1
@diagnosis = assign(:diagnosis, FactoryBot.create(:diagnosis, regular_inspection: @regular_inspection))
-
end
-
-
1
it 'renders the edit diagnosis form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]',
-
regular_inspection_diagnosis_path(@regular_inspection, @diagnosis),
-
'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'diagnoses/index', type: :view do
-
1
before(:each) do
-
1
regular_inspection = FactoryBot.create(:regular_inspection)
-
1
assign(:regular_inspection, regular_inspection)
-
1
assign(:diagnoses, [
-
FactoryBot.create(:diagnosis, regular_inspection: regular_inspection),
-
FactoryBot.create(:diagnosis,
-
regular_inspection: regular_inspection,
-
component_category: Component.categories[:superstructure_horizontal_grider])
-
])
-
end
-
-
1
it 'renders a list of diagnoses' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'diagnoses/new', type: :view do
-
1
before(:each) do
-
1
@regular_inspection = FactoryBot.create(:regular_inspection)
-
1
assign(:regular_inspection, @regular_inspection)
-
1
assign(:diagnosis, Diagnosis.new)
-
end
-
-
1
it 'renders new diagnosis form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', regular_inspection_diagnoses_path(@regular_inspection), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'diagnoses/show', type: :view do
-
1
before(:each) do
-
1
bridge = FactoryBot.create(:bridge)
-
1
regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
-
1
component = FactoryBot.create(:component, bridge: bridge)
-
1
injury = FactoryBot.create(:injury, regular_inspection: regular_inspection, component: component)
-
1
assign(:regular_inspection, regular_inspection)
-
1
@diagnosis = assign(:diagnosis, FactoryBot.create(:diagnosis,
-
regular_inspection: regular_inspection,
-
injury: injury))
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'injuries/edit', type: :view do
-
1
before(:each) do
-
1
bridge = FactoryBot.create(:bridge)
-
1
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
-
1
assign(:components, [])
-
1
assign(:regular_inspection, @regular_inspection)
-
1
assign(:injury, Injury.new(regular_inspection: @regular_inspection))
-
end
-
-
1
it 'renders the edit injury form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', regular_inspection_injuries_path(@regular_inspection), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'injuries/index', type: :view do
-
1
before(:each) do
-
1
bridge = FactoryBot.create(:bridge)
-
1
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
-
1
component1 = FactoryBot.create(:component, bridge: bridge)
-
1
component2 = FactoryBot.create(:component, bridge: bridge)
-
1
assign(:injuries, [
-
FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: component1),
-
FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: component2)
-
])
-
end
-
-
1
it 'renders a list of injuries' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'injuries/new', type: :view do
-
1
before(:each) do
-
1
bridge = FactoryBot.create(:bridge)
-
1
@regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
-
1
assign(:components, [])
-
1
assign(:regular_inspection, @regular_inspection)
-
1
assign(:injury, Injury.new(regular_inspection: @regular_inspection))
-
end
-
-
1
it 'renders new injury form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', regular_inspection_injuries_path(@regular_inspection), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'injuries/show', type: :view do
-
1
before(:each) do
-
1
bridge = FactoryBot.create(:bridge)
-
1
regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
-
1
component = FactoryBot.create(:component, bridge: bridge)
-
1
assign(:regular_inspection, regular_inspection)
-
1
@injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: regular_inspection, component: component))
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'mlit_importers/create.html.slim', type: :view do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'mlit_importers/new.html.slim', type: :view do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'mlit_importers/preview.html.slim', type: :view do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'regular_inspections/edit', type: :view do
-
1
before(:each) do
-
1
bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
@regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection, bridge: bridge))
-
end
-
-
1
it 'renders the edit regular_inspection form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', regular_inspection_path(@regular_inspection), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'regular_inspections/index', type: :view do
-
1
before(:each) do
-
1
bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
assign(:regular_inspections, [
-
FactoryBot.create(:regular_inspection, bridge: bridge),
-
FactoryBot.create(:regular_inspection, bridge: bridge)
-
])
-
end
-
-
1
it 'renders a list of regular_inspections' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'regular_inspections/new', type: :view do
-
1
before(:each) do
-
1
assign(:regular_inspection, RegularInspection.new)
-
end
-
-
1
it 'renders new regular_inspection form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', regular_inspections_path, 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'regular_inspections/show', type: :view do
-
1
before(:each) do
-
1
bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
@regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection, bridge: bridge))
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'soundnesses/edit', type: :view do
-
1
before(:each) do
-
1
@bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
@soundness = assign(:soundness, FactoryBot.create(:soundness, bridge: @bridge))
-
end
-
-
1
it 'renders the edit soundness form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', bridge_soundness_path(@bridge, @soundness), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'soundnesses/index', type: :view do
-
1
before(:each) do
-
1
bridge = FactoryBot.create(:bridge)
-
1
assign(:bridge, bridge)
-
1
assign(:soundnesses, [
-
FactoryBot.create(:soundness, bridge: bridge),
-
FactoryBot.create(:soundness, bridge: bridge)
-
])
-
end
-
-
1
it 'renders a list of soundnesses' do
-
1
render
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'soundnesses/new', type: :view do
-
1
before(:each) do
-
1
@bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
assign(:soundness, Soundness.new)
-
end
-
-
1
it 'renders new soundness form' do
-
1
render
-
-
1
assert_select 'form[action=?][method=?]', bridge_soundnesses_path(@bridge), 'post' do
-
end
-
end
-
end
-
# frozen_string_literal: true
-
-
1
require 'rails_helper'
-
-
1
RSpec.describe 'soundnesses/show', type: :view do
-
1
before(:each) do
-
1
@bridge = assign(:bridge, FactoryBot.create(:bridge))
-
1
@soundness = assign(:soundness, FactoryBot.create(:soundness, bridge: @bridge))
-
end
-
-
1
it 'renders attributes in <p>' do
-
1
render
-
end
-
end