loading
Generated 2021-03-11T08:35:07+00:00

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% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/controllers/admin/base_controller.rb 100.00 % 10 5 5 0 1.00
app/controllers/admin/sessions_controller.rb 100.00 % 43 24 24 0 1.08
app/controllers/admin/top_controller.rb 100.00 % 8 3 3 0 1.00
app/controllers/admin/users_controller.rb 100.00 % 84 36 36 0 2.17
app/controllers/application_controller.rb 100.00 % 5 1 1 0 1.00
app/controllers/bridge_content_injuries_controller.rb 100.00 % 104 43 43 0 2.58
app/controllers/bridge_contents_controller.rb 100.00 % 108 41 41 0 2.66
app/controllers/bridge_main_contents_controller.rb 100.00 % 57 25 25 0 2.20
app/controllers/bridges_controller.rb 100.00 % 92 37 37 0 2.11
app/controllers/components_controller.rb 100.00 % 91 40 40 0 2.40
app/controllers/concerns/admin_session_action.rb 100.00 % 23 9 9 0 7.00
app/controllers/concerns/user_session_action.rb 100.00 % 23 9 9 0 54.11
app/controllers/diagnoses_controller.rb 100.00 % 92 40 40 0 2.40
app/controllers/injuries_controller.rb 100.00 % 97 44 44 0 2.30
app/controllers/mlit_importers_controller.rb 100.00 % 38 18 18 0 2.17
app/controllers/regular_inspections_controller.rb 100.00 % 113 42 42 0 1.98
app/controllers/soundnesses_controller.rb 100.00 % 91 40 40 0 2.40
app/controllers/status_controller.rb 100.00 % 18 7 7 0 1.29
app/controllers/top_controller.rb 100.00 % 13 8 8 0 1.00
app/controllers/user_base_controller.rb 100.00 % 8 4 4 0 1.00
app/helpers/application_helper.rb 100.00 % 5 1 1 0 1.00
app/jobs/application_job.rb 100.00 % 10 1 1 0 1.00
app/jobs/game_tile_job.rb 100.00 % 29 17 17 0 2.41
app/models/admin_user.rb 100.00 % 19 7 7 0 1.00
app/models/application_record.rb 100.00 % 6 2 2 0 1.00
app/models/bridge.rb 100.00 % 81 35 35 0 1.46
app/models/bridge_content.rb 97.83 % 166 92 90 2 4.11
app/models/bridge_content_injury.rb 100.00 % 18 9 9 0 1.00
app/models/bridge_main_content.rb 100.00 % 6 2 2 0 1.00
app/models/component.rb 100.00 % 25 8 8 0 2.13
app/models/concerns/location_implement.rb 100.00 % 23 14 14 0 5.57
app/models/concerns/user_implement.rb 100.00 % 12 5 5 0 153.60
app/models/dashboard.rb 98.51 % 104 67 66 1 6.69
app/models/diagnosis.rb 100.00 % 33 15 15 0 5.60
app/models/game_tile.rb 100.00 % 95 64 64 0 9.23
app/models/injury.rb 100.00 % 36 14 14 0 1.21
app/models/mlit_importer.rb 100.00 % 35 23 23 0 5.87
app/models/regular_inspection.rb 100.00 % 25 14 14 0 1.00
app/models/soundness.rb 100.00 % 17 5 5 0 1.00
app/models/user.rb 100.00 % 20 7 7 0 1.00
app/validators/bridge_content_injury_same_origin_validator.rb 100.00 % 12 5 5 0 10.40
app/validators/same_component_category_validator.rb 100.00 % 12 5 5 0 10.80
config/application.rb 100.00 % 50 23 23 0 1.70
config/boot.rb 100.00 % 6 3 3 0 1.00
config/environment.rb 100.00 % 7 2 2 0 1.00
config/environments/test.rb 100.00 % 51 15 15 0 1.00
config/initializers/application_controller_renderer.rb 100.00 % 10 0 0 0 0.00
config/initializers/assets.rb 100.00 % 16 2 2 0 1.00
config/initializers/backtrace_silencers.rb 100.00 % 9 0 0 0 0.00
config/initializers/content_security_policy.rb 100.00 % 32 0 0 0 0.00
config/initializers/cookies_serializer.rb 100.00 % 7 1 1 0 1.00
config/initializers/filter_parameter_logging.rb 100.00 % 6 1 1 0 1.00
config/initializers/inflections.rb 100.00 % 18 0 0 0 0.00
config/initializers/mime_types.rb 100.00 % 6 0 0 0 0.00
config/initializers/wrap_parameters.rb 100.00 % 16 2 2 0 1.50
config/routes.rb 100.00 % 45 28 28 0 1.00
spec/factories/admin_users.rb 100.00 % 8 4 4 0 17.75
spec/factories/bridge_content_injuries.rb 100.00 % 9 5 5 0 5.80
spec/factories/bridge_contents.rb 100.00 % 13 7 7 0 29.14
spec/factories/bridge_main_contents.rb 100.00 % 7 3 3 0 1.00
spec/factories/bridges.rb 100.00 % 11 7 7 0 192.43
spec/factories/components.rb 100.00 % 10 6 6 0 45.33
spec/factories/diagnoses.rb 100.00 % 11 7 7 0 16.29
spec/factories/injuries.rb 100.00 % 10 6 6 0 23.00
spec/factories/regular_inspections.rb 100.00 % 14 9 9 0 100.11
spec/factories/soundnesses.rb 100.00 % 11 6 6 0 17.17
spec/factories/users.rb 100.00 % 8 4 4 0 71.75
spec/helpers/application_helper_spec.rb 100.00 % 16 2 2 0 1.00
spec/jobs/game_tile_job_spec.rb 100.00 % 25 14 14 0 1.14
spec/models/admin_user_spec.rb 100.00 % 90 52 52 0 2.17
spec/models/bridge_content_injury_spec.rb 100.00 % 27 16 16 0 2.63
spec/models/bridge_content_spec.rb 100.00 % 81 49 49 0 1.63
spec/models/bridge_main_content_spec.rb 100.00 % 14 7 7 0 1.71
spec/models/bridge_spec.rb 100.00 % 53 32 32 0 2.34
spec/models/component_spec.rb 100.00 % 24 14 14 0 2.64
spec/models/concern/location_implement_spec.rb 100.00 % 17 8 8 0 1.00
spec/models/dashboard_spec.rb 100.00 % 72 46 46 0 1.87
spec/models/diagnosis_spec.rb 100.00 % 60 37 37 0 2.51
spec/models/game_tile_spec.rb 100.00 % 28 19 19 0 1.00
spec/models/injury_spec.rb 100.00 % 31 19 19 0 3.11
spec/models/mlit_importer_spec.rb 100.00 % 31 21 21 0 1.00
spec/models/regular_inspection_spec.rb 100.00 % 31 19 19 0 2.89
spec/models/soundness_spec.rb 100.00 % 48 28 28 0 1.96
spec/models/user_spec.rb 100.00 % 90 52 52 0 2.17
spec/requests/admin/sessions_request_spec.rb 100.00 % 47 21 21 0 1.05
spec/requests/admin/top_request_spec.rb 100.00 % 22 13 13 0 1.15
spec/requests/admin/users_spec.rb 100.00 % 148 72 72 0 1.50
spec/requests/bridge_content_injuries_spec.rb 100.00 % 174 82 82 0 2.26
spec/requests/bridge_contents_spec.rb 100.00 % 149 78 78 0 1.92
spec/requests/bridge_main_contents_request_spec.rb 100.00 % 75 38 38 0 1.82
spec/requests/bridges_spec.rb 100.00 % 154 87 87 0 1.84
spec/requests/components_spec.rb 100.00 % 143 76 76 0 1.71
spec/requests/diagnoses_spec.rb 100.00 % 148 80 80 0 2.15
spec/requests/injuries_spec.rb 100.00 % 147 80 80 0 1.99
spec/requests/mlit_importers_spec.rb 100.00 % 77 41 41 0 1.39
spec/requests/regular_inspections_spec.rb 100.00 % 156 84 84 0 1.71
spec/requests/sessions_request_spec.rb 100.00 % 6 2 2 0 1.00
spec/requests/soundnesses_spec.rb 100.00 % 142 76 76 0 1.71
spec/requests/status_request_spec.rb 100.00 % 42 18 18 0 1.22
spec/requests/top_request_spec.rb 100.00 % 22 13 13 0 1.15
spec/routing/admin/users_routing_spec.rb 100.00 % 41 19 19 0 1.00
spec/routing/bridge_content_injuries_routing_spec.rb 100.00 % 57 19 19 0 1.00
spec/routing/bridge_contents_routing_spec.rb 100.00 % 57 19 19 0 1.00
spec/routing/bridge_main_contents_routing_spec.rb 100.00 % 19 7 7 0 1.00
spec/routing/bridges_routing_spec.rb 100.00 % 41 19 19 0 1.00
spec/routing/components_routing_spec.rb 100.00 % 41 19 19 0 1.00
spec/routing/diagnoses_routing_spec.rb 100.00 % 51 19 19 0 1.00
spec/routing/injuries_routing_spec.rb 100.00 % 49 19 19 0 1.00
spec/routing/regular_inspections_routing_spec.rb 100.00 % 53 23 23 0 1.00
spec/routing/soundnesses_routing_spec.rb 100.00 % 41 19 19 0 1.00
spec/routing/status_routing_spec.rb 100.00 % 11 5 5 0 1.00
spec/views/admin/users/edit.html.slim_spec.rb 100.00 % 15 7 7 0 1.00
spec/views/admin/users/index.html.slim_spec.rb 100.00 % 16 6 6 0 1.00
spec/views/admin/users/new.html.slim_spec.rb 100.00 % 16 7 7 0 1.00
spec/views/admin/users/show.html.slim_spec.rb 100.00 % 13 6 6 0 1.00
spec/views/bridge_content_injuries/edit.html.slim_spec.rb 100.00 % 25 10 10 0 1.00
spec/views/bridge_content_injuries/index.html.slim_spec.rb 100.00 % 20 10 10 0 1.00
spec/views/bridge_content_injuries/new.html.slim_spec.rb 100.00 % 20 9 9 0 1.00
spec/views/bridge_content_injuries/show.html.slim_spec.rb 100.00 % 17 9 9 0 1.00
spec/views/bridge_contents/edit.html.slim_spec.rb 100.00 % 20 9 9 0 1.00
spec/views/bridge_contents/index.html.slim_spec.rb 100.00 % 17 7 7 0 1.00
spec/views/bridge_contents/new.html.slim_spec.rb 100.00 % 19 10 10 0 1.00
spec/views/bridge_contents/show.html.slim_spec.rb 100.00 % 14 7 7 0 1.00
spec/views/bridges/edit.html.slim_spec.rb 100.00 % 16 7 7 0 1.00
spec/views/bridges/index.html.slim_spec.rb 100.00 % 16 6 6 0 1.00
spec/views/bridges/new.html.slim_spec.rb 100.00 % 18 9 9 0 1.00
spec/views/bridges/show.html.slim_spec.rb 100.00 % 13 6 6 0 1.00
spec/views/components/edit.html.slim_spec.rb 100.00 % 17 8 8 0 1.00
spec/views/components/index.html.slim_spec.rb 100.00 % 17 7 7 0 1.00
spec/views/components/new.html.slim_spec.rb 100.00 % 17 8 8 0 1.00
spec/views/components/show.html.slim_spec.rb 100.00 % 14 7 7 0 1.00
spec/views/diagnoses/edit.html.slim_spec.rb 100.00 % 20 9 9 0 1.00
spec/views/diagnoses/index.html.slim_spec.rb 100.00 % 20 8 8 0 1.00
spec/views/diagnoses/new.html.slim_spec.rb 100.00 % 18 9 9 0 1.00
spec/views/diagnoses/show.html.slim_spec.rb 100.00 % 20 11 11 0 1.00
spec/views/injuries/edit.html.slim_spec.rb 100.00 % 20 11 11 0 1.00
spec/views/injuries/index.html.slim_spec.rb 100.00 % 20 10 10 0 1.00
spec/views/injuries/new.html.slim_spec.rb 100.00 % 20 11 11 0 1.00
spec/views/injuries/show.html.slim_spec.rb 100.00 % 17 10 10 0 1.00
spec/views/mlit_importers/create.html.slim_spec.rb 100.00 % 7 3 3 0 1.00
spec/views/mlit_importers/new.html.slim_spec.rb 100.00 % 7 3 3 0 1.00
spec/views/mlit_importers/preview.html.slim_spec.rb 100.00 % 7 3 3 0 1.00
spec/views/regular_inspections/edit.html.slim_spec.rb 100.00 % 17 8 8 0 1.00
spec/views/regular_inspections/index.html.slim_spec.rb 100.00 % 17 7 7 0 1.00
spec/views/regular_inspections/new.html.slim_spec.rb 100.00 % 16 7 7 0 1.00
spec/views/regular_inspections/show.html.slim_spec.rb 100.00 % 14 7 7 0 1.00
spec/views/soundnesses/edit.html.slim_spec.rb 100.00 % 17 8 8 0 1.00
spec/views/soundnesses/index.html.slim_spec.rb 100.00 % 18 8 8 0 1.00
spec/views/soundnesses/new.html.slim_spec.rb 100.00 % 17 8 8 0 1.00
spec/views/soundnesses/show.html.slim_spec.rb 100.00 % 14 7 7 0 1.00

app/controllers/admin/base_controller.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module Admin
  3. # Admin Base Controller
  4. 1 class BaseController < ApplicationController
  5. 1 include AdminSessionAction
  6. 1 layout 'admin'
  7. 1 before_action :let_admin_user_login
  8. end
  9. end

app/controllers/admin/sessions_controller.rb

100.0% lines covered

24 relevant lines. 24 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module Admin
  3. # Admin Sessions Controller
  4. 1 class SessionsController < Admin::BaseController
  5. 1 before_action :let_admin_user_login, only: %i[]
  6. 1 def index
  7. 1 @admin_user = AdminUser.new
  8. end
  9. 1 def login
  10. 2 user = AdminUser.find_by(login_name: params[:admin_user][:login_name])
  11. 2 if user&.authenticate(params[:admin_user][:password])
  12. 1 login_action(user)
  13. else
  14. 1 login_fail_action
  15. end
  16. end
  17. 1 def logout
  18. 1 reset_session
  19. 1 redirect_to({ action: :index }, { notice: t('controller.common.logout') })
  20. end
  21. 1 private
  22. 1 def login_params
  23. 1 params.require(:admin_user).permit(:login_name, :password)
  24. end
  25. 1 def login_action(user)
  26. 1 reset_session
  27. 1 session[:admin_user_id] = user.id
  28. 1 redirect_to action: :index, controller: :top
  29. end
  30. 1 def login_fail_action
  31. 1 flash.now[:error] = t('controller.common.not_authenticated')
  32. 1 @admin_user = AdminUser.new login_params
  33. 1 render :index
  34. end
  35. end
  36. end

app/controllers/admin/top_controller.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module Admin
  3. # Admin Top Controller
  4. 1 class TopController < Admin::BaseController
  5. 1 def index; end
  6. end
  7. end

app/controllers/admin/users_controller.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 module Admin
  3. # Admin Users Controller
  4. 1 class UsersController < Admin::BaseController
  5. 1 before_action :set_user, only: %i[show edit update destroy]
  6. # GET /admin/users
  7. # GET /admin/users.json
  8. 1 def index
  9. 1 @users = User.all
  10. end
  11. # GET /admin/users/1
  12. # GET /admin/users/1.json
  13. 1 def show; end
  14. # GET /admin/users/new
  15. 1 def new
  16. 1 @user = User.new
  17. end
  18. # GET /admin/users/1/edit
  19. 1 def edit; end
  20. # POST /admin/users
  21. # POST /admin/users.json
  22. 1 def create
  23. 4 @user = User.new(user_params)
  24. 4 respond_to do |format|
  25. 4 if @user.save
  26. 2 format.html do
  27. 2 redirect_to [:admin, @user],
  28. notice: I18n.t('controller.common.success_on_create', model_name: User.model_name.human)
  29. end
  30. 2 format.json { render :show, status: :created, location: @user }
  31. else
  32. 4 format.html { render :new }
  33. 2 format.json { render json: @user.errors, status: :unprocessable_entity }
  34. end
  35. end
  36. end
  37. # PATCH/PUT /admin/users/1
  38. # PATCH/PUT /admin/users/1.json
  39. 1 def update
  40. 3 respond_to do |format|
  41. 3 if @user.update(user_params)
  42. 2 format.html do
  43. 2 redirect_to [:admin, @user],
  44. notice: I18n.t('controller.common.success_on_update', model_name: User.model_name.human)
  45. end
  46. 2 format.json { render :show, status: :ok, location: @user }
  47. else
  48. 2 format.html { render :edit }
  49. 1 format.json { render json: @user.errors, status: :unprocessable_entity }
  50. end
  51. end
  52. end
  53. # DELETE /admin/users/1
  54. # DELETE /admin/users/1.json
  55. 1 def destroy
  56. 2 @user.destroy
  57. 2 respond_to do |format|
  58. 4 format.html { redirect_to admin_users_url, notice: 'User was successfully destroyed.' }
  59. 2 format.json { head :no_content }
  60. end
  61. end
  62. 1 private
  63. # Use callbacks to share common setup or constraints between actions.
  64. 1 def set_user
  65. 7 @user = User.find(params[:id])
  66. end
  67. # Only allow a list of trusted parameters through.
  68. 1 def user_params
  69. 7 params.fetch(:user, {}).permit(:login_name, :password)
  70. end
  71. end
  72. end

app/controllers/application_controller.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # ApplicationController
  3. 1 class ApplicationController < ActionController::Base
  4. end

app/controllers/bridge_content_injuries_controller.rb

100.0% lines covered

43 relevant lines. 43 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # BridgeContentInjuriesController
  3. 1 class BridgeContentInjuriesController < UserBaseController
  4. 1 before_action :set_regular_inspection
  5. 1 before_action :set_injury
  6. 1 before_action :set_bridge_content_injury, only: %i[show edit update destroy]
  7. # GET /regular_inspections/1/injuries/1/bridge_content_injuries
  8. # GET /regular_inspections/1/injuries/1/bridge_content_injuries.json
  9. 1 def index
  10. 1 @bridge_content_injuries = BridgeContentInjury.where(injury: @injury).all
  11. end
  12. # GET /regular_inspections/1/injuries/1/bridge_content_injuries/1
  13. # GET /regular_inspections/1/injuries/1/bridge_content_injuries/1.json
  14. 1 def show; end
  15. # GET /regular_inspections/1/injuries/1/bridge_content_injuries/new
  16. 1 def new
  17. 1 @bridge_content_injury = BridgeContentInjury.new(injury: @injury)
  18. end
  19. # GET /regular_inspections/1/injuries/1/bridge_content_injuries/1/edit
  20. 1 def edit; end
  21. # POST /regular_inspections/1/injuries/1/bridge_content_injuries
  22. # POST /regular_inspections/1/injuries/1/bridge_content_injuries.json
  23. 1 def create
  24. 4 @bridge_content_injury = BridgeContentInjury.new(bridge_content_injury_params)
  25. 4 @bridge_content_injury.injury = @injury
  26. 4 respond_to do |format|
  27. 4 if @bridge_content_injury.save
  28. 2 format.html do
  29. 2 redirect_to [@regular_inspection, @injury, @bridge_content_injury],
  30. notice: I18n.t('controller.common.success_on_create',
  31. model_name: BridgeContentInjury.model_name.human)
  32. end
  33. 2 format.json { render :show, status: :created, location: @bridge_content_injury }
  34. else
  35. 4 format.html { render :new }
  36. 2 format.json { render json: @bridge_content_injury.errors, status: :unprocessable_entity }
  37. end
  38. end
  39. end
  40. # PATCH/PUT /regular_inspections/1/injuries/1/bridge_content_injuries/1
  41. # PATCH/PUT /regular_inspections/1/injuries/1/bridge_content_injuries/1.json
  42. 1 def update
  43. 3 respond_to do |format|
  44. 3 if @bridge_content_injury.update(bridge_content_injury_params)
  45. 2 format.html do
  46. 2 redirect_to [@regular_inspection, @injury, @bridge_content_injury],
  47. notice: I18n.t('controller.common.success_on_update',
  48. model_name: BridgeContentInjury.model_name.human)
  49. end
  50. 2 format.json { render :show, status: :ok, location: @bridge_content_injury }
  51. else
  52. 2 format.html { render :edit }
  53. 1 format.json { render json: @bridge_content_injury.errors, status: :unprocessable_entity }
  54. end
  55. end
  56. end
  57. # DELETE /regular_inspections/1/injuries/1/bridge_content_injuries/1
  58. # DELETE /regular_inspections/1/injuries/1/bridge_content_injuries/1.json
  59. 1 def destroy
  60. 2 @bridge_content_injury.destroy
  61. 2 respond_to do |format|
  62. 2 format.html do
  63. 2 redirect_to regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
  64. notice: I18n.t('controller.common.success_on_destroy',
  65. model_name: BridgeContentInjury.model_name.human)
  66. end
  67. 2 format.json { head :no_content }
  68. end
  69. end
  70. 1 private
  71. # Use callbacks to share common setup or constraints between actions.
  72. 1 def set_bridge_content_injury
  73. 7 @bridge_content_injury = BridgeContentInjury.joins(:bridge_content, :injury)
  74. .where(injury: @injury)
  75. .find(params[:id])
  76. end
  77. 1 def set_regular_inspection
  78. 13 @regular_inspection = RegularInspection.joins(:bridge)
  79. .includes(:bridge_contents)
  80. .find(params[:regular_inspection_id])
  81. end
  82. 1 def set_injury
  83. 13 @injury = Injury.includes(:bridge_content_injuries)
  84. .find(params[:injury_id])
  85. end
  86. # Only allow a list of trusted parameters through.
  87. 1 def bridge_content_injury_params
  88. 7 params.fetch(:bridge_content_injury, {}).permit(:bridge_content_id, :seek, :ortho_geojson, :pointposition)
  89. end
  90. end

app/controllers/bridge_contents_controller.rb

100.0% lines covered

41 relevant lines. 41 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # BridgeContentsController
  3. 1 class BridgeContentsController < UserBaseController
  4. 1 before_action :set_regular_inspection
  5. 1 before_action :set_bridge_content, only: %i[show edit update destroy]
  6. # GET /regular_inspections/1/bridge_contents
  7. # GET /regular_inspections/1/bridge_contents.json
  8. 1 def index
  9. 1 @bridge_contents = BridgeContent.where(regular_inspection: @regular_inspection).all
  10. end
  11. # GET /regular_inspections/1/bridge_contents/1
  12. # GET /regular_inspections/1/bridge_contents/1.json
  13. 1 def show; end
  14. # GET /regular_inspections/1/bridge_contents/new
  15. 1 def new
  16. 1 @bridge_content = BridgeContent.new(regular_inspection: @regular_inspection)
  17. end
  18. # GET /regular_inspections/1/bridge_contents/1/edit
  19. 1 def edit; end
  20. # POST /regular_inspections/1/bridge_contents
  21. # POST /regular_inspections/1/bridge_contents.json
  22. 1 def create
  23. 4 @bridge_content = BridgeContent.new(bridge_content_params)
  24. 4 @bridge_content.regular_inspection = @regular_inspection
  25. 4 respond_to do |format|
  26. 4 if @bridge_content.save
  27. 2 format.html do
  28. 2 redirect_to [@regular_inspection, @bridge_content],
  29. notice: I18n.t('controller.common.success_on_create', model_name: BridgeContent.model_name.human)
  30. end
  31. 2 format.json { render :show, status: :created, location: @bridge_content }
  32. else
  33. 4 format.html { render :new }
  34. 2 format.json { render json: @bridge_content.errors, status: :unprocessable_entity }
  35. end
  36. end
  37. end
  38. # PATCH/PUT /regular_inspections/1/bridge_contents/1
  39. # PATCH/PUT /regular_inspections/1/bridge_contents/1.json
  40. 1 def update
  41. 3 respond_to do |format|
  42. 3 if @bridge_content.update(bridge_content_params)
  43. 2 format.html do
  44. 2 redirect_to [@regular_inspection, @bridge_content],
  45. notice: I18n.t('controller.common.success_on_update', model_name: BridgeContent.model_name.human)
  46. end
  47. 2 format.json { render :show, status: :ok, location: @bridge_content }
  48. else
  49. 2 format.html { render :edit }
  50. 1 format.json { render json: @bridge_content.errors, status: :unprocessable_entity }
  51. end
  52. end
  53. end
  54. # DELETE /regular_inspections/1/bridge_contents/1
  55. # DELETE /regular_inspections/1/bridge_contents/1.json
  56. 1 def destroy
  57. 2 @bridge_content.destroy
  58. 2 respond_to do |format|
  59. 2 format.html do
  60. 2 redirect_to regular_inspection_bridge_contents_url(@regular_inspection),
  61. notice: I18n.t('controller.common.success_on_destroy', model_name: BridgeContent.model_name.human)
  62. end
  63. 2 format.json { head :no_content }
  64. end
  65. end
  66. 1 private
  67. # Use callbacks to share common setup or constraints between actions.
  68. 1 def set_bridge_content
  69. 7 @bridge_content = BridgeContent.where(regular_inspection: @regular_inspection)
  70. .includes(:bridge_content_injury).find(params[:id])
  71. end
  72. 1 def set_regular_inspection
  73. 13 @regular_inspection = RegularInspection.joins(:bridge).find(params[:regular_inspection_id])
  74. 13 @components = @regular_inspection.bridge.components
  75. end
  76. # Only allow a list of trusted parameters through.
  77. 1 def bridge_content_params
  78. 7 params.fetch(:bridge_content, {}).permit(:title, :data, :data_type, :position_entry_type, :component_id,
  79. :center_x, :center_y, :center_z,
  80. :euler_angle_alpha, :euler_angle_beta, :euler_angle_gamma,
  81. :quaternion_one, :quaternion_two, :quaternion_three, :quaternion_four,
  82. :bbox_u_r_x, :bbox_u_r_y, :bbox_u_r_z,
  83. :bbox_u_l_x, :bbox_u_l_y, :bbox_u_l_z,
  84. :bbox_d_r_x, :bbox_d_r_y, :bbox_d_r_z,
  85. :bbox_d_l_x, :bbox_d_l_y, :bbox_d_l_z,
  86. :photo_dimentions, :date_of_shooting, :projection_method,
  87. :target_material, :damage_or_not, :representative_photo,
  88. :pointcloud_data_id, :pointcloud_creation_name,
  89. :pointcloud_created_at, :pointcloud_measurement_method,
  90. :pointcloud_measurement_environment, :pointcloud_measuring_equipment,
  91. :pointcloud_analysis_method, :pointcloud_software,
  92. :pointcloud_crs, :pointcloud_reference_point_x,
  93. :pointcloud_reference_point_y, :pointcloud_reference_point_z)
  94. end
  95. end

app/controllers/bridge_main_contents_controller.rb

100.0% lines covered

25 relevant lines. 25 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # BridgeMainContentsController
  3. 1 class BridgeMainContentsController < UserBaseController
  4. 1 before_action :set_regular_inspection
  5. 1 before_action :set_bridge_main_content, only: %i[destroy]
  6. # POST /regular_inspections/1/bridge_main_contents
  7. # POST /regular_inspections/1/bridge_main_contents.json
  8. 1 def create
  9. 4 @bridge_main_content = BridgeMainContent.new(bridge_main_content_params)
  10. 4 respond_to do |format|
  11. 4 if @bridge_main_content.save
  12. 2 format.html do
  13. 2 redirect_to regular_inspection_bridge_contents_url(@regular_inspection),
  14. notice: I18n.t('controller.common.success_on_create',
  15. model_name: BridgeMainContent.model_name.human)
  16. end
  17. 2 format.json { render :show, status: :created, location: @bridge_main_content }
  18. else
  19. 4 format.html { redirect_to regular_inspection_bridge_contents_url(@regular_inspection) }
  20. 2 format.json { render json: @bridge_main_content.errors, status: :unprocessable_entity }
  21. end
  22. end
  23. end
  24. # DELETE /regular_inspections/1/bridge_main_contents/1
  25. # DELETE /regular_inspections/1/bridge_main_contents/1.json
  26. 1 def destroy
  27. 2 @bridge_main_content.destroy
  28. 2 respond_to do |format|
  29. 2 format.html do
  30. 2 redirect_to regular_inspection_bridge_contents_url(@regular_inspection),
  31. notice: I18n.t('controller.common.success_on_destroy',
  32. model_name: BridgeMainContent.model_name.human)
  33. end
  34. 2 format.json { head :no_content }
  35. end
  36. end
  37. 1 private
  38. # Use callbacks to share common setup or constraints between actions.
  39. 1 def set_bridge_main_content
  40. 2 @bridge_main_content = BridgeMainContent.find(params[:id])
  41. end
  42. 1 def set_regular_inspection
  43. 6 @regular_inspection = RegularInspection.joins(:bridge).find(params[:regular_inspection_id])
  44. end
  45. # Only allow a list of trusted parameters through.
  46. 1 def bridge_main_content_params
  47. 4 params.fetch(:bridge_main_content, {}).permit(:bridge_content_id)
  48. end
  49. end

app/controllers/bridges_controller.rb

100.0% lines covered

37 relevant lines. 37 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # BridgesController
  3. 1 class BridgesController < UserBaseController
  4. 1 before_action :set_bridge, only: %i[show edit update destroy]
  5. # GET /bridges
  6. # GET /bridges.json
  7. 1 def index
  8. 1 @bridges = Bridge.all
  9. end
  10. # GET /bridges/1
  11. # GET /bridges/1.json
  12. 1 def show; end
  13. # GET /bridges/new
  14. 1 def new
  15. 1 @bridge = Bridge.new
  16. 1 @bridge.location = 'POINT(140.084556 36.104611)'
  17. end
  18. # GET /bridges/1/edit
  19. 1 def edit; end
  20. # POST /bridges
  21. # POST /bridges.json
  22. 1 def create
  23. 4 @bridge = Bridge.new(bridge_params)
  24. 4 respond_to do |format|
  25. 4 if @bridge.save
  26. 2 format.html do
  27. 2 redirect_to @bridge,
  28. notice: I18n.t('controller.common.success_on_create', model_name: Bridge.model_name.human)
  29. end
  30. 2 format.json { render :show, status: :created, location: @bridge }
  31. else
  32. 4 format.html { render :new }
  33. 2 format.json { render json: @bridge.errors, status: :unprocessable_entity }
  34. end
  35. end
  36. end
  37. # PATCH/PUT /bridges/1
  38. # PATCH/PUT /bridges/1.json
  39. 1 def update
  40. 3 respond_to do |format|
  41. 3 if @bridge.update(bridge_params)
  42. 2 format.html do
  43. 2 redirect_to @bridge,
  44. notice: I18n.t('controller.common.success_on_update', model_name: Bridge.model_name.human)
  45. end
  46. 2 format.json { render :show, status: :ok, location: @bridge }
  47. else
  48. 2 format.html { render :edit }
  49. 1 format.json { render json: @bridge.errors, status: :unprocessable_entity }
  50. end
  51. end
  52. end
  53. # DELETE /bridges/1
  54. # DELETE /bridges/1.json
  55. 1 def destroy
  56. 2 @bridge.destroy
  57. 2 respond_to do |format|
  58. 2 format.html do
  59. 2 redirect_to bridges_url,
  60. notice: I18n.t('controller.common.success_on_destroy', model_name: Bridge.model_name.human)
  61. end
  62. 2 format.json { head :no_content }
  63. end
  64. end
  65. 1 private
  66. # Use callbacks to share common setup or constraints between actions.
  67. 1 def set_bridge
  68. 7 @bridge = Bridge.includes(:soundnesses, :regular_inspections).find(params[:id])
  69. end
  70. # Only allow a list of trusted parameters through.
  71. 1 def bridge_params
  72. 7 params.fetch(:bridge, {}).permit(:title, :address, :location, :road_name, :bridge_length, :width,
  73. :applicable_specifications_upper, :applicable_specifications_lower,
  74. :traffic_count, :large_vehicle_mixing_rate, :year_in_service,
  75. :priority, :administrator_name, :bridge_type,
  76. :street_condition, :availabillity_of_alternative_route,
  77. :freeway_or_public_road, :emergency_transport_road,
  78. :kana_title, :bridge_identification_number, :kind_of_bridge)
  79. end
  80. end

app/controllers/components_controller.rb

100.0% lines covered

40 relevant lines. 40 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # ComponentsController
  3. 1 class ComponentsController < UserBaseController
  4. 1 before_action :set_bridge
  5. 1 before_action :set_component, only: %i[show edit update destroy]
  6. # GET /components
  7. # GET /components.json
  8. 1 def index
  9. 1 @components = Component.where(bridge: @bridge).all
  10. end
  11. # GET /components/1
  12. # GET /components/1.json
  13. 1 def show; end
  14. # GET /components/new
  15. 1 def new
  16. 1 @component = Component.new(bridge: @bridge)
  17. end
  18. # GET /components/1/edit
  19. 1 def edit; end
  20. # POST /components
  21. # POST /components.json
  22. 1 def create
  23. 4 @component = Component.new(component_params)
  24. 4 @component.bridge = @bridge
  25. 4 respond_to do |format|
  26. 4 if @component.save
  27. 2 format.html do
  28. 2 redirect_to [@bridge, @component],
  29. notice: I18n.t('controller.common.success_on_create', model_name: Component.model_name.human)
  30. end
  31. 2 format.json { render :show, status: :created, location: @component }
  32. else
  33. 4 format.html { render :new }
  34. 2 format.json { render json: @component.errors, status: :unprocessable_entity }
  35. end
  36. end
  37. end
  38. # PATCH/PUT /components/1
  39. # PATCH/PUT /components/1.json
  40. 1 def update
  41. 3 respond_to do |format|
  42. 3 if @component.update(component_params)
  43. 2 format.html do
  44. 2 redirect_to [@bridge, @component],
  45. notice: I18n.t('controller.common.success_on_update', model_name: Component.model_name.human)
  46. end
  47. 2 format.json { render :show, status: :ok, location: @component }
  48. else
  49. 2 format.html { render :edit }
  50. 1 format.json { render json: @component.errors, status: :unprocessable_entity }
  51. end
  52. end
  53. end
  54. # DELETE /components/1
  55. # DELETE /components/1.json
  56. 1 def destroy
  57. 2 @component.destroy
  58. 2 respond_to do |format|
  59. 2 format.html do
  60. 2 redirect_to bridge_components_url(@bridge),
  61. notice: I18n.t('controller.common.success_on_destroy', model_name: Component.model_name.human)
  62. end
  63. 2 format.json { head :no_content }
  64. end
  65. end
  66. 1 private
  67. # Use callbacks to share common setup or constraints between actions.
  68. 1 def set_component
  69. 7 @component = Component.find(params[:id])
  70. end
  71. 1 def set_bridge
  72. 13 @bridge = Bridge.find(params[:bridge_id])
  73. end
  74. # Only allow a list of trusted parameters through.
  75. 1 def component_params
  76. 7 params.fetch(:component, {}).permit(:span_number, :component_category, :title)
  77. end
  78. end

app/controllers/concerns/admin_session_action.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # AdminSession action concern
  3. 1 module AdminSessionAction
  4. 1 extend ActiveSupport::Concern
  5. 1 def let_admin_user_login
  6. 15 admin_user_id = session[:admin_user_id]
  7. 15 unless admin_user_id.blank?
  8. 14 @current_admin_user ||= AdminUser.find_by(id: admin_user_id)
  9. 14 return unless @current_admin_user.nil?
  10. end
  11. 1 alert = 'need to login'
  12. 1 redirect_to(
  13. {
  14. controller: 'admin/sessions',
  15. action: 'index'
  16. }, {
  17. alert: alert
  18. }
  19. )
  20. end
  21. end

app/controllers/concerns/user_session_action.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # User Session action concern
  3. 1 module UserSessionAction
  4. 1 extend ActiveSupport::Concern
  5. 1 def let_user_login
  6. 121 user_id = session[:user_id]
  7. 121 unless user_id.blank?
  8. 120 @current_user ||= User.find_by(id: user_id)
  9. 120 return unless @current_user.nil?
  10. end
  11. 1 alert = 'need to login'
  12. 1 redirect_to(
  13. {
  14. controller: 'sessions',
  15. action: 'index'
  16. }, {
  17. alert: alert
  18. }
  19. )
  20. end
  21. end

app/controllers/diagnoses_controller.rb

100.0% lines covered

40 relevant lines. 40 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # DiagnosesController
  3. 1 class DiagnosesController < UserBaseController
  4. 1 before_action :set_regular_inspection
  5. 1 before_action :set_diagnosis, only: %i[show edit update destroy]
  6. # GET /regular_inspections/1/diagnoses
  7. # GET /regular_inspections/1/diagnoses.json
  8. 1 def index
  9. 1 @diagnoses = Diagnosis.where(regular_inspection: @regular_inspection)
  10. .includes(:injury).order(:component_category).all
  11. end
  12. # GET /regular_inspections/1/diagnoses/1
  13. # GET /regular_inspections/1/diagnoses/1.json
  14. 1 def show; end
  15. # GET /regular_inspections/1/diagnoses/new
  16. 1 def new
  17. 1 @diagnosis = Diagnosis.new(regular_inspection: @regular_inspection)
  18. end
  19. # GET /regular_inspections/1/diagnoses/1/edit
  20. 1 def edit; end
  21. # POST /regular_inspections/1/diagnoses
  22. # POST /regular_inspections/1/diagnoses.json
  23. 1 def create
  24. 4 @diagnosis = Diagnosis.new(diagnosis_params)
  25. 4 @diagnosis.regular_inspection = @regular_inspection
  26. 4 respond_to do |format|
  27. 4 if @diagnosis.save
  28. 2 format.html do
  29. 2 redirect_to [@regular_inspection, @diagnosis],
  30. notice: I18n.t('controller.common.success_on_create', model_name: Diagnosis.model_name.human)
  31. end
  32. 2 format.json { render :show, status: :created, location: @diagnosis }
  33. else
  34. 4 format.html { render :new }
  35. 2 format.json { render json: @diagnosis.errors, status: :unprocessable_entity }
  36. end
  37. end
  38. end
  39. # PATCH/PUT /regular_inspections/1/diagnoses/1
  40. # PATCH/PUT /regular_inspections/1/diagnoses/1.json
  41. 1 def update
  42. 3 respond_to do |format|
  43. 3 if @diagnosis.update(diagnosis_params)
  44. 2 format.html do
  45. 2 redirect_to [@regular_inspection, @diagnosis],
  46. notice: I18n.t('controller.common.success_on_update', model_name: Diagnosis.model_name.human)
  47. end
  48. 2 format.json { render :show, status: :ok, location: @diagnosis }
  49. else
  50. 2 format.html { render :edit }
  51. 1 format.json { render json: @diagnosis.errors, status: :unprocessable_entity }
  52. end
  53. end
  54. end
  55. # DELETE /regular_inspections/1/diagnoses/1
  56. # DELETE /regular_inspections/1/diagnoses/1.json
  57. 1 def destroy
  58. 2 @diagnosis.destroy
  59. 2 respond_to do |format|
  60. 2 format.html do
  61. 2 redirect_to regular_inspection_diagnoses_url(@regular_inspection),
  62. notice: I18n.t('controller.common.success_on_destroy', model_name: Diagnosis.model_name.human)
  63. end
  64. 2 format.json { head :no_content }
  65. end
  66. end
  67. 1 private
  68. # Use callbacks to share common setup or constraints between actions.
  69. 1 def set_diagnosis
  70. 7 @diagnosis = Diagnosis.find(params[:id])
  71. end
  72. 1 def set_regular_inspection
  73. 13 @regular_inspection = RegularInspection.joins(:bridge).includes(:injuries).find(params[:regular_inspection_id])
  74. end
  75. # Only allow a list of trusted parameters through.
  76. 1 def diagnosis_params
  77. 7 params.fetch(:diagnosis, {}).permit(:component_category, :result, :injury_id, :remark)
  78. end
  79. end

app/controllers/injuries_controller.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # InjuriesController
  3. 1 class InjuriesController < UserBaseController
  4. 1 before_action :set_regular_inspection
  5. 1 before_action :set_injury, only: %i[show edit update destroy]
  6. # GET /regular_inspections/1/injuries
  7. # GET /regular_inspections/1/injuries.json
  8. 1 def index
  9. 1 @injuries = Injury.where(regular_inspection: @regular_inspection).all
  10. end
  11. # GET /regular_inspections/1/injuries/1
  12. # GET /regular_inspections/1/injuries/1.json
  13. 1 def show; end
  14. # GET /regular_inspections/1/injuries/new
  15. 1 def new
  16. 1 @injury = Injury.new(regular_inspection: @regular_inspection)
  17. 1 @components = Component.where(bridge: @regular_inspection.bridge)
  18. end
  19. # GET /regular_inspections/1/injuries/1/edit
  20. 1 def edit
  21. 1 @components = Component.where(bridge: @regular_inspection.bridge)
  22. end
  23. # POST /regular_inspections/1/injuries
  24. # POST /regular_inspections/1/injuries.json
  25. 1 def create
  26. 4 @injury = Injury.new(injury_params)
  27. 4 @injury.regular_inspection = @regular_inspection
  28. 4 respond_to do |format|
  29. 4 if @injury.save
  30. 2 format.html do
  31. 2 redirect_to [@regular_inspection, @injury],
  32. notice: I18n.t('controller.common.success_on_create', model_name: Injury.model_name.human)
  33. end
  34. 2 format.json { render :show, status: :created, location: @injury }
  35. else
  36. 2 @components = Component.where(bridge: @regular_inspection.bridge)
  37. 4 format.html { render :new }
  38. 2 format.json { render json: @injury.errors, status: :unprocessable_entity }
  39. end
  40. end
  41. end
  42. # PATCH/PUT /regular_inspections/1/injuries/1
  43. # PATCH/PUT /regular_inspections/1/injuries/1.json
  44. 1 def update
  45. 3 respond_to do |format|
  46. 3 if @injury.update(injury_params)
  47. 2 format.html do
  48. 2 redirect_to [@regular_inspection, @injury],
  49. notice: I18n.t('controller.common.success_on_update', model_name: Injury.model_name.human)
  50. end
  51. 2 format.json { render :show, status: :ok, location: @injury }
  52. else
  53. 1 @components = Component.where(bridge: @regular_inspection.bridge)
  54. 2 format.html { render :edit }
  55. 1 format.json { render json: @injury.errors, status: :unprocessable_entity }
  56. end
  57. end
  58. end
  59. # DELETE /regular_inspections/1/injuries/1
  60. # DELETE /regular_inspections/1/injuries/1.json
  61. 1 def destroy
  62. 2 @injury.destroy
  63. 2 respond_to do |format|
  64. 2 format.html do
  65. 2 redirect_to regular_inspection_injury_url(@regular_inspection),
  66. notice: I18n.t('controller.common.success_on_destroy', model_name: Injury.model_name.human)
  67. end
  68. 2 format.json { head :no_content }
  69. end
  70. end
  71. 1 private
  72. # Use callbacks to share common setup or constraints between actions.
  73. 1 def set_injury
  74. 7 @injury = Injury.where(regular_inspection: @regular_inspection).find(params[:id])
  75. end
  76. 1 def set_regular_inspection
  77. 13 @regular_inspection = RegularInspection.joins(:bridge).find(params[:regular_inspection_id])
  78. end
  79. # Only allow a list of trusted parameters through.
  80. 1 def injury_params
  81. 7 params.fetch(:injury, {}).permit(:component_id, :injury_type, :injury_grade, :quantitatively_obtained_value,
  82. :unit, :injury_pattern, :classification, :impression)
  83. end
  84. end

app/controllers/mlit_importers_controller.rb

100.0% lines covered

18 relevant lines. 18 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Mlti Importers Controller
  3. 1 class MlitImportersController < UserBaseController
  4. 1 def new; end
  5. 1 def preview
  6. 2 update_file = preview_params[:upload_file]
  7. 2 @bridge = MlitImporter.import(update_file)
  8. 2 render :new unless @bridge.valid?
  9. end
  10. 1 def create
  11. 4 @bridge = Bridge.new(bridge_params)
  12. 4 respond_to do |format|
  13. 4 if @bridge.save
  14. 2 format.html do
  15. 2 redirect_to @bridge,
  16. notice: I18n.t('controller.common.success_on_create', model_name: Bridge.model_name.human)
  17. end
  18. else
  19. 4 format.html { render :new }
  20. end
  21. end
  22. end
  23. 1 private
  24. 1 def preview_params
  25. 2 params.permit(:upload_file)
  26. end
  27. # Only allow a list of trusted parameters through.
  28. 1 def bridge_params
  29. 4 params.fetch(:bridge, {}).permit(:title, :address, :location, :road_name)
  30. end
  31. end

app/controllers/regular_inspections_controller.rb

100.0% lines covered

42 relevant lines. 42 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Regular Inspections Controller
  3. 1 class RegularInspectionsController < UserBaseController
  4. 1 before_action :set_regular_inspection, only: %i[show edit update destroy]
  5. # GET /regular_inspections
  6. # GET /regular_inspections.json
  7. 1 def index
  8. 1 @regular_inspections = RegularInspection.joins(:bridge).all
  9. end
  10. # GET /regular_inspections/1
  11. # GET /regular_inspections/1.json
  12. 1 def show; end
  13. # GET /regular_inspections/new
  14. 1 def new
  15. 1 @regular_inspection = RegularInspection.new
  16. end
  17. # GET /regular_inspections/1/edit
  18. 1 def edit; end
  19. # POST /regular_inspections
  20. # POST /regular_inspections.json
  21. 1 def create
  22. 4 @regular_inspection = RegularInspection.new(regular_inspection_params)
  23. 4 respond_to do |format|
  24. 4 if @regular_inspection.save
  25. 2 format.html do
  26. 2 redirect_to @regular_inspection,
  27. notice: I18n.t('controller.common.success_on_create',
  28. model_name: RegularInspection.model_name.human)
  29. end
  30. 2 format.json { render :show, status: :created, location: @regular_inspection }
  31. else
  32. 4 format.html { render :new }
  33. 2 format.json { render json: @regular_inspection.errors, status: :unprocessable_entity }
  34. end
  35. end
  36. end
  37. # PATCH/PUT /regular_inspections/1
  38. # PATCH/PUT /regular_inspections/1.json
  39. 1 def update
  40. 3 respond_to do |format|
  41. 3 if @regular_inspection.update(regular_inspection_params)
  42. 2 format.html do
  43. 2 redirect_to @regular_inspection,
  44. notice: I18n.t('controller.common.success_on_update',
  45. model_name: RegularInspection.model_name.human)
  46. end
  47. 2 format.json { render :show, status: :ok, location: @regular_inspection }
  48. else
  49. 2 format.html { render :edit }
  50. 1 format.json { render json: @regular_inspection.errors, status: :unprocessable_entity }
  51. end
  52. end
  53. end
  54. # DELETE /regular_inspections/1
  55. # DELETE /regular_inspections/1.json
  56. 1 def destroy
  57. 2 @regular_inspection.destroy
  58. 2 respond_to do |format|
  59. 2 format.html do
  60. 2 redirect_to regular_inspections_url,
  61. notice: I18n.t('controller.common.success_on_destroy',
  62. model_name: RegularInspection.model_name.human)
  63. end
  64. 2 format.json { head :no_content }
  65. end
  66. end
  67. 1 def download_image_metadata
  68. 1 @regular_inspection = RegularInspection.includes(:bridge_contents).find(params[:regular_inspection_id])
  69. 1 send_data(
  70. render_to_string(
  71. partial: 'regular_inspections/download_image_metadata.csv'
  72. ),
  73. filename: 'image_metadata.csv',
  74. type: 'csv'
  75. )
  76. end
  77. 1 def download_pointcloud_metadata
  78. 1 @regular_inspection = RegularInspection.includes(:bridge_contents).find(params[:regular_inspection_id])
  79. 1 send_data(
  80. render_to_string(
  81. partial: 'regular_inspections/download_pointcloud_metadata.csv'
  82. ),
  83. filename: 'pointcloud_metadata.csv',
  84. type: 'csv'
  85. )
  86. end
  87. 1 private
  88. # Use callbacks to share common setup or constraints between actions.
  89. 1 def set_regular_inspection
  90. 7 @regular_inspection = RegularInspection.includes([:diagnoses, { injuries: [:component] }])
  91. .order('diagnoses.component_category')
  92. .order('components.component_category').find(params[:id])
  93. end
  94. # Only allow a list of trusted parameters through.
  95. 1 def regular_inspection_params
  96. 7 params.fetch(:regular_inspection, {}).permit(:bridge_id, :title, :person_responsible, :periodic_inspection_date,
  97. :record_updated_date, :start_date, :end_date)
  98. end
  99. end

app/controllers/soundnesses_controller.rb

100.0% lines covered

40 relevant lines. 40 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # SoundnessesController
  3. 1 class SoundnessesController < UserBaseController
  4. 1 before_action :set_bridge
  5. 1 before_action :set_soundness, only: %i[show edit update destroy]
  6. # GET /bridges/1/soundnesses
  7. # GET /bridges/1/soundnesses.json
  8. 1 def index
  9. 1 @soundnesses = Soundness.where(bridge: @bridge).all
  10. end
  11. # GET /bridges/1/soundnesses/1
  12. # GET /bridges/1/soundnesses/1.json
  13. 1 def show; end
  14. # GET /bridges/1/soundnesses/new
  15. 1 def new
  16. 1 @soundness = Soundness.new(bridge: @bridge)
  17. end
  18. # GET /bridges/1/soundnesses/1/edit
  19. 1 def edit; end
  20. # POST /bridges/1/soundnesses
  21. # POST /bridges/1/soundnesses.json
  22. 1 def create
  23. 4 @soundness = Soundness.new(soundness_params)
  24. 4 @soundness.bridge = @bridge
  25. 4 respond_to do |format|
  26. 4 if @soundness.save
  27. 2 format.html do
  28. 2 redirect_to [@bridge, @soundness],
  29. notice: I18n.t('controller.common.success_on_create', model_name: Soundness.model_name.human)
  30. end
  31. 2 format.json { render :show, status: :created, location: @soundness }
  32. else
  33. 4 format.html { render :new }
  34. 2 format.json { render json: @soundness.errors, status: :unprocessable_entity }
  35. end
  36. end
  37. end
  38. # PATCH/PUT /soundnesses/1
  39. # PATCH/PUT /soundnesses/1.json
  40. 1 def update
  41. 3 respond_to do |format|
  42. 3 if @soundness.update(soundness_params)
  43. 2 format.html do
  44. 2 redirect_to [@bridge, @soundness],
  45. notice: I18n.t('controller.common.success_on_update', model_name: Soundness.model_name.human)
  46. end
  47. 2 format.json { render :show, status: :ok, location: @soundness }
  48. else
  49. 2 format.html { render :edit }
  50. 1 format.json { render json: @soundness.errors, status: :unprocessable_entity }
  51. end
  52. end
  53. end
  54. # DELETE /soundnesses/1
  55. # DELETE /soundnesses/1.json
  56. 1 def destroy
  57. 2 @soundness.destroy
  58. 2 respond_to do |format|
  59. 2 format.html do
  60. 2 redirect_to bridge_soundnesses_url(@bridge),
  61. notice: I18n.t('controller.common.success_on_destroy', model_name: Soundness.model_name.human)
  62. end
  63. 2 format.json { head :no_content }
  64. end
  65. end
  66. 1 private
  67. # Use callbacks to share common setup or constraints between actions.
  68. 1 def set_soundness
  69. 7 @soundness = Soundness.find(params[:id])
  70. end
  71. 1 def set_bridge
  72. 13 @bridge = Bridge.find(params[:bridge_id])
  73. end
  74. # Only allow a list of trusted parameters through.
  75. 1 def soundness_params
  76. 7 params.fetch(:soundness, {}).permit(:evaluation_at, :evaluation, :overall_evaluation)
  77. end
  78. end

app/controllers/status_controller.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # StatusController
  3. 1 class StatusController < ActionController::Base
  4. 1 def index
  5. 2 payload = {
  6. bridge_count: 0,
  7. message: nil
  8. }
  9. begin
  10. 2 payload[:bridge_count] = Bridge.count
  11. 1 render json: payload, status: :ok
  12. rescue => e # rubocop:disable Style/RescueStandardError
  13. 1 payload[:message] = e.message
  14. 1 render json: payload, status: :internal_server_error
  15. end
  16. end
  17. end

app/controllers/top_controller.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # TopController path=/
  3. 1 class TopController < UserBaseController
  4. 1 def index
  5. 1 @bridges = Bridge.includes(:soundnesses)
  6. 1 @matrix = Dashboard.matrix(@bridges)
  7. 1 @overall_evaluations = Dashboard.sorted_overall_evaluations
  8. 1 @soundness_chart = Dashboard.soundness_chart(@bridges)
  9. 1 @priority_chart = Dashboard.priority_chart(@bridges)
  10. 1 @kind_of_bridge_chart = Dashboard.kind_of_bridge_chart(@bridges)
  11. end
  12. end

app/controllers/user_base_controller.rb

100.0% lines covered

4 relevant lines. 4 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # User Base Controller
  3. 1 class UserBaseController < ApplicationController
  4. 1 include UserSessionAction
  5. 1 layout 'user'
  6. 1 before_action :let_user_login
  7. end

app/helpers/application_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # ApplicationHelper
  3. 1 module ApplicationHelper
  4. end

app/jobs/application_job.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # ApplicationJob
  3. 1 class ApplicationJob < ActiveJob::Base
  4. # Automatically retry jobs that encountered a deadlock
  5. # retry_on ActiveRecord::Deadlocked
  6. # Most jobs are safe to ignore if the underlying records are no longer available
  7. # discard_on ActiveJob::DeserializationError
  8. end

app/jobs/game_tile_job.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # GameTileJob
  3. 1 class GameTileJob < ApplicationJob
  4. 1 queue_as :default
  5. 1 def perform(bridge_content_id)
  6. 3 bridge_content = BridgeContent.find_by_id(bridge_content_id)
  7. 3 return if bridge_content.nil?
  8. 3 return unless bridge_content.data_type.to_i == BridgeContent.data_types[:ortho]
  9. 3 exec_perform(bridge_content)
  10. end
  11. 1 private
  12. 1 def exec_perform(bridge_content)
  13. 3 bridge_content.data.open do |file|
  14. 3 target_dir = Rails.root.join('public', 'ortho_images', bridge_content.id.to_s)
  15. 3 target_dir = File.join('/tmp', 'ortho_images', bridge_content.id.to_s) if Rails.env == 'test'
  16. 3 FileUtils.rm_rf(target_dir)
  17. 3 game_tile = GameTile.new(file.path, target_dir)
  18. 3 zoom_range = game_tile.make
  19. 3 bridge_content.ortho_tile_info = { min_zoom: zoom_range.first, max_zoom: zoom_range.last }
  20. 3 bridge_content.save
  21. end
  22. end
  23. end

app/models/admin_user.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # AdminUser model
  3. 1 class AdminUser < ApplicationRecord
  4. 1 include UserImplement
  5. 1 has_secure_password
  6. 1 validates :login_name, presence: true, uniqueness: true
  7. 1 validates :password_digest, presence: true
  8. 1 validates :password,
  9. length: { minimum: 8, if: :validate_password? },
  10. confirmation: { if: :validate_password? }
  11. 1 validates :password,
  12. format: {
  13. with: /\A(?=.*?[a-z])(?=.*?\d)[a-z\d]{2,100}\z/i,
  14. message: I18n.t('errors.attributes.password.invalid'),
  15. if: :validate_password?
  16. }, confirmation: { if: :validate_password? }
  17. end

app/models/application_record.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # ApplicationRecord
  3. 1 class ApplicationRecord < ActiveRecord::Base
  4. 1 self.abstract_class = true
  5. end

app/models/bridge.rb

100.0% lines covered

35 relevant lines. 35 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Bridge class
  3. 1 class Bridge < ApplicationRecord
  4. 1 include AttrJson::Record
  5. 1 include AttrJson::Record::QueryScopes
  6. 1 attr_json_config(default_container_attribute: :other_data)
  7. 1 has_many :soundnesses
  8. 1 has_many :regular_inspections
  9. 1 has_many :components
  10. 1 validates :title, presence: true
  11. 1 validates :address, presence: true
  12. 1 validates :location, presence: true
  13. 1 attr_json :road_name, :string
  14. 1 attr_json :bridge_length, :integer
  15. 1 attr_json :width, :float
  16. # 適用示方書
  17. 1 attr_json :applicable_specifications_upper, :string
  18. 1 attr_json :applicable_specifications_lower, :string
  19. # 交通量
  20. 1 attr_json :traffic_count, :string
  21. # 大型車混入率
  22. 1 attr_json :large_vehicle_mixing_rate, :string
  23. # 供用年
  24. 1 attr_json :year_in_service, :integer
  25. # 重要度
  26. 1 attr_json :priority, :integer, default: 0
  27. # 管理者名
  28. 1 attr_json :administrator_name, :string
  29. # 橋梁形式
  30. 1 attr_json :bridge_type, :string
  31. # 路下条件
  32. 1 attr_json :street_condition, :string
  33. # 代替路の有無
  34. 1 attr_json :availabillity_of_alternative_route, :integer
  35. # 自専道or一般道
  36. 1 attr_json :freeway_or_public_road, :integer
  37. # 緊急輸送道路
  38. 1 attr_json :emergency_transport_road, :boolean
  39. # フリガナ
  40. 1 attr_json :kana_title, :string
  41. # 橋梁ID
  42. 1 attr_json :bridge_identification_number, :string
  43. # 橋種
  44. 1 attr_json :kind_of_bridge, :integer, default: 0
  45. 1 enum priority_type: {
  46. priority_unselected: 0,
  47. priority_a: 1,
  48. priority_b: 2,
  49. priority_c: 3
  50. }
  51. 1 enum availabillity_of_alternative_route_type: {
  52. unknown: 0,
  53. available: 1,
  54. unavailable: 2
  55. }
  56. 1 enum freeway_or_public_road_type: {
  57. unselected: 0,
  58. freeway: 1,
  59. public_road: 2
  60. }
  61. 1 enum kind_of_bridge_type: {
  62. others: 0,
  63. concrete: 1,
  64. steel: 2,
  65. mixing: 3
  66. }
  67. 1 def full_title
  68. 16 return title if kana_title.blank?
  69. 2 "#{title} (#{kana_title})"
  70. end
  71. end

app/models/bridge_content.rb

97.83% lines covered

92 relevant lines. 90 lines covered and 2 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'exifr/jpeg'
  3. # rubocop:disable Metrics/ClassLength
  4. # BridgeContent Model
  5. 1 class BridgeContent < ApplicationRecord
  6. 1 after_commit :pointcloud_update
  7. 1 before_save :check_pointcloud_is_update
  8. 1 after_commit :ortho_image_update
  9. 1 before_save :check_ortho_is_update
  10. 1 after_commit :check_image_has_exif
  11. 1 belongs_to :regular_inspection
  12. 1 belongs_to :component, optional: true
  13. 1 has_one :bridge_main_content
  14. 1 has_one :bridge_content_injury
  15. 1 validates :title, presence: true
  16. 1 has_one_attached :data
  17. 1 validates :data, presence: true
  18. 1 store_accessor :metadata, :data_type
  19. 1 store_accessor :metadata, :ortho_tile_info
  20. 1 store_accessor :metadata, :ortho_metadata
  21. 1 store_accessor :metadata, :pointcloud_info
  22. 1 store_accessor :metadata, :pointcloud_metadata
  23. # image metadata
  24. 1 store_accessor :metadata, :position_entry_type
  25. 1 store_accessor :metadata, :center_x
  26. 1 store_accessor :metadata, :center_y
  27. 1 store_accessor :metadata, :center_z
  28. 1 store_accessor :metadata, :euler_angle_alpha
  29. 1 store_accessor :metadata, :euler_angle_beta
  30. 1 store_accessor :metadata, :euler_angle_gamma
  31. 1 store_accessor :metadata, :quaternion_one
  32. 1 store_accessor :metadata, :quaternion_two
  33. 1 store_accessor :metadata, :quaternion_three
  34. 1 store_accessor :metadata, :quaternion_four
  35. 1 store_accessor :metadata, :bbox_u_r_x
  36. 1 store_accessor :metadata, :bbox_u_r_y
  37. 1 store_accessor :metadata, :bbox_u_r_z
  38. 1 store_accessor :metadata, :bbox_u_l_x
  39. 1 store_accessor :metadata, :bbox_u_l_y
  40. 1 store_accessor :metadata, :bbox_u_l_z
  41. 1 store_accessor :metadata, :bbox_d_r_x
  42. 1 store_accessor :metadata, :bbox_d_r_y
  43. 1 store_accessor :metadata, :bbox_d_r_z
  44. 1 store_accessor :metadata, :bbox_d_l_x
  45. 1 store_accessor :metadata, :bbox_d_l_y
  46. 1 store_accessor :metadata, :bbox_d_l_z
  47. 1 store_accessor :metadata, :photo_dimentions
  48. 1 store_accessor :metadata, :date_of_shooting
  49. 1 store_accessor :metadata, :projection_method
  50. 1 store_accessor :metadata, :target_material
  51. 1 store_accessor :metadata, :damage_or_not
  52. 1 store_accessor :metadata, :representative_photo
  53. # point cloud metadata
  54. 1 store_accessor :metadata, :pointcloud_data_id
  55. 1 store_accessor :metadata, :pointcloud_creation_name
  56. 1 store_accessor :metadata, :pointcloud_created_at
  57. 1 store_accessor :metadata, :pointcloud_measurement_method
  58. 1 store_accessor :metadata, :pointcloud_measurement_environment
  59. 1 store_accessor :metadata, :pointcloud_measuring_equipment
  60. 1 store_accessor :metadata, :pointcloud_analysis_method
  61. 1 store_accessor :metadata, :pointcloud_software
  62. 1 store_accessor :metadata, :pointcloud_crs
  63. 1 store_accessor :metadata, :pointcloud_reference_point_x
  64. 1 store_accessor :metadata, :pointcloud_reference_point_y
  65. 1 store_accessor :metadata, :pointcloud_reference_point_z
  66. 1 enum data_type: {
  67. unselected: 0,
  68. image: 1,
  69. movie: 2,
  70. damage_diagram: 3,
  71. ortho: 4,
  72. pointcloud: 5
  73. }
  74. 1 enum position_entry_type: {
  75. center_photo: 0,
  76. center_camera: 1,
  77. photo_bbox: 2
  78. }
  79. 1 enum projection_method: {
  80. center_projection: 0,
  81. orthographic_projection: 1
  82. }
  83. 1 enum target_material: {
  84. main_girder: 'Mg',
  85. cross_member: 'Cr',
  86. slab: 'Ds',
  87. substructure: 'SB',
  88. bearing_h: 'Bh',
  89. bearing_m: 'Bm',
  90. bearing_c: 'Bh',
  91. top_plate: 'Ct',
  92. side_wall: 'Sw',
  93. bottom_plate: 'Cb'
  94. }
  95. 1 enum damage_or_not: {
  96. damage: 1,
  97. not_damage: 0
  98. }
  99. 1 enum representative_photo: {
  100. representative: 1,
  101. others: 0
  102. }
  103. 1 def main_content?
  104. 2 return true unless bridge_main_content.nil?
  105. 1 false
  106. end
  107. 1 private
  108. 1 def check_ortho_is_update
  109. 55 return unless data_type.to_i == BridgeContent.data_types[:ortho]
  110. 6 self.ortho_tile_info = nil if data.changed?
  111. end
  112. 1 def ortho_image_update
  113. 57 return unless data_type.to_i == BridgeContent.data_types[:ortho]
  114. 6 GameTileJob.perform_later(id) if ortho_tile_info.nil?
  115. end
  116. 1 def check_pointcloud_is_update
  117. 55 return unless data_type.to_i == BridgeContent.data_types[:pointcloud]
  118. self.pointcloud_info = nil if data.changed?
  119. end
  120. 1 def pointcloud_update
  121. 57 return unless data_type.to_i == BridgeContent.data_types[:pointcloud]
  122. PointcloudJob.perform_later(id) if pointcloud_info.nil?
  123. end
  124. # rubocop:disable Metrics/AbcSize
  125. 1 def check_image_has_exif
  126. 57 return unless data_type.to_i == BridgeContent.data_types[:image]
  127. 2 return unless date_of_shooting.blank?
  128. 1 return unless data.content_type == 'image/jpeg'
  129. # read exif
  130. 1 data.open do |file|
  131. 1 exif = EXIFR::JPEG.new(file.path)
  132. 1 break unless exif.exif?
  133. 1 break if exif.date_time.nil?
  134. 1 self.date_of_shooting = exif.date_time.strftime('%Y/%m/%d %H:%M:%S')
  135. 1 save
  136. end
  137. end
  138. # rubocop:enable Metrics/AbcSize
  139. end
  140. # rubocop:enable Metrics/ClassLength

app/models/bridge_content_injury.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # BridgeContentInjury
  3. 1 class BridgeContentInjury < ApplicationRecord
  4. 1 include AttrJson::Record
  5. 1 attr_json_config(default_container_attribute: :other_data)
  6. 1 belongs_to :bridge_content
  7. 1 belongs_to :injury
  8. 1 validates_with BridgeContentInjurySameOriginValidator
  9. # 動画 seek
  10. 1 attr_json :seek, :integer
  11. # オルソ geojson
  12. 1 attr_json :ortho_geojson, :string
  13. 1 attr_json :pointposition, :string
  14. end

app/models/bridge_main_content.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # BridgeMainContent
  3. 1 class BridgeMainContent < ApplicationRecord
  4. 1 belongs_to :bridge_content
  5. end

app/models/component.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Component model
  3. 1 class Component < ApplicationRecord
  4. 1 belongs_to :bridge
  5. 1 validates :bridge, presence: true
  6. 1 validates :span_number, presence: true
  7. 1 validates :component_category, presence: true
  8. 1 def show_name
  9. 10 I18n.t('activerecord.attributes.component.span_number') +
  10. " #{span_number} " +
  11. I18n.t("enums.component.category.#{Component.categories.invert[component_category]}") +
  12. title
  13. end
  14. 1 enum category: {
  15. superstructure_main_girder: 1,
  16. superstructure_horizontal_grider: 2,
  17. superstructure_slab: 3,
  18. substructure: 4,
  19. support_structure: 5,
  20. other: 6
  21. }
  22. end

app/models/concerns/location_implement.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # location implement
  3. 1 module LocationImplement
  4. # 35°37′37″ -> 35.62694444444445
  5. 1 def self.sexagesimal_to_float(value)
  6. 17 coordinate, others = value.split('°')
  7. 17 minutes, others = others.split('′')
  8. 17 seconds = others.split('″')[0]
  9. 17 coordinate.to_i + minutes.to_f / 60 + seconds.to_f / 3600
  10. end
  11. # 35.35.62694444 -> 35°37′37″
  12. 1 def self.float_to_sexagesimal(value)
  13. 1 coordinate_whole = value.to_i
  14. 1 coordinate_decimal = value - coordinate_whole
  15. 1 minutes = coordinate_decimal * 60
  16. 1 minutes_whole = minutes.to_i
  17. 1 minutes_decimal = minutes - minutes_whole
  18. 1 seconds = (minutes_decimal * 60).round.to_i
  19. 1 "#{coordinate_whole}°#{minutes_whole}′#{seconds}″"
  20. end
  21. end

app/models/concerns/user_implement.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # user implement
  3. 1 module UserImplement
  4. 1 extend ActiveSupport::Concern
  5. 1 private
  6. 1 def validate_password?
  7. 764 password.present? || password_confirmation.present?
  8. end
  9. end

app/models/dashboard.rb

98.51% lines covered

67 relevant lines. 66 lines covered and 1 lines missed.
    
  1. # frozen_string_literal: true
  2. # Dashboard class
  3. 1 class Dashboard
  4. 1 class << self
  5. 1 def matrix(bridges)
  6. 3 bridges = bridges.order('soundnesses.evaluation_at')
  7. 3 make_matrix(bridges)
  8. end
  9. 1 def sorted_overall_evaluations
  10. 24 overall_evaluations = Soundness.overall_evaluations.map { |k, _| k }
  11. 4 unselected = overall_evaluations.shift
  12. 4 overall_evaluations << unselected
  13. 4 overall_evaluations.reverse
  14. end
  15. 1 def soundness_chart(bridges)
  16. 2 bridges = bridges.order('soundnesses.evaluation_at')
  17. 2 values = {}
  18. 12 sorted_overall_evaluations.each { |k| values[k.to_s] = 0 }
  19. 2 bridges.each do |bridge|
  20. 4 soundness = bridge.soundnesses.last
  21. 4 if soundness.nil?
  22. 1 values['unselected'] += 1
  23. else
  24. 3 values[soundness.overall_evaluation] += 1
  25. end
  26. end
  27. 2 values
  28. end
  29. 1 def priority_chart(bridges)
  30. 10 priority_types = Bridge.priority_types.map { |k, _| k }
  31. 2 values = {}
  32. 10 priority_types.each { |k| values[k.to_s] = 0 }
  33. 2 bridges.each do |bridge|
  34. 4 key = Bridge.priority_types.invert[bridge.priority]
  35. 4 if !key.nil?
  36. 4 values[key] += 1
  37. else
  38. values['priority_unselected'] += 1
  39. end
  40. end
  41. 2 values
  42. end
  43. 1 def kind_of_bridge_chart(bridges)
  44. 6 year_in_services = bridges.map(&:year_in_service).filter { |k| !k.nil? }.sort.uniq
  45. 2 return {} if year_in_services.empty?
  46. 1 make_kind_of_bridge_chart(year_in_services)
  47. end
  48. 1 private
  49. 1 def matrix_item(bridge)
  50. 8 soundness = bridge.soundnesses.last
  51. 8 return nil, nil, bridge if soundness.nil?
  52. 6 year = soundness.evaluation_at.strftime('%Y')
  53. 6 overall_evaluation = soundness.overall_evaluation
  54. 6 [year, overall_evaluation, bridge]
  55. end
  56. 1 def make_matrix(bridges)
  57. 3 matrix = {}
  58. 3 bridges.each do |bridge|
  59. 8 year, overall_evaluation, bridge = matrix_item(bridge)
  60. 8 next if year.nil?
  61. 6 matrix[year] = {} if matrix[year].nil?
  62. 6 matrix[year][overall_evaluation] = [] if matrix[year][overall_evaluation].nil?
  63. 6 matrix[year][overall_evaluation] << bridge
  64. end
  65. 3 matrix
  66. end
  67. 1 def make_kind_of_bridge_chart(year_in_services)
  68. 1 start_year = year_in_services[0]
  69. 1 end_year = year_in_services[-1]
  70. 1 values = init_kind_of_bridge_chart(start_year, end_year)
  71. 1 year_in_services.each do |year_in_service|
  72. 2 targets = Bridge.jsonb_contains(year_in_service: year_in_service)
  73. 2 targets.each do |bridge|
  74. 2 values[year_in_service][Bridge.kind_of_bridge_types.invert[bridge.kind_of_bridge].to_s] += 1
  75. end
  76. end
  77. 1 values
  78. end
  79. 1 def init_kind_of_bridge_chart(start_year, end_year)
  80. 1 values = {}
  81. 1 Range.new(start_year, end_year).each do |year|
  82. 32 sub_values = {}
  83. 32 Bridge.kind_of_bridge_types.each do |k, _|
  84. 128 sub_values[k.to_s] = 0
  85. end
  86. 32 values[year] = sub_values
  87. end
  88. 1 values
  89. end
  90. end
  91. end

app/models/diagnosis.rb

100.0% lines covered

15 relevant lines. 15 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Injury model
  3. 1 class Diagnosis < ApplicationRecord
  4. 1 include AttrJson::Record
  5. 1 attr_json_config(default_container_attribute: :other_data)
  6. 1 belongs_to :regular_inspection
  7. 1 belongs_to :injury, optional: true
  8. 1 validates :component_category, presence: true, uniqueness: { scope: [:regular_inspection] }
  9. 1 validates :result, presence: true
  10. 1 validates :injury, presence: true, if: :need_injury?
  11. 1 validates_with SameComponentCategoryValidator
  12. 1 enum diagnosis_result: {
  13. unselected: 0,
  14. one: 1,
  15. two: 2,
  16. three: 3,
  17. four: 4
  18. }
  19. 1 private
  20. 1 def need_injury?
  21. 36 if result == 2 || result == 3
  22. 8 true
  23. else
  24. 28 false
  25. end
  26. end
  27. end

app/models/game_tile.rb

100.0% lines covered

64 relevant lines. 64 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'fileutils'
  3. 1 require 'tmpdir'
  4. 1 require 'tempfile'
  5. # GameTile class
  6. 1 class GameTile
  7. 1 attr_accessor :file, :tile_dir, :base_zoom, :width, :height
  8. 1 TILE_SIZE = 256
  9. 1 def initialize(file, tile_dir)
  10. 4 self.file = file
  11. 4 self.tile_dir = tile_dir
  12. end
  13. 1 def make
  14. 4 zoom_range, base_zoom = zooms
  15. 4 self.base_zoom = base_zoom
  16. 4 zoom_range.each do |zoom|
  17. 12 make_tile(zoom)
  18. end
  19. 4 zoom_range
  20. end
  21. 1 private
  22. 1 def zooms
  23. 4 self.width = `identify -ping -format "%w" #{file}`.to_i
  24. 4 self.height = `identify -ping -format "%h" #{file}`.to_i
  25. 4 base = width > height ? width : height
  26. 4 max_zoom = (Math.log(base) / Math.log(2)).ceil
  27. 4 min_zoom = 8
  28. 4 [min_zoom..(max_zoom + 1), max_zoom]
  29. end
  30. 1 def calculate_params(zoom)
  31. 12 scale = (2**(zoom - base_zoom)).to_f
  32. 12 width = (self.width * scale).to_i
  33. 12 height = (self.height * scale).to_i
  34. 12 tiles_per_column = (width.to_f / TILE_SIZE).ceil
  35. 12 tiles_per_row = (height.to_f / TILE_SIZE).ceil
  36. 12 [scale, tiles_per_column, tiles_per_row]
  37. end
  38. 1 def make_marge_file(scale, tiles_per_column, tiles_per_row)
  39. # make resize image
  40. 12 tmp = Tempfile.new(['tmp', '.png'])
  41. 12 tmp.close
  42. 12 `vips resize #{file} #{tmp.path} #{scale}`
  43. # make background image
  44. 12 bg_width = tiles_per_column * TILE_SIZE
  45. 12 bg_height = tiles_per_row * TILE_SIZE
  46. 12 bg_file = Tempfile.new(['bg', '.png'])
  47. 12 bg_file.close
  48. 12 `vips black #{bg_file.path} #{bg_width} #{bg_height}`
  49. # make marge image
  50. 12 merge_file = Tempfile.new(['merge', '.png'])
  51. 12 merge_file.close
  52. 12 `vips insert #{bg_file.path} #{tmp.path} #{merge_file.path} 0 0`
  53. 12 tmp.delete
  54. 12 bg_file.delete
  55. 12 merge_file
  56. end
  57. 1 def crap_images(working_dir, zoom, merge_file)
  58. 12 vips_opts = "--suffix .png --tile-size 256 --basename image_#{zoom} --depth one --overlap 0 --background 0"
  59. 12 `vips dzsave #{merge_file.path} #{working_dir}/image #{vips_opts}`
  60. 12 merge_file.delete
  61. end
  62. 1 def generate_tiles(working_dir, zoom)
  63. 12 search_file = File.join(working_dir, "image_#{zoom}_files", '0', '*.png')
  64. 12 total_tiles = Dir[search_file]
  65. 12 total_tiles.each do |file_path|
  66. 40 base_name = File.basename(file_path, '.png')
  67. 40 target = File.join(tile_dir, zoom.to_s, "#{base_name}.png")
  68. 40 `cp -f #{file_path} #{target}`
  69. end
  70. end
  71. 1 def make_tile(zoom)
  72. 12 scale, tiles_per_column, tiles_per_row = calculate_params(zoom)
  73. 12 output_dir = File.join(tile_dir, zoom.to_s)
  74. 12 FileUtils.mkdir_p(output_dir) unless File.exist?(output_dir)
  75. 12 Dir.mktmpdir do |working_dir|
  76. 12 merge_file = make_marge_file(scale, tiles_per_column, tiles_per_row)
  77. 12 crap_images(working_dir, zoom, merge_file)
  78. 12 generate_tiles(working_dir, zoom)
  79. end
  80. end
  81. end

app/models/injury.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Injury model
  3. 1 class Injury < ApplicationRecord
  4. 1 include AttrJson::Record
  5. 1 attr_json_config(default_container_attribute: :other_data)
  6. 1 belongs_to :regular_inspection
  7. 1 belongs_to :component
  8. 1 has_many :bridge_content_injuries
  9. 1 enum grade: {
  10. unselected: 0,
  11. a: 1,
  12. b: 2,
  13. c: 3,
  14. d: 4,
  15. e: 5
  16. }
  17. 1 def show_name
  18. 4 I18n.t("enums.component.category.#{Component.categories.invert[component.component_category]}") +
  19. " #{injury_type} #{injury_grade}"
  20. end
  21. # 定量的に取得した値
  22. 1 attr_json :quantitatively_obtained_value, :string
  23. # 単位
  24. 1 attr_json :unit, :string
  25. # 損傷パターン
  26. 1 attr_json :injury_pattern, :string
  27. # 分類
  28. 1 attr_json :classification, :string
  29. # 所見
  30. 1 attr_json :impression, :string
  31. end

app/models/mlit_importer.rb

100.0% lines covered

23 relevant lines. 23 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Mlit Importer class
  3. 1 class MlitImporter
  4. # for human_attribute_name
  5. 1 include ActiveModel::Model
  6. 1 attr_accessor :upload_file
  7. 1 class << self
  8. 1 def import(file)
  9. 8 import_from_excel_file(file)
  10. end
  11. 1 private
  12. 1 def import_from_excel_file(file)
  13. 8 xlsx = Roo::Spreadsheet.open(file)
  14. 8 bridge = Bridge.new
  15. # read first sheet
  16. 8 sheet = xlsx.sheet(0)
  17. 8 title = sheet.cell(6, 1)
  18. 8 bridge.title = title
  19. 8 address = sheet.cell(6, 6)
  20. 8 bridge.address = address
  21. 8 latitude_string = sheet.cell(4, 11)
  22. 8 longitude_string = sheet.cell(5, 11)
  23. 8 latitude = LocationImplement.sexagesimal_to_float(latitude_string)
  24. 8 longitude = LocationImplement.sexagesimal_to_float(longitude_string)
  25. 8 bridge.location = "POINT(#{longitude} #{latitude})"
  26. 8 road_name = sheet.cell(6, 4)
  27. 8 bridge.road_name = road_name
  28. 8 bridge
  29. end
  30. end
  31. end

app/models/regular_inspection.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # RegularInspection class
  3. 1 class RegularInspection < ApplicationRecord
  4. 1 include AttrJson::Record
  5. 1 attr_json_config(default_container_attribute: :other_data)
  6. 1 belongs_to :bridge
  7. 1 has_many :bridge_contents
  8. 1 has_many :injuries
  9. 1 has_many :diagnoses
  10. 1 validates :bridge, presence: true
  11. 1 validates :title, presence: true
  12. # 点検担当者
  13. 1 attr_json :person_responsible, :string
  14. # 定期点検実施年月日
  15. 1 attr_json :periodic_inspection_date, :date
  16. # 調書更新年月日
  17. 1 attr_json :record_updated_date, :date
  18. # 開始日
  19. 1 attr_json :start_date, :date
  20. # 終了日
  21. 1 attr_json :end_date, :date
  22. end

app/models/soundness.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Soundness Model
  3. 1 class Soundness < ApplicationRecord
  4. 1 belongs_to :bridge
  5. 1 validates :evaluation, presence: true
  6. 1 validates :evaluation_at, presence: true
  7. 1 enum overall_evaluation: {
  8. unselected: 0,
  9. one: 1,
  10. two: 2,
  11. three: 3,
  12. four: 4
  13. }
  14. end

app/models/user.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # User model
  3. 1 class User < ApplicationRecord
  4. 1 include UserImplement
  5. 1 has_secure_password
  6. 1 validates :login_name, presence: true, uniqueness: true
  7. 1 validates :password_digest, presence: true
  8. 1 validates :password,
  9. length: { minimum: 8, if: :validate_password? },
  10. confirmation: { if: :validate_password? }
  11. 1 validates :password,
  12. format: {
  13. with: /\A(?=.*?[a-z])(?=.*?\d)[a-z\d]{2,100}\z/i,
  14. message: I18n.t('errors.attributes.password.invalid'),
  15. if: :validate_password?
  16. }, confirmation: { if: :validate_password? }
  17. end

app/validators/bridge_content_injury_same_origin_validator.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # BridgeContentInjurySameOriginValidator
  3. 1 class BridgeContentInjurySameOriginValidator < ActiveModel::Validator
  4. 1 def validate(record)
  5. 26 return unless record.injury && record.bridge_content
  6. 23 return if record.injury.regular_inspection == record.bridge_content.regular_inspection
  7. 1 record.errors.add :injury_id, :is_not_same_origin
  8. end
  9. end

app/validators/same_component_category_validator.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # SameComponentCategoryValidator
  3. 1 class SameComponentCategoryValidator < ActiveModel::Validator
  4. 1 def validate(record)
  5. 36 return if record.injury.nil?
  6. 15 return if record.injury.component.component_category == record.component_category
  7. 1 record.errors.add :injury_id, :injury_component_category_is_not_same
  8. end
  9. end

config/application.rb

100.0% lines covered

23 relevant lines. 23 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require_relative 'boot'
  3. 1 require 'rails'
  4. # Pick the frameworks you want:
  5. 1 require 'active_model/railtie'
  6. 1 require 'active_job/railtie'
  7. 1 require 'active_record/railtie'
  8. 1 require 'active_storage/engine'
  9. 1 require 'action_controller/railtie'
  10. 1 require 'action_mailer/railtie'
  11. 1 require 'action_mailbox/engine'
  12. 1 require 'action_text/engine'
  13. 1 require 'action_view/railtie'
  14. 1 require 'action_cable/engine'
  15. 1 require 'sprockets/railtie'
  16. # require "rails/test_unit/railtie"
  17. # Require the gems listed in Gemfile, including any gems
  18. # you've limited to :test, :development, or :production.
  19. 1 Bundler.require(*Rails.groups)
  20. 1 module Ha4db
  21. # Our Application
  22. 1 class Application < Rails::Application
  23. 1 config.i18n.default_locale = :ja
  24. # Initialize configuration defaults for originally generated Rails version.
  25. 1 config.load_defaults 6.0
  26. # Settings in config/environments/* take precedence over those specified here.
  27. # Application configuration can go into files in config/initializers
  28. # -- all .rb files in that directory are automatically loaded after loading
  29. # the framework and any gems in your application.
  30. # Don't generate system test files.
  31. 1 config.generators.system_tests = nil
  32. # For material components for web
  33. 1 config.action_view.field_error_proc = proc do |html_tag, _|
  34. 17 html_tag.html_safe
  35. end
  36. # active job
  37. 1 config.active_job.queue_adapter = :sidekiq
  38. # use vips
  39. 1 config.active_storage.variant_processor = :vips
  40. end
  41. end

config/boot.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
  3. 1 require 'bundler/setup' # Set up gems listed in the Gemfile.
  4. 1 require 'bootsnap/setup' # Speed up boot time by caching expensive operations.

config/environment.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Load the Rails application.
  3. 1 require_relative 'application'
  4. # Initialize the Rails application.
  5. 1 Rails.application.initialize!

config/environments/test.rb

100.0% lines covered

15 relevant lines. 15 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # The test environment is used exclusively to run your application's
  3. # test suite. You never need to work with it otherwise. Remember that
  4. # your test database is "scratch space" for the test suite and is wiped
  5. # and recreated between test runs. Don't rely on the data there!
  6. 1 Rails.application.configure do
  7. # Settings specified here will take precedence over those in config/application.rb.
  8. 1 config.cache_classes = false
  9. 1 config.action_view.cache_template_loading = true
  10. # Do not eager load code on boot. This avoids loading your whole application
  11. # just for the purpose of running a single test. If you are using a tool that
  12. # preloads Rails for running tests, you may have to set it to true.
  13. 1 config.eager_load = false
  14. # Configure public file server for tests with Cache-Control for performance.
  15. 1 config.public_file_server.enabled = true
  16. 1 config.public_file_server.headers = {
  17. 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
  18. }
  19. # Show full error reports and disable caching.
  20. 1 config.consider_all_requests_local = true
  21. 1 config.action_controller.perform_caching = false
  22. 1 config.cache_store = :null_store
  23. # Raise exceptions instead of rendering exception templates.
  24. 1 config.action_dispatch.show_exceptions = false
  25. # Disable request forgery protection in test environment.
  26. 1 config.action_controller.allow_forgery_protection = false
  27. # Store uploaded files on the local file system in a temporary directory.
  28. 1 config.active_storage.service = :test
  29. 1 config.action_mailer.perform_caching = false
  30. # Tell Action Mailer not to deliver emails to the real world.
  31. # The :test delivery method accumulates sent emails in the
  32. # ActionMailer::Base.deliveries array.
  33. 1 config.action_mailer.delivery_method = :test
  34. # Print deprecation notices to the stderr.
  35. 1 config.active_support.deprecation = :stderr
  36. # Raises error for missing translations.
  37. # config.action_view.raise_on_missing_translations = true
  38. end

config/initializers/application_controller_renderer.rb

100.0% lines covered

0 relevant lines. 0 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # ActiveSupport::Reloader.to_prepare do
  4. # ApplicationController.renderer.defaults.merge!(
  5. # http_host: 'example.org',
  6. # https: false
  7. # )
  8. # end

config/initializers/assets.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # Version of your assets, change this if you want to expire all your assets.
  4. 1 Rails.application.config.assets.version = '1.0'
  5. # Add additional assets to the asset load path.
  6. # Rails.application.config.assets.paths << Emoji.images_path
  7. # Add Yarn node_modules folder to the asset load path.
  8. 1 Rails.application.config.assets.paths << Rails.root.join('node_modules')
  9. # Precompile additional assets.
  10. # application.js, application.css, and all non-JS/CSS in the app/assets
  11. # folder are already added.
  12. # Rails.application.config.assets.precompile += %w( admin.js admin.css )

config/initializers/backtrace_silencers.rb

100.0% lines covered

0 relevant lines. 0 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
  4. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
  5. # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
  6. # Rails.backtrace_cleaner.remove_silencers!

config/initializers/content_security_policy.rb

100.0% lines covered

0 relevant lines. 0 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # Define an application-wide content security policy
  4. # For further information see the following documentation
  5. # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
  6. # Rails.application.config.content_security_policy do |policy|
  7. # policy.default_src :self, :https
  8. # policy.font_src :self, :https, :data
  9. # policy.img_src :self, :https, :data
  10. # policy.object_src :none
  11. # policy.script_src :self, :https
  12. # policy.style_src :self, :https
  13. # # If you are using webpack-dev-server then specify webpack-dev-server host
  14. # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
  15. # # Specify URI for violation reports
  16. # # policy.report_uri "/csp-violation-report-endpoint"
  17. # end
  18. # If you are using UJS then enable automatic nonce generation
  19. # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
  20. # Set the nonce only to specific directives
  21. # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
  22. # Report CSP violations to a specified URI
  23. # For further information see the following documentation:
  24. # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
  25. # Rails.application.config.content_security_policy_report_only = true

config/initializers/cookies_serializer.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # Specify a serializer for the signed and encrypted cookie jars.
  4. # Valid options are :json, :marshal, and :hybrid.
  5. 1 Rails.application.config.action_dispatch.cookies_serializer = :json

config/initializers/filter_parameter_logging.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # Configure sensitive parameters which will be filtered from the log file.
  4. 1 Rails.application.config.filter_parameters += [:password]

config/initializers/inflections.rb

100.0% lines covered

0 relevant lines. 0 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # Add new inflection rules using the following format. Inflections
  4. # are locale specific, and you may define rules for as many different
  5. # locales as you wish. All of these examples are active by default:
  6. # ActiveSupport::Inflector.inflections(:en) do |inflect|
  7. # inflect.plural /^(ox)$/i, '\1en'
  8. # inflect.singular /^(ox)en/i, '\1'
  9. # inflect.irregular 'person', 'people'
  10. # inflect.uncountable %w( fish sheep )
  11. # end
  12. # These inflection rules are supported but not enabled by default:
  13. # ActiveSupport::Inflector.inflections(:en) do |inflect|
  14. # inflect.acronym 'RESTful'
  15. # end

config/initializers/mime_types.rb

100.0% lines covered

0 relevant lines. 0 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # Add new mime types for use in respond_to blocks:
  4. # Mime::Type.register "text/richtext", :rtf

config/initializers/wrap_parameters.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Be sure to restart your server when you modify this file.
  3. # This file contains settings for ActionController::ParamsWrapper which
  4. # is enabled by default.
  5. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
  6. 1 ActiveSupport.on_load(:action_controller) do
  7. 2 wrap_parameters format: [:json]
  8. end
  9. # To enable root element in JSON for ActiveRecord objects.
  10. # ActiveSupport.on_load(:active_record) do
  11. # self.include_root_in_json = true
  12. # end

config/routes.rb

100.0% lines covered

28 relevant lines. 28 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # rubocop:disable Metrics/BlockLength
  3. 1 Rails.application.routes.draw do
  4. 1 resources :regular_inspections do
  5. 1 resources :bridge_contents
  6. 1 resources :injuries do
  7. 1 resources :bridge_content_injuries
  8. end
  9. 1 resources :diagnoses
  10. 1 resources :bridge_main_contents, only: %i[create destroy]
  11. 1 get 'download_image_metadata'
  12. 1 get 'download_pointcloud_metadata'
  13. end
  14. 1 resource :mlit_importer, only: %i[new create] do
  15. 1 post 'preview'
  16. end
  17. 1 resources :bridges do
  18. 1 resources :components
  19. 1 resources :soundnesses
  20. end
  21. # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
  22. 1 root to: 'top#index'
  23. 1 get 'top/index'
  24. 1 get 'sessions/index'
  25. 1 post 'sessions/login'
  26. 1 get 'sessions/logout'
  27. # admin
  28. 1 namespace :admin do
  29. 1 get 'sessions/index'
  30. 1 post 'sessions/login'
  31. 1 get 'sessions/logout'
  32. 1 get 'top/index'
  33. 1 resources :users
  34. end
  35. 1 get 'status', to: 'status#index', format: :json
  36. # sidekiq
  37. 1 require 'sidekiq/web'
  38. 1 mount Sidekiq::Web => '/sidekiq'
  39. end
  40. # rubocop:enable Metrics/BlockLength

spec/factories/admin_users.rb

100.0% lines covered

4 relevant lines. 4 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 FactoryBot.define do
  3. 1 factory :admin_user do
  4. 35 login_name { Faker::Internet.user_name }
  5. 34 password { 'passw0rd' }
  6. end
  7. end

spec/factories/bridge_content_injuries.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 FactoryBot.define do
  3. 1 factory :bridge_content_injury do
  4. 1 bridge_content
  5. 1 injury
  6. 25 seek { 0 }
  7. end
  8. end

spec/factories/bridge_contents.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # BridgeContent Factorybot
  3. 1 FactoryBot.define do
  4. 1 factory :bridge_content do
  5. 1 regular_inspection
  6. 67 component { nil }
  7. 67 sequence(:title) { |i| "Bridge Contents #{i}" }
  8. 1 after(:build) do |bridge_content|
  9. 66 bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testimage.jpg'))
  10. end
  11. end
  12. end

spec/factories/bridge_main_contents.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 FactoryBot.define do
  3. 1 factory :bridge_main_content do
  4. 1 bridge_content
  5. end
  6. end

spec/factories/bridges.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 FactoryBot.define do
  3. 1 factory :bridge do
  4. 269 sequence(:title) { |i| "Bridge #{i}" }
  5. 269 location { 'POINT(139.895697 35.325315)' }
  6. 269 sequence(:address) { |i| "Address #{i}" }
  7. 269 bridge_length { 10 }
  8. 269 width { 4.4 }
  9. end
  10. end

spec/factories/components.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 FactoryBot.define do
  3. 1 factory :component do
  4. 1 bridge
  5. 90 sequence(:title) { |i| "title #{i}" }
  6. 90 span_number { 1 }
  7. 89 component_category { Component.categories[:superstructure_main_girder] }
  8. end
  9. end

spec/factories/diagnoses.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 FactoryBot.define do
  3. 1 factory :diagnosis do
  4. 1 regular_inspection
  5. 31 component_category { Component.categories[:superstructure_main_girder] }
  6. 32 result { Diagnosis.diagnosis_results[:one] }
  7. 16 injury { nil }
  8. 32 sequence(:remark) { |i| "remark #{i}" }
  9. end
  10. end

spec/factories/injuries.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 FactoryBot.define do
  3. 1 factory :injury do
  4. 1 regular_inspection
  5. 1 component
  6. 67 sequence(:injury_type) { |i| "Injury type #{i}" }
  7. 67 injury_grade { Injury.grades[:a] }
  8. end
  9. end

spec/factories/regular_inspections.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # RegularInspection Factorybot
  3. 1 FactoryBot.define do
  4. 1 factory :regular_inspection do
  5. 1 bridge
  6. 148 sequence(:title) { |i| "Inspection #{i}" }
  7. 150 sequence(:person_responsible) { |i| "Person responsible #{i}" }
  8. 150 periodic_inspection_date { Faker::Date.backward(days: 14) }
  9. 150 record_updated_date { Faker::Date.backward(days: 14) }
  10. 150 start_date { Faker::Date.backward(days: 20) }
  11. 150 end_date { Faker::Date.backward(days: 10) }
  12. end
  13. end

spec/factories/soundnesses.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. # Soundness Factorybot
  3. 1 FactoryBot.define do
  4. 1 factory :soundness do
  5. 1 bridge
  6. 46 sequence(:evaluation) { |i| "Soundness evaluation #{i}" }
  7. 27 evaluation_at { Faker::Date.backward(days: 14) }
  8. 27 overall_evaluation { Soundness.overall_evaluations[:one] }
  9. end
  10. end

spec/factories/users.rb

100.0% lines covered

4 relevant lines. 4 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 FactoryBot.define do
  3. 1 factory :user do
  4. 143 login_name { Faker::Internet.user_name }
  5. 142 password { 'passw0rd' }
  6. end
  7. end

spec/helpers/application_helper_spec.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # Specs in this file have access to a helper object that includes
  4. # the ApplicationHelper. For example:
  5. #
  6. # describe ApplicationHelper do
  7. # describe "string concat" do
  8. # it "concats two strings with spaces" do
  9. # expect(helper.concat_strings("this","that")).to eq("this that")
  10. # end
  11. # end
  12. # end
  13. 1 RSpec.describe ApplicationHelper, type: :helper do
  14. end

spec/jobs/game_tile_job_spec.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe GameTileJob, type: :job do
  4. 1 describe 'create' do
  5. 1 before do
  6. 2 @bridge_content = FactoryBot.create(:bridge_content,
  7. data: Rails.root.join('spec', 'testdata', 'ortho_image.png'),
  8. data_type: BridgeContent.data_types[:ortho])
  9. 2 GameTileJob.perform_now(@bridge_content.id)
  10. end
  11. 1 it '8/0_0.png' do
  12. 1 expect(Dir).to exist(File.join('/tmp', 'ortho_images', @bridge_content.id.to_s, '8'))
  13. 1 check_file = File.join('/tmp', 'ortho_images', @bridge_content.id.to_s, '8/0_0.png')
  14. 1 expect(File).to exist(check_file)
  15. end
  16. 1 it 'metadata' do
  17. 1 @bridge_content.reload
  18. 1 expect(@bridge_content.ortho_tile_info['min_zoom']).to eq(8)
  19. 1 expect(@bridge_content.ortho_tile_info['max_zoom']).to eq(10)
  20. end
  21. end
  22. end

spec/models/admin_user_spec.rb

100.0% lines covered

52 relevant lines. 52 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe AdminUser, type: :model do
  5. 1 before do
  6. 16 @admin_user = FactoryBot.build(:admin_user)
  7. end
  8. 14 subject { @admin_user }
  9. 2 it { should respond_to(:login_name) }
  10. 2 it { should respond_to(:password_digest) }
  11. 2 it { should respond_to(:password) }
  12. 2 it { should respond_to(:password_confirmation) }
  13. 2 it { should respond_to(:authenticate) }
  14. 2 it { should be_valid }
  15. 1 describe 'when login_name is not present' do
  16. 2 before { @admin_user.login_name = ' ' }
  17. 2 it { should_not be_valid }
  18. end
  19. 1 describe 'when login_name is already taken' do
  20. 1 before do
  21. 1 with_same_login_name = @admin_user.dup
  22. 1 with_same_login_name.save
  23. end
  24. 2 it { should_not be_valid }
  25. end
  26. 1 describe 'when password is not present' do
  27. 1 before do
  28. 1 @admin_user = FactoryBot.build(:admin_user, password: '', password_confirmation: '')
  29. end
  30. 2 it { should_not be_valid }
  31. end
  32. 1 describe "when password doesn't match confirmation" do
  33. 2 before { @admin_user.password_confirmation = 'mismatch' }
  34. 2 it { should_not be_valid }
  35. end
  36. 1 describe "with a password that's too short" do
  37. 2 before { @admin_user.password = @admin_user.password_confirmation = 'aaaaaa1' }
  38. 2 it { should_not be_valid }
  39. end
  40. 1 describe 'return value of authenticate method' do
  41. 4 before { @admin_user.save }
  42. 4 let(:found_admin) { AdminUser.find_by(login_name: @admin_user.login_name) }
  43. 1 describe 'with valid password' do
  44. 2 it { should eq found_admin.authenticate(@admin_user.password) }
  45. end
  46. 1 describe 'with invalid password' do
  47. 3 let(:admin_for_invalid_password) { found_admin.authenticate('invalid') }
  48. 2 it { should_not eq admin_for_invalid_password }
  49. 2 specify { expect(admin_for_invalid_password).to be_falsey }
  50. end
  51. end
  52. 1 describe 'when password format is invalid' do
  53. 1 it 'should be invalid' do
  54. 1 passwords = %w[a*8 11111111 abcd_1234]
  55. 1 passwords.each do |invalid_password|
  56. 3 @admin_user.password = @admin_user.password_confirmation = invalid_password
  57. 3 expect(@admin_user).not_to be_valid
  58. end
  59. 1 @admin_user.password = @admin_user.password_confirmation = 'abcd 1234'
  60. 1 expect(@admin_user).not_to be_valid
  61. end
  62. end
  63. 1 describe 'when password format is valid' do
  64. 1 it 'should be valid' do
  65. 1 passwords = %w[abcd1234 AbcdEFG1 1234567A]
  66. 1 passwords.each do |valid_password|
  67. 3 @admin_user.password = @admin_user.password_confirmation = valid_password
  68. 3 expect(@admin_user).to be_valid
  69. end
  70. end
  71. end
  72. end
  73. # rubocop:enable Metrics/BlockLength

spec/models/bridge_content_injury_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe BridgeContentInjury, type: :model do
  4. 1 before do
  5. 5 regular_inspection = FactoryBot.create(:regular_inspection)
  6. 5 injury = FactoryBot.create(:injury, regular_inspection: regular_inspection)
  7. 5 bridge_content = FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
  8. 5 @bridge_content_injury = FactoryBot.create(:bridge_content_injury, bridge_content: bridge_content, injury: injury)
  9. end
  10. 6 subject { @bridge_content_injury }
  11. 2 it { should respond_to(:injury) }
  12. 2 it { should respond_to(:bridge_content) }
  13. 2 it { should respond_to(:seek) }
  14. 2 it { should be_valid }
  15. 1 describe 'when result to two, it to be invalid' do
  16. 1 before do
  17. 1 @bridge_content_injury.injury = FactoryBot.create(:injury)
  18. end
  19. 2 it { should_not be_valid }
  20. end
  21. end

spec/models/bridge_content_spec.rb

100.0% lines covered

49 relevant lines. 49 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe BridgeContent, type: :model do
  5. 1 before do
  6. 13 @bridge_content = FactoryBot.build(:bridge_content)
  7. end
  8. 7 subject { @bridge_content }
  9. 2 it { should respond_to(:title) }
  10. 2 it { should respond_to(:data) }
  11. 2 it { should respond_to(:regular_inspection) }
  12. 2 it { should respond_to(:component) }
  13. 2 it { should be_valid }
  14. 1 describe 'when title is not present' do
  15. 2 before { @bridge_content.title = ' ' }
  16. 2 it { should_not be_valid }
  17. end
  18. 1 describe 'bridge_content.data.content_type is image/jpeg' do
  19. 2 subject { @bridge_content.data.content_type }
  20. 2 it { should eq('image/jpeg') }
  21. end
  22. 1 describe 'bridge_content.data.content_type is image/png' do
  23. 1 before do
  24. 1 @bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testimage.png'))
  25. end
  26. 2 subject { @bridge_content.data.content_type }
  27. 2 it { should eq('image/png') }
  28. end
  29. 1 describe 'bridge_content.data.content_type is image/png' do
  30. 1 before do
  31. 1 @bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testmovie.mp4'))
  32. end
  33. 2 subject { @bridge_content.data.content_type }
  34. 2 it { should eq('video/mp4') }
  35. end
  36. 1 describe 'bridge_content.data_type to ortho' do
  37. 1 before do
  38. 1 @bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'ortho_image.png'))
  39. 1 @bridge_content.data_type = BridgeContent.data_types[:ortho]
  40. 1 perform_enqueued_jobs do
  41. 1 @bridge_content.save
  42. end
  43. end
  44. 1 it 'create new tiles' do
  45. 1 check_file = File.join('/tmp', 'ortho_images', @bridge_content.id.to_s, '8/0_0.png')
  46. 1 expect(File).to exist(check_file)
  47. end
  48. end
  49. 1 describe 'image/jpeg with exif' do
  50. 1 before do
  51. 1 @bridge_content.data = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testexif.jpg'))
  52. 1 @bridge_content.data_type = BridgeContent.data_types[:image]
  53. 1 @bridge_content.save
  54. end
  55. 1 it 'date_of_shooting will be update' do
  56. 1 expect(@bridge_content.date_of_shooting).to eq('2008/07/31 15:56:49')
  57. end
  58. end
  59. 1 describe 'main_content?' do
  60. 1 it 'default is false' do
  61. 1 expect(@bridge_content.main_content?).to eq(false)
  62. end
  63. 1 it 'if have main_content, to be true' do
  64. 1 bridge_main_content = FactoryBot.create(:bridge_main_content, bridge_content: @bridge_content)
  65. 1 @bridge_content.bridge_main_content = bridge_main_content
  66. 1 expect(@bridge_content.main_content?).to eq(true)
  67. end
  68. end
  69. end
  70. # rubocop:enable Metrics/BlockLength

spec/models/bridge_main_content_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe BridgeMainContent, type: :model do
  4. 1 before do
  5. 2 @bridge_main_content = FactoryBot.build(:bridge_main_content)
  6. end
  7. 3 subject { @bridge_main_content }
  8. 2 it { should respond_to(:bridge_content) }
  9. 2 it { should be_valid }
  10. end

spec/models/bridge_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe Bridge, type: :model do
  5. 1 before do
  6. 14 @bridge = FactoryBot.build(:bridge)
  7. end
  8. 13 subject { @bridge }
  9. 2 it { should respond_to(:title) }
  10. 2 it { should respond_to(:address) }
  11. 2 it { should respond_to(:location) }
  12. 2 it { should respond_to(:soundnesses) }
  13. 2 it { should respond_to(:regular_inspections) }
  14. 2 it { should respond_to(:components) }
  15. 2 it { should respond_to(:bridge_length) }
  16. 2 it { should respond_to(:width) }
  17. 2 it { should be_valid }
  18. 1 describe 'when title is not present' do
  19. 2 before { @bridge.title = ' ' }
  20. 2 it { should_not be_valid }
  21. end
  22. 1 describe 'when address is not present' do
  23. 2 before { @bridge.address = ' ' }
  24. 2 it { should_not be_valid }
  25. end
  26. 1 describe 'when location is not present' do
  27. 2 before { @bridge.location = nil }
  28. 2 it { should_not be_valid }
  29. end
  30. 1 describe 'full_title function' do
  31. 1 describe 'without kana_title' do
  32. 2 before { @bridge.title = 'test' }
  33. 2 it { expect(@bridge.full_title).to eq('test') }
  34. end
  35. 1 describe 'with kana_title' do
  36. 1 before do
  37. 1 @bridge.title = 'test'
  38. 1 @bridge.kana_title = 'kana'
  39. end
  40. 2 it { expect(@bridge.full_title).to eq('test (kana)') }
  41. end
  42. end
  43. end
  44. # rubocop:enable Metrics/BlockLength

spec/models/component_spec.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe Component, type: :model do
  4. 1 before do
  5. 6 @bridge = FactoryBot.create(:bridge)
  6. 6 @component = FactoryBot.build(:component, bridge: @bridge)
  7. end
  8. 7 subject { @component }
  9. 2 it { should respond_to(:bridge) }
  10. 2 it { should respond_to(:title) }
  11. 2 it { should respond_to(:component_category) }
  12. 2 it { should respond_to(:show_name) }
  13. 2 it { should be_valid }
  14. 1 describe 'when bridge is not present' do
  15. 2 before { @component.bridge = nil }
  16. 2 it { should_not be_valid }
  17. end
  18. end

spec/models/concern/location_implement_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe LocationImplement do
  4. 1 describe 'sexagesimal_to_float' do
  5. 1 it 'value 35°37′37″ returns 35.62694444444445' do
  6. 1 expect(LocationImplement.sexagesimal_to_float('35°37′37″')).to eq(35.62694444444445)
  7. end
  8. end
  9. 1 describe 'float_to_sexagesimal' do
  10. 1 it 'value 35.62694444 returns 35°37′37″' do
  11. 1 expect(LocationImplement.float_to_sexagesimal(35.62694444)).to eq('35°37′37″')
  12. end
  13. end
  14. end

spec/models/dashboard_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe Dashboard, type: :model do
  5. 1 before do
  6. 6 @bridge1 = FactoryBot.create(:bridge, year_in_service: 1981, kind_of_bridge: 1)
  7. 6 @bridge2 = FactoryBot.create(:bridge)
  8. 6 @bridge3 = FactoryBot.create(:bridge)
  9. 6 @bridge4 = FactoryBot.create(:bridge, year_in_service: 2012, kind_of_bridge: 2)
  10. 6 FactoryBot.create(:soundness, bridge: @bridge1, evaluation_at: '2018/05/21', overall_evaluation: 'one')
  11. 6 FactoryBot.create(:soundness, bridge: @bridge2, evaluation_at: '2018/05/21', overall_evaluation: 'two')
  12. 6 FactoryBot.create(:soundness, bridge: @bridge3, evaluation_at: '2018/05/21', overall_evaluation: 'three')
  13. 6 @bridges = Bridge.includes(:soundnesses)
  14. end
  15. 1 describe 'matrix_item' do
  16. 1 context 'call matrix' do
  17. 1 it 'return values' do
  18. 1 result = Dashboard.matrix(@bridges)
  19. 1 expect(result['2018']).not_to eq(nil)
  20. 1 expect(result['2018']['one']).not_to eq(nil)
  21. 1 expect(result['2018']['one']).to eq([@bridge1])
  22. end
  23. 1 context 'with newer values' do
  24. 1 before do
  25. 1 FactoryBot.create(:soundness, bridge: @bridge1, evaluation_at: '2020/05/21', overall_evaluation: 'two')
  26. end
  27. 1 it 'return newer values' do
  28. 1 result = Dashboard.matrix(@bridges)
  29. 1 expect(result['2018']).not_to eq(nil)
  30. 1 expect(result['2018']['one']).to eq(nil)
  31. 1 expect(result['2020']).not_to eq(nil)
  32. 1 expect(result['2020']['two']).to eq([@bridge1])
  33. end
  34. end
  35. end
  36. end
  37. 1 describe 'sorted_overall_evaluations' do
  38. 1 it 'return sorted value' do
  39. 1 result = Dashboard.sorted_overall_evaluations
  40. 1 expect(result).to eq(%w[unselected four three two one])
  41. end
  42. end
  43. 1 describe 'soundness_chart' do
  44. 1 it 'return chart values' do
  45. 1 result = Dashboard.soundness_chart(@bridges)
  46. 1 expect(result['unselected']).to eq(1)
  47. 1 expect(result['one']).to eq(1)
  48. 1 expect(result['two']).to eq(1)
  49. 1 expect(result['three']).to eq(1)
  50. end
  51. end
  52. 1 describe 'priority_chart' do
  53. 1 it 'return priority values' do
  54. 1 result = Dashboard.priority_chart(@bridges)
  55. 1 expect(result['priority_unselected']).to eq(4)
  56. end
  57. end
  58. 1 describe 'kind_of_bridge_chart' do
  59. 1 it 'return kink_of_bridge values' do
  60. 1 result = Dashboard.kind_of_bridge_chart(@bridges)
  61. 1 expect(result[1981]['concrete']).to eq(1)
  62. end
  63. end
  64. end
  65. # rubocop:enable Metrics/BlockLength

spec/models/diagnosis_spec.rb

100.0% lines covered

37 relevant lines. 37 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe Diagnosis, type: :model do
  5. 1 before do
  6. 11 @bridge = FactoryBot.create(:bridge)
  7. 11 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
  8. 11 @diagnosis = FactoryBot.create(:diagnosis, regular_inspection: @regular_inspection)
  9. end
  10. 11 subject { @diagnosis }
  11. 2 it { should respond_to(:regular_inspection) }
  12. 2 it { should respond_to(:component_category) }
  13. 2 it { should respond_to(:result) }
  14. 2 it { should respond_to(:injury) }
  15. 2 it { should respond_to(:remark) }
  16. 2 it { should be_valid }
  17. 1 describe 'when result to two, it to be invalid' do
  18. 2 before { @diagnosis.result = Diagnosis.diagnosis_results[:two] }
  19. 2 it { should_not be_valid }
  20. end
  21. 1 describe 'when result to four, it to be valid' do
  22. 2 before { @diagnosis.result = Diagnosis.diagnosis_results[:four] }
  23. 2 it { should be_valid }
  24. end
  25. 1 describe 'when result to two with injury' do
  26. 3 before { @diagnosis.result = Diagnosis.diagnosis_results[:two] }
  27. 1 describe 'with same component_category' do
  28. 1 before do
  29. 1 injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection)
  30. 1 @diagnosis.injury = injury
  31. end
  32. 2 it { should be_valid }
  33. end
  34. 1 describe 'with other component_category' do
  35. 1 before do
  36. 1 component = FactoryBot.create(:component, bridge: @bridge, component_category: Component.categories[:other])
  37. 1 injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: component)
  38. 1 @diagnosis.injury = injury
  39. end
  40. 2 it { should_not be_valid }
  41. end
  42. end
  43. 1 describe 'when result to two with same component_category' do
  44. 1 before do
  45. 1 @new_diagnosis = FactoryBot.build(:diagnosis, regular_inspection: @regular_inspection)
  46. end
  47. 2 subject { @new_diagnosis }
  48. 2 it { should_not be_valid }
  49. end
  50. end
  51. # rubocop:enable Metrics/BlockLength

spec/models/game_tile_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 OUTPUT_PATH = '/tmp/out'
  4. 1 INPUT_FILE = Rails.root.join('spec', 'testdata', 'ortho_image.png')
  5. 1 RSpec.describe GameTile, type: :model do
  6. 1 describe 'make tile' do
  7. 1 before do
  8. 1 game_tile = GameTile.new(INPUT_FILE, OUTPUT_PATH)
  9. 1 @result = game_tile.make
  10. end
  11. 1 it 'generate tiles' do
  12. 1 check_file = File.join(OUTPUT_PATH, '8/0_0.png')
  13. 1 expect(File).to exist(check_file)
  14. 1 check_file = File.join(OUTPUT_PATH, '9/0_0.png')
  15. 1 expect(File).to exist(check_file)
  16. 1 check_file = File.join(OUTPUT_PATH, '9/0_1.png')
  17. 1 expect(File).to exist(check_file)
  18. 1 check_file = File.join(OUTPUT_PATH, '9/1_0.png')
  19. 1 expect(File).not_to exist(check_file)
  20. 1 expect(@result.first).to be(8)
  21. 1 expect(@result.last).to be(10)
  22. end
  23. end
  24. end

spec/models/injury_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe Injury, type: :model do
  4. 1 before do
  5. 7 @bridge = FactoryBot.create(:bridge)
  6. 7 @component = FactoryBot.create(:component, bridge: @bridge)
  7. 7 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
  8. 7 @injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: @component)
  9. end
  10. 8 subject { @injury }
  11. 2 it { should respond_to(:regular_inspection) }
  12. 2 it { should respond_to(:component) }
  13. 2 it { should respond_to(:injury_type) }
  14. 2 it { should respond_to(:injury_grade) }
  15. 2 it { should be_valid }
  16. 1 describe 'when regular_inspection is not present' do
  17. 2 before { @injury.regular_inspection = nil }
  18. 2 it { should_not be_valid }
  19. end
  20. 1 describe 'when component is not present' do
  21. 2 before { @injury.component = nil }
  22. 2 it { should_not be_valid }
  23. end
  24. end

spec/models/mlit_importer_spec.rb

100.0% lines covered

21 relevant lines. 21 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe MlitImporter, type: :model do
  4. 1 describe 'import' do
  5. 1 context 'with mlit-testdata-001.xlsx' do
  6. 1 it 'can read file' do
  7. 1 file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001.xlsx')
  8. 1 bridge = MlitImporter.import(file)
  9. 1 expect(bridge.title).to eq('テスト橋')
  10. 1 expect(bridge.address).to eq('千葉県千葉市若葉区テスト橋')
  11. 1 expect(bridge.location.latitude).to eq(35.62694444444445)
  12. 1 expect(bridge.location.longitude).to eq(140.16611111111112)
  13. 1 expect(bridge.valid?).to eq(true)
  14. end
  15. end
  16. 1 context 'with mlit-testdata-001-invalid.xlsx' do
  17. 1 it 'cannot read file' do
  18. 1 file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001-invalid.xlsx')
  19. 1 bridge = MlitImporter.import(file)
  20. 1 expect(bridge.title).to eq(nil)
  21. 1 expect(bridge.address).to eq('千葉県千葉市若葉区テスト橋')
  22. 1 expect(bridge.location.latitude).to eq(35.62694444444445)
  23. 1 expect(bridge.location.longitude).to eq(140.16611111111112)
  24. 1 expect(bridge.valid?).to eq(false)
  25. end
  26. end
  27. end
  28. end

spec/models/regular_inspection_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe RegularInspection, type: :model do
  4. 1 before do
  5. 9 @bridge = FactoryBot.create(:bridge)
  6. 9 @regular_inspection = FactoryBot.build(:regular_inspection, bridge: @bridge)
  7. end
  8. 10 subject { @regular_inspection }
  9. 2 it { should respond_to(:title) }
  10. 2 it { should respond_to(:person_responsible) }
  11. 2 it { should respond_to(:periodic_inspection_date) }
  12. 2 it { should respond_to(:record_updated_date) }
  13. 2 it { should respond_to(:start_date) }
  14. 2 it { should respond_to(:end_date) }
  15. 2 it { should be_valid }
  16. 1 describe 'when bridge is not present' do
  17. 2 before { @regular_inspection.bridge = nil }
  18. 2 it { should_not be_valid }
  19. end
  20. 1 describe 'when title is not present' do
  21. 2 before { @regular_inspection.title = ' ' }
  22. 2 it { should_not be_valid }
  23. end
  24. end

spec/models/soundness_spec.rb

100.0% lines covered

28 relevant lines. 28 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe Soundness, type: :model do
  5. 1 before do
  6. 9 @soundness = FactoryBot.build(:soundness)
  7. end
  8. 8 subject { @soundness }
  9. 2 it { should respond_to(:bridge) }
  10. 2 it { should respond_to(:evaluation) }
  11. 2 it { should respond_to(:evaluation_at) }
  12. 2 it { should respond_to(:overall_evaluation) }
  13. 2 it { should be_valid }
  14. 1 describe 'when evaluation is not present' do
  15. 2 before { @soundness.evaluation = ' ' }
  16. 2 it { should_not be_valid }
  17. end
  18. 1 describe 'when evaluation_at is not present' do
  19. 2 before { @soundness.evaluation_at = nil }
  20. 2 it { should_not be_valid }
  21. end
  22. 1 describe 'overall_evaluation' do
  23. 1 describe 'enable to change by integer' do
  24. 2 before { @soundness.overall_evaluation = 2 }
  25. 2 subject { @soundness.two? }
  26. 2 it { should eq(true) }
  27. end
  28. end
  29. 1 describe 'count' do
  30. 1 it 'up to 1' do
  31. 1 soundness = Soundness.new(bridge: FactoryBot.create(:bridge))
  32. 1 soundness.evaluation = 'test'
  33. 1 soundness.evaluation_at = '2020/10/15'
  34. 1 expect do
  35. 1 soundness.save
  36. end.to change(Soundness, :count).by(1)
  37. end
  38. end
  39. end
  40. # rubocop:enable Metrics/BlockLength

spec/models/user_spec.rb

100.0% lines covered

52 relevant lines. 52 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe User, type: :model do
  5. 1 before do
  6. 16 @user = FactoryBot.build(:user)
  7. end
  8. 14 subject { @user }
  9. 2 it { should respond_to(:login_name) }
  10. 2 it { should respond_to(:password_digest) }
  11. 2 it { should respond_to(:password) }
  12. 2 it { should respond_to(:password_confirmation) }
  13. 2 it { should respond_to(:authenticate) }
  14. 2 it { should be_valid }
  15. 1 describe 'when login_name is not present' do
  16. 2 before { @user.login_name = ' ' }
  17. 2 it { should_not be_valid }
  18. end
  19. 1 describe 'when login_name is already taken' do
  20. 1 before do
  21. 1 with_same_login_name = @user.dup
  22. 1 with_same_login_name.save
  23. end
  24. 2 it { should_not be_valid }
  25. end
  26. 1 describe 'when password is not present' do
  27. 1 before do
  28. 1 @user = FactoryBot.build(:user, password: '', password_confirmation: '')
  29. end
  30. 2 it { should_not be_valid }
  31. end
  32. 1 describe "when password doesn't match confirmation" do
  33. 2 before { @user.password_confirmation = 'mismatch' }
  34. 2 it { should_not be_valid }
  35. end
  36. 1 describe "with a password that's too short" do
  37. 2 before { @user.password = @user.password_confirmation = 'aaaaaa1' }
  38. 2 it { should_not be_valid }
  39. end
  40. 1 describe 'return value of authenticate method' do
  41. 4 before { @user.save }
  42. 4 let(:found_user) { User.find_by(login_name: @user.login_name) }
  43. 1 describe 'with valid password' do
  44. 2 it { should eq found_user.authenticate(@user.password) }
  45. end
  46. 1 describe 'with invalid password' do
  47. 3 let(:for_invalid_password) { found_user.authenticate('invalid') }
  48. 2 it { should_not eq for_invalid_password }
  49. 2 specify { expect(for_invalid_password).to be_falsey }
  50. end
  51. end
  52. 1 describe 'when password format is invalid' do
  53. 1 it 'should be invalid' do
  54. 1 passwords = %w[a*8 11111111 abcd_1234]
  55. 1 passwords.each do |invalid_password|
  56. 3 @user.password = @user.password_confirmation = invalid_password
  57. 3 expect(@user).not_to be_valid
  58. end
  59. 1 @user.password = @user.password_confirmation = 'abcd 1234'
  60. 1 expect(@user).not_to be_valid
  61. end
  62. end
  63. 1 describe 'when password format is valid' do
  64. 1 it 'should be valid' do
  65. 1 passwords = %w[abcd1234 AbcdEFG1 1234567A]
  66. 1 passwords.each do |valid_password|
  67. 3 @user.password = @user.password_confirmation = valid_password
  68. 3 expect(@user).to be_valid
  69. end
  70. end
  71. end
  72. end
  73. # rubocop:enable Metrics/BlockLength

spec/requests/admin/sessions_request_spec.rb

100.0% lines covered

21 relevant lines. 21 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'Admin::Sessions', type: :request do # rubocop:disable Metrics/BlockLength
  4. 1 describe 'GET /admin/sessions/index' do
  5. 1 it 'show index view' do
  6. 1 get admin_sessions_index_path
  7. 1 expect(response).to have_http_status(200)
  8. end
  9. end
  10. 1 describe 'POST /admin/sessions/login' do
  11. 1 before do
  12. 2 @admin_user = FactoryBot.create(:admin_user)
  13. end
  14. 1 it 'enable to login' do
  15. 1 post admin_sessions_login_path, params: {
  16. admin_user: {
  17. login_name: @admin_user.login_name,
  18. password: @admin_user.password
  19. }
  20. }
  21. 1 expect(response).to redirect_to admin_top_index_path
  22. end
  23. 1 it 'fail with invalid password' do
  24. 1 post admin_sessions_login_path, params: {
  25. admin_user: {
  26. login_name: @admin_user.login_name,
  27. password: 'pass0000'
  28. }
  29. }
  30. 1 expect(response).to have_http_status(200)
  31. 1 expect(response.body).to include 'password'
  32. 1 expect(response.body).to include @admin_user.login_name
  33. end
  34. end
  35. 1 describe 'POST /admin/sessions/logout' do
  36. 1 it 'enable to logout' do
  37. 1 get admin_sessions_logout_path
  38. 1 expect(response).to redirect_to admin_sessions_index_path
  39. end
  40. end
  41. end

spec/requests/admin/top_request_spec.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'Admin::Tops', type: :request do
  4. 1 before do
  5. 2 @admin_user = FactoryBot.create(:admin_user)
  6. 2 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ admin_user_id: @admin_user.id })
  7. end
  8. 1 describe 'GET /admin/top/index' do
  9. 1 it 'enable to access' do
  10. 1 get admin_top_index_path
  11. 1 expect(response).to have_http_status(200)
  12. end
  13. 1 it 'fail without login' do
  14. 1 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ admin_user_id: '' })
  15. 1 get admin_top_index_path
  16. 1 expect(response).to redirect_to admin_sessions_index_path
  17. end
  18. end
  19. end

spec/requests/admin/users_spec.rb

100.0% lines covered

72 relevant lines. 72 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/admin/users', type: :request do
  16. 1 before do
  17. 13 @admin_user = FactoryBot.create(:admin_user)
  18. 13 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ admin_user_id: @admin_user.id })
  19. end
  20. # Admin::User. As you add validations to Admin::User, be sure to
  21. # adjust the attributes here as well.
  22. 1 let(:valid_attributes) do
  23. 10 {
  24. login_name: 'user',
  25. password: 'passw0rd'
  26. }
  27. end
  28. 1 let(:invalid_attributes) do
  29. {
  30. 3 login_name: Faker::Internet.user_name,
  31. password: 'pass'
  32. }
  33. end
  34. 1 describe 'GET /index' do
  35. 1 it 'renders a successful response' do
  36. 1 User.create! valid_attributes
  37. 1 get admin_users_url
  38. 1 expect(response).to be_successful
  39. end
  40. end
  41. 1 describe 'GET /show' do
  42. 1 it 'renders a successful response' do
  43. 1 user = User.create! valid_attributes
  44. 1 get admin_user_url(user)
  45. 1 expect(response).to be_successful
  46. end
  47. end
  48. 1 describe 'GET /new' do
  49. 1 it 'renders a successful response' do
  50. 1 get new_admin_user_url
  51. 1 expect(response).to be_successful
  52. end
  53. end
  54. 1 describe 'GET /edit' do
  55. 1 it 'render a successful response' do
  56. 1 user = User.create! valid_attributes
  57. 1 get edit_admin_user_url(user)
  58. 1 expect(response).to be_successful
  59. end
  60. end
  61. 1 describe 'POST /create' do
  62. 1 context 'with valid parameters' do
  63. 1 it 'creates a new User' do
  64. 1 expect do
  65. 1 post admin_users_url, params: { user: valid_attributes }
  66. end.to change(User, :count).by(1)
  67. end
  68. 1 it 'redirects to the created admin_user' do
  69. 1 post admin_users_url, params: { user: valid_attributes }
  70. 1 user = User.last
  71. 1 expect(response).to redirect_to(admin_user_url(user))
  72. end
  73. end
  74. 1 context 'with invalid parameters' do
  75. 1 it 'does not create a new User' do
  76. 1 expect do
  77. 1 post admin_users_url, params: { user: invalid_attributes }
  78. end.to change(User, :count).by(0)
  79. end
  80. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  81. 1 post admin_users_url, params: { user: invalid_attributes }
  82. 1 expect(response).to be_successful
  83. end
  84. end
  85. end
  86. 1 describe 'PATCH /update' do
  87. 1 context 'with valid parameters' do
  88. 1 let(:new_attributes) do
  89. 2 {
  90. login_name: 'user1',
  91. password: 'passw0rd'
  92. }
  93. end
  94. 1 it 'updates the requested user' do
  95. 1 user = User.create! valid_attributes
  96. 1 patch admin_user_url(user), params: { user: new_attributes }
  97. 1 user.reload
  98. 1 expect(user.login_name).to eq 'user1'
  99. end
  100. 1 it 'redirects to the user' do
  101. 1 user = User.create! valid_attributes
  102. 1 patch admin_user_url(user), params: { user: new_attributes }
  103. 1 user.reload
  104. 1 expect(response).to redirect_to(admin_user_url(user))
  105. end
  106. end
  107. 1 context 'with invalid parameters' do
  108. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  109. 1 user = User.create! valid_attributes
  110. 1 patch admin_user_url(user), params: { user: invalid_attributes }
  111. 1 expect(response).to be_successful
  112. end
  113. end
  114. end
  115. 1 describe 'DELETE /destroy' do
  116. 1 it 'destroys the requested admin_user' do
  117. 1 user = User.create! valid_attributes
  118. 1 expect do
  119. 1 delete admin_user_url(user)
  120. end.to change(User, :count).by(-1)
  121. end
  122. 1 it 'redirects to the admin_users list' do
  123. 1 user = User.create! valid_attributes
  124. 1 delete admin_user_url(user)
  125. 1 expect(response).to redirect_to(admin_users_url)
  126. end
  127. end
  128. end
  129. # rubocop:enable Metrics/BlockLength

spec/requests/bridge_content_injuries_spec.rb

100.0% lines covered

82 relevant lines. 82 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/bridge_content_injuries', type: :request do
  16. 1 before do
  17. 13 @user = FactoryBot.create(:user)
  18. 13 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  19. 13 @bridge = FactoryBot.create(:bridge)
  20. 13 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
  21. 13 @component = FactoryBot.create(:component, bridge: @bridge)
  22. 13 @injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: @component)
  23. 13 @bridge_content = FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection)
  24. end
  25. # BridgeContentInjury. As you add validations to BridgeContentInjury, be sure to
  26. # adjust the attributes here as well.
  27. 1 let(:valid_attributes) do
  28. 10 FactoryBot.build(:bridge_content_injury, injury: @injury, bridge_content: @bridge_content).attributes
  29. end
  30. 1 let(:invalid_attributes) do
  31. 3 bridge_content_injury = FactoryBot.build(:bridge_content_injury, injury: @injury, bridge_content: @bridge_content)
  32. 3 bridge_content_injury.bridge_content = nil
  33. 3 bridge_content_injury.attributes
  34. end
  35. 1 describe 'GET /index' do
  36. 1 it 'renders a successful response' do
  37. 1 BridgeContentInjury.create! valid_attributes
  38. 1 get regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury)
  39. 1 expect(response).to be_successful
  40. end
  41. end
  42. 1 describe 'GET /show' do
  43. 1 it 'renders a successful response' do
  44. 1 bridge_content_injury = BridgeContentInjury.create! valid_attributes
  45. 1 get regular_inspection_injury_bridge_content_injury_url(@regular_inspection, @injury, bridge_content_injury)
  46. 1 expect(response).to be_successful
  47. end
  48. end
  49. 1 describe 'GET /new' do
  50. 1 it 'renders a successful response' do
  51. 1 get new_regular_inspection_injury_bridge_content_injury_url(@regular_inspection, @injury)
  52. 1 expect(response).to be_successful
  53. end
  54. end
  55. 1 describe 'GET /edit' do
  56. 1 it 'render a successful response' do
  57. 1 bridge_content_injury = BridgeContentInjury.create! valid_attributes
  58. 1 get edit_regular_inspection_injury_bridge_content_injury_url(@regular_inspection, @injury, bridge_content_injury)
  59. 1 expect(response).to be_successful
  60. end
  61. end
  62. 1 describe 'POST /create' do
  63. 1 context 'with valid parameters' do
  64. 1 it 'creates a new BridgeContentInjury' do
  65. 1 expect do
  66. 1 post regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
  67. params: { bridge_content_injury: valid_attributes }
  68. end.to change(BridgeContentInjury, :count).by(1)
  69. end
  70. 1 it 'redirects to the created bridge_content_injury' do
  71. 1 post regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
  72. params: { bridge_content_injury: valid_attributes }
  73. 1 expect(response).to redirect_to(
  74. regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
  75. @injury,
  76. BridgeContentInjury.last)
  77. )
  78. end
  79. end
  80. 1 context 'with invalid parameters' do
  81. 1 it 'does not create a new BridgeContentInjury' do
  82. 1 expect do
  83. 1 post regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
  84. params: { bridge_content_injury: invalid_attributes }
  85. end.to change(BridgeContentInjury, :count).by(0)
  86. end
  87. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  88. 1 post regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury),
  89. params: { bridge_content_injury: invalid_attributes }
  90. 1 expect(response).to be_successful
  91. end
  92. end
  93. end
  94. 1 describe 'PATCH /update' do
  95. 1 context 'with valid parameters' do
  96. 1 let(:new_attributes) do
  97. 2 @new_bridge_content = FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection)
  98. 2 bridge_content_injury = FactoryBot.build(:bridge_content_injury, bridge_content: @new_bridge_content).attributes
  99. 2 bridge_content_injury['seek'] = 2
  100. 2 bridge_content_injury
  101. end
  102. 1 it 'updates the requested bridge_content_injury' do
  103. 1 bridge_content_injury = BridgeContentInjury.create! valid_attributes
  104. 1 patch regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
  105. @injury,
  106. bridge_content_injury),
  107. params: { bridge_content_injury: new_attributes }
  108. 1 bridge_content_injury.reload
  109. 1 expect(bridge_content_injury.bridge_content).to eq(@new_bridge_content)
  110. 1 expect(bridge_content_injury.seek).to eq(2)
  111. end
  112. 1 it 'redirects to the bridge_content_injury' do
  113. 1 bridge_content_injury = BridgeContentInjury.create! valid_attributes
  114. 1 patch regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
  115. @injury,
  116. bridge_content_injury),
  117. params: { bridge_content_injury: new_attributes }
  118. 1 bridge_content_injury.reload
  119. 1 expect(response).to redirect_to(
  120. regular_inspection_injury_bridge_content_injury_url(@regular_inspection, @injury, bridge_content_injury)
  121. )
  122. end
  123. end
  124. 1 context 'with invalid parameters' do
  125. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  126. 1 bridge_content_injury = BridgeContentInjury.create! valid_attributes
  127. 1 patch regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
  128. @injury,
  129. bridge_content_injury),
  130. params: { bridge_content_injury: invalid_attributes }
  131. 1 expect(response).to be_successful
  132. end
  133. end
  134. end
  135. 1 describe 'DELETE /destroy' do
  136. 1 it 'destroys the requested bridge_content_injury' do
  137. 1 bridge_content_injury = BridgeContentInjury.create! valid_attributes
  138. 1 expect do
  139. 1 delete regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
  140. @injury,
  141. bridge_content_injury)
  142. end.to change(BridgeContentInjury, :count).by(-1)
  143. end
  144. 1 it 'redirects to the bridge_content_injuries list' do
  145. 1 bridge_content_injury = BridgeContentInjury.create! valid_attributes
  146. 1 delete regular_inspection_injury_bridge_content_injury_url(@regular_inspection,
  147. @injury,
  148. bridge_content_injury)
  149. 1 expect(response).to redirect_to(
  150. regular_inspection_injury_bridge_content_injuries_url(@regular_inspection, @injury)
  151. )
  152. end
  153. end
  154. end
  155. # rubocop:enable Metrics/BlockLength

spec/requests/bridge_contents_spec.rb

100.0% lines covered

78 relevant lines. 78 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/bridge_contents', type: :request do
  16. 1 before do
  17. 13 @user = FactoryBot.create(:user)
  18. 13 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  19. 13 @regular_inspection = FactoryBot.create(:regular_inspection)
  20. end
  21. # BridgeContent. As you add validations to BridgeContent, be sure to
  22. # adjust the attributes here as well.
  23. 1 let(:valid_attributes) do
  24. 10 attributes = FactoryBot.build(:bridge_content, regular_inspection: @regular_inspection).attributes
  25. 10 attributes['data'] = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testimage.jpg'))
  26. 10 attributes
  27. end
  28. 1 let(:invalid_attributes) do
  29. 3 attributes = FactoryBot.build(:bridge_content, regular_inspection: @regular_inspection).attributes
  30. 3 attributes['title'] = ''
  31. 3 attributes
  32. end
  33. 1 describe 'GET /index' do
  34. 1 it 'renders a successful response' do
  35. 1 BridgeContent.create! valid_attributes
  36. 1 get regular_inspection_bridge_contents_url(@regular_inspection)
  37. 1 expect(response).to be_successful
  38. end
  39. end
  40. 1 describe 'GET /show' do
  41. 1 it 'renders a successful response' do
  42. 1 bridge_content = BridgeContent.create! valid_attributes
  43. 1 get regular_inspection_bridge_content_url(@regular_inspection, bridge_content)
  44. 1 expect(response).to be_successful
  45. end
  46. end
  47. 1 describe 'GET /new' do
  48. 1 it 'renders a successful response' do
  49. 1 get new_regular_inspection_bridge_content_url(@regular_inspection)
  50. 1 expect(response).to be_successful
  51. end
  52. end
  53. 1 describe 'GET /edit' do
  54. 1 it 'render a successful response' do
  55. 1 bridge_content = BridgeContent.create! valid_attributes
  56. 1 get edit_regular_inspection_bridge_content_url(@regular_inspection, bridge_content)
  57. 1 expect(response).to be_successful
  58. end
  59. end
  60. 1 describe 'POST /create' do
  61. 1 context 'with valid parameters' do
  62. 1 it 'creates a new BridgeContent' do
  63. 1 expect do
  64. 1 post regular_inspection_bridge_contents_url(@regular_inspection), params: { bridge_content: valid_attributes }
  65. end.to change(BridgeContent, :count).by(1)
  66. end
  67. 1 it 'redirects to the created bridge_content' do
  68. 1 post regular_inspection_bridge_contents_url(@regular_inspection), params: { bridge_content: valid_attributes }
  69. 1 expect(response).to redirect_to(regular_inspection_bridge_content_url(@regular_inspection, BridgeContent.last))
  70. end
  71. end
  72. 1 context 'with invalid parameters' do
  73. 1 it 'does not create a new BridgeContent' do
  74. 1 expect do
  75. 1 post regular_inspection_bridge_contents_url(@regular_inspection),
  76. params: { bridge_content: invalid_attributes }
  77. end.to change(BridgeContent, :count).by(0)
  78. end
  79. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  80. 1 post regular_inspection_bridge_contents_url(@regular_inspection), params: { bridge_content: invalid_attributes }
  81. 1 expect(response).to be_successful
  82. end
  83. end
  84. end
  85. 1 describe 'PATCH /update' do
  86. 1 context 'with valid parameters' do
  87. 1 let(:new_attributes) do
  88. 2 attributes = valid_attributes
  89. 2 attributes['data'] = fixture_file_upload(Rails.root.join('spec', 'testdata', 'testmovie.mp4'))
  90. 2 attributes
  91. end
  92. 1 it 'updates the requested bridge_content' do
  93. 1 bridge_content = BridgeContent.create! valid_attributes
  94. 1 patch regular_inspection_bridge_content_url(@regular_inspection, bridge_content),
  95. params: { bridge_content: new_attributes }
  96. 1 bridge_content.reload
  97. 1 expect(bridge_content.data.content_type).to eq('video/mp4')
  98. end
  99. 1 it 'redirects to the bridge_content' do
  100. 1 bridge_content = BridgeContent.create! valid_attributes
  101. 1 patch regular_inspection_bridge_content_url(@regular_inspection, bridge_content),
  102. params: { bridge_content: new_attributes }
  103. 1 bridge_content.reload
  104. 1 expect(response).to redirect_to(regular_inspection_bridge_content_url(@regular_inspection, bridge_content))
  105. end
  106. end
  107. 1 context 'with invalid parameters' do
  108. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  109. 1 bridge_content = BridgeContent.create! valid_attributes
  110. 1 patch regular_inspection_bridge_content_url(@regular_inspection, bridge_content),
  111. params: { bridge_content: invalid_attributes }
  112. 1 expect(response).to be_successful
  113. end
  114. end
  115. end
  116. 1 describe 'DELETE /destroy' do
  117. 1 it 'destroys the requested bridge_content' do
  118. 1 bridge_content = BridgeContent.create! valid_attributes
  119. 1 expect do
  120. 1 delete regular_inspection_bridge_content_url(@regular_inspection, bridge_content)
  121. end.to change(BridgeContent, :count).by(-1)
  122. end
  123. 1 it 'redirects to the bridge_contents list' do
  124. 1 bridge_content = BridgeContent.create! valid_attributes
  125. 1 delete regular_inspection_bridge_content_url(@regular_inspection, bridge_content)
  126. 1 expect(response).to redirect_to(regular_inspection_bridge_contents_url(@regular_inspection))
  127. end
  128. end
  129. end
  130. # rubocop:enable Metrics/BlockLength

spec/requests/bridge_main_contents_request_spec.rb

100.0% lines covered

38 relevant lines. 38 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe 'BridgeMainContents', type: :request do
  5. 1 before do
  6. 6 @user = FactoryBot.create(:user)
  7. 6 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  8. 6 @bridge = FactoryBot.create(:bridge)
  9. 6 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
  10. 6 @bridge_content = FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection)
  11. end
  12. # BridgeMainContent. As you add validations to BridgeMainContent, be sure to
  13. # adjust the attributes here as well.
  14. 1 let(:valid_attributes) do
  15. 4 FactoryBot.build(:bridge_main_content,
  16. bridge_content: @bridge_content).attributes
  17. end
  18. 1 let(:invalid_attributes) do
  19. 2 invalid_value = FactoryBot.build(:bridge_main_content)
  20. 2 invalid_value.bridge_content = nil
  21. 2 invalid_value.attributes
  22. end
  23. 1 describe 'POST /create' do
  24. 1 context 'with valid parameters' do
  25. 1 it 'creates a new Injury' do
  26. 1 expect do
  27. 1 post regular_inspection_bridge_main_contents_url(@regular_inspection),
  28. params: { bridge_main_content: valid_attributes }
  29. end.to change(BridgeMainContent, :count).by(1)
  30. end
  31. 1 it 'redirects to bridge_contents index' do
  32. 1 post regular_inspection_bridge_main_contents_url(@regular_inspection),
  33. params: { bridge_main_content: valid_attributes }
  34. 1 expect(response).to redirect_to(regular_inspection_bridge_contents_url(@regular_inspection))
  35. end
  36. end
  37. 1 context 'with invalid parameters' do
  38. 1 it 'does not create a new Injury' do
  39. 1 expect do
  40. 1 post regular_inspection_bridge_main_contents_url(@regular_inspection),
  41. params: { bridge_main_content: invalid_attributes }
  42. end.to change(BridgeMainContent, :count).by(0)
  43. end
  44. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  45. 1 post regular_inspection_bridge_main_contents_url(@regular_inspection),
  46. params: { bridge_main_content: invalid_attributes }
  47. 1 expect(response).to redirect_to(regular_inspection_bridge_contents_url(@regular_inspection))
  48. end
  49. end
  50. end
  51. 1 describe 'DELETE /destroy' do
  52. 1 it 'destroys the requested bridge_main_content' do
  53. 1 bridge_main_content = BridgeMainContent.create! valid_attributes
  54. 1 expect do
  55. 1 delete regular_inspection_bridge_main_content_url(@regular_inspection, bridge_main_content)
  56. end.to change(BridgeMainContent, :count).by(-1)
  57. end
  58. 1 it 'redirects to the injuries list' do
  59. 1 bridge_main_content = BridgeMainContent.create! valid_attributes
  60. 1 delete regular_inspection_bridge_main_content_url(@regular_inspection, bridge_main_content)
  61. 1 expect(response).to redirect_to(regular_inspection_bridge_contents_url(@regular_inspection))
  62. end
  63. end
  64. end
  65. # rubocop:enable Metrics/BlockLength

spec/requests/bridges_spec.rb

100.0% lines covered

87 relevant lines. 87 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/bridges', type: :request do
  16. 1 before do
  17. 13 @user = FactoryBot.create(:user)
  18. 13 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  19. end
  20. # Bridge. As you add validations to Bridge, be sure to
  21. # adjust the attributes here as well.
  22. 1 let(:valid_attributes) do
  23. 10 bridge = FactoryBot.build(:bridge).attributes
  24. 10 bridge['bridge_length'] = bridge['other_data']['bridge_length']
  25. 10 bridge['width'] = bridge['other_data']['width']
  26. 10 bridge
  27. end
  28. 1 let(:invalid_attributes) do
  29. 3 bridge = FactoryBot.build(:bridge)
  30. 3 bridge.title = ''
  31. 3 bridge.attributes
  32. end
  33. 1 describe 'GET /index' do
  34. 1 it 'renders a successful response' do
  35. 1 Bridge.create! valid_attributes
  36. 1 get bridges_url
  37. 1 expect(response).to be_successful
  38. end
  39. end
  40. 1 describe 'GET /show' do
  41. 1 it 'renders a successful response' do
  42. 1 bridge = Bridge.create! valid_attributes
  43. 1 get bridge_url(bridge)
  44. 1 expect(response).to be_successful
  45. end
  46. end
  47. 1 describe 'GET /new' do
  48. 1 it 'renders a successful response' do
  49. 1 get new_bridge_url
  50. 1 expect(response).to be_successful
  51. end
  52. end
  53. 1 describe 'GET /edit' do
  54. 1 it 'render a successful response' do
  55. 1 bridge = Bridge.create! valid_attributes
  56. 1 get edit_bridge_url(bridge)
  57. 1 expect(response).to be_successful
  58. end
  59. end
  60. 1 describe 'POST /create' do
  61. 1 context 'with valid parameters' do
  62. 1 it 'creates a new Bridge' do
  63. 1 expect do
  64. 1 post bridges_url, params: { bridge: valid_attributes }
  65. end.to change(Bridge, :count).by(1)
  66. end
  67. 1 it 'redirects to the created bridge' do
  68. 1 post bridges_url, params: { bridge: valid_attributes }
  69. 1 expect(response).to redirect_to(bridge_url(Bridge.last))
  70. end
  71. end
  72. 1 context 'with invalid parameters' do
  73. 1 it 'does not create a new Bridge' do
  74. 1 expect do
  75. 1 post bridges_url, params: { bridge: invalid_attributes }
  76. end.to change(Bridge, :count).by(0)
  77. end
  78. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  79. 1 post bridges_url, params: { bridge: invalid_attributes }
  80. 1 expect(response).to be_successful
  81. end
  82. end
  83. end
  84. 1 describe 'PATCH /update' do
  85. 1 context 'with valid parameters' do
  86. 1 let(:new_attributes) do
  87. 2 bridge = FactoryBot.build(:bridge).attributes
  88. 2 bridge['bridge_length'] = 20
  89. 2 bridge['width'] = 6.5
  90. 2 bridge['emergency_transport_road'] = true
  91. 2 bridge['title'] = 'title'
  92. 2 bridge['kana_title'] = 'kana'
  93. 2 bridge
  94. end
  95. 1 it 'updates the requested bridge' do
  96. 1 new_params = new_attributes
  97. 1 bridge = Bridge.create! valid_attributes
  98. 1 patch bridge_url(bridge), params: { bridge: new_params }
  99. 1 bridge.reload
  100. 1 expect(bridge.title).to eq(new_params['title'])
  101. 1 expect(bridge.bridge_length).to eq(20)
  102. 1 expect(bridge.width).to eq(6.5)
  103. 1 expect(bridge.emergency_transport_road).to eq(true)
  104. 1 expect(bridge.full_title).to eq('title (kana)')
  105. end
  106. 1 it 'redirects to the bridge' do
  107. 1 bridge = Bridge.create! valid_attributes
  108. 1 patch bridge_url(bridge), params: { bridge: new_attributes }
  109. 1 bridge.reload
  110. 1 expect(response).to redirect_to(bridge_url(bridge))
  111. end
  112. end
  113. 1 context 'with invalid parameters' do
  114. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  115. 1 bridge = Bridge.create! valid_attributes
  116. 1 patch bridge_url(bridge), params: { bridge: invalid_attributes }
  117. 1 expect(response).to be_successful
  118. end
  119. end
  120. end
  121. 1 describe 'DELETE /destroy' do
  122. 1 it 'destroys the requested bridge' do
  123. 1 bridge = Bridge.create! valid_attributes
  124. 1 expect do
  125. 1 delete bridge_url(bridge)
  126. end.to change(Bridge, :count).by(-1)
  127. end
  128. 1 it 'redirects to the bridges list' do
  129. 1 bridge = Bridge.create! valid_attributes
  130. 1 delete bridge_url(bridge)
  131. 1 expect(response).to redirect_to(bridges_url)
  132. end
  133. end
  134. end
  135. # rubocop:enable Metrics/BlockLength

spec/requests/components_spec.rb

100.0% lines covered

76 relevant lines. 76 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/components', type: :request do
  16. 1 before do
  17. 13 @user = FactoryBot.create(:user)
  18. 13 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  19. 13 @bridge = FactoryBot.create(:bridge)
  20. end
  21. # Component. As you add validations to Component, be sure to
  22. # adjust the attributes here as well.
  23. 1 let(:valid_attributes) do
  24. 10 FactoryBot.build(:component, bridge: @bridge).attributes
  25. end
  26. 1 let(:invalid_attributes) do
  27. 3 component = FactoryBot.build(:component, bridge: @bridge)
  28. 3 component.component_category = nil
  29. 3 component.attributes
  30. end
  31. 1 describe 'GET /index' do
  32. 1 it 'renders a successful response' do
  33. 1 Component.create! valid_attributes
  34. 1 get bridge_components_url(@bridge)
  35. 1 expect(response).to be_successful
  36. end
  37. end
  38. 1 describe 'GET /show' do
  39. 1 it 'renders a successful response' do
  40. 1 component = Component.create! valid_attributes
  41. 1 get bridge_component_url(@bridge, component)
  42. 1 expect(response).to be_successful
  43. end
  44. end
  45. 1 describe 'GET /new' do
  46. 1 it 'renders a successful response' do
  47. 1 get new_bridge_component_url(@bridge)
  48. 1 expect(response).to be_successful
  49. end
  50. end
  51. 1 describe 'GET /edit' do
  52. 1 it 'render a successful response' do
  53. 1 component = Component.create! valid_attributes
  54. 1 get edit_bridge_component_url(@bridge, component)
  55. 1 expect(response).to be_successful
  56. end
  57. end
  58. 1 describe 'POST /create' do
  59. 1 context 'with valid parameters' do
  60. 1 it 'creates a new Component' do
  61. 1 expect do
  62. 1 post bridge_components_url(@bridge), params: { component: valid_attributes }
  63. end.to change(Component, :count).by(1)
  64. end
  65. 1 it 'redirects to the created component' do
  66. 1 post bridge_components_url(@bridge), params: { component: valid_attributes }
  67. 1 expect(response).to redirect_to(bridge_component_url(@bridge, Component.last))
  68. end
  69. end
  70. 1 context 'with invalid parameters' do
  71. 1 it 'does not create a new Component' do
  72. 1 expect do
  73. 1 post bridge_components_url(@bridge), params: { component: invalid_attributes }
  74. end.to change(Component, :count).by(0)
  75. end
  76. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  77. 1 post bridge_components_url(@bridge), params: { component: invalid_attributes }
  78. 1 expect(response).to be_successful
  79. end
  80. end
  81. end
  82. 1 describe 'PATCH /update' do
  83. 1 context 'with valid parameters' do
  84. 1 let(:new_attributes) do
  85. 2 component = FactoryBot.build(:component, bridge: @bridge)
  86. 2 component.component_category = Component.categories[:other]
  87. 2 component.attributes
  88. end
  89. 1 it 'updates the requested component' do
  90. 1 component = Component.create! valid_attributes
  91. 1 patch bridge_component_url(@bridge, component), params: { component: new_attributes }
  92. 1 component.reload
  93. 1 expect(component.component_category).to eq(6)
  94. end
  95. 1 it 'redirects to the component' do
  96. 1 component = Component.create! valid_attributes
  97. 1 patch bridge_component_url(@bridge, component), params: { component: new_attributes }
  98. 1 component.reload
  99. 1 expect(response).to redirect_to(bridge_component_url(@bridge, component))
  100. end
  101. end
  102. 1 context 'with invalid parameters' do
  103. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  104. 1 component = Component.create! valid_attributes
  105. 1 patch bridge_component_url(@bridge, component), params: { component: invalid_attributes }
  106. 1 expect(response).to be_successful
  107. end
  108. end
  109. end
  110. 1 describe 'DELETE /destroy' do
  111. 1 it 'destroys the requested component' do
  112. 1 component = Component.create! valid_attributes
  113. 1 expect do
  114. 1 delete bridge_component_url(@bridge, component)
  115. end.to change(Component, :count).by(-1)
  116. end
  117. 1 it 'redirects to the components list' do
  118. 1 component = Component.create! valid_attributes
  119. 1 delete bridge_component_url(@bridge, component)
  120. 1 expect(response).to redirect_to(bridge_components_url(@bridge))
  121. end
  122. end
  123. end
  124. # rubocop:enable Metrics/BlockLength

spec/requests/diagnoses_spec.rb

100.0% lines covered

80 relevant lines. 80 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/diagnoses', type: :request do
  16. 1 before do
  17. 13 @user = FactoryBot.create(:user)
  18. 13 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  19. 13 @bridge = FactoryBot.create(:bridge)
  20. 13 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
  21. 13 @component = FactoryBot.create(:component, bridge: @bridge)
  22. 13 @injury = FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: @component)
  23. end
  24. # Diagnosis. As you add validations to Diagnosis, be sure to
  25. # adjust the attributes here as well.
  26. 1 let(:valid_attributes) do
  27. 10 FactoryBot.build(:diagnosis, regular_inspection: @regular_inspection, injury: @injury).attributes
  28. end
  29. 1 let(:invalid_attributes) do
  30. 3 regular_inspection = FactoryBot.build(:diagnosis, regular_inspection: @regular_inspection, injury: @injury)
  31. 3 regular_inspection.injury = nil
  32. 3 regular_inspection.result = Diagnosis.diagnosis_results[:two]
  33. 3 regular_inspection.attributes
  34. end
  35. 1 describe 'GET /index' do
  36. 1 it 'renders a successful response' do
  37. 1 Diagnosis.create! valid_attributes
  38. 1 get regular_inspection_diagnoses_url(@regular_inspection)
  39. 1 expect(response).to be_successful
  40. end
  41. end
  42. 1 describe 'GET /show' do
  43. 1 it 'renders a successful response' do
  44. 1 diagnosis = Diagnosis.create! valid_attributes
  45. 1 get regular_inspection_diagnosis_url(@regular_inspection, diagnosis)
  46. 1 expect(response).to be_successful
  47. end
  48. end
  49. 1 describe 'GET /new' do
  50. 1 it 'renders a successful response' do
  51. 1 get new_regular_inspection_diagnosis_url(@regular_inspection)
  52. 1 expect(response).to be_successful
  53. end
  54. end
  55. 1 describe 'GET /edit' do
  56. 1 it 'render a successful response' do
  57. 1 diagnosis = Diagnosis.create! valid_attributes
  58. 1 get edit_regular_inspection_diagnosis_url(@regular_inspection, diagnosis)
  59. 1 expect(response).to be_successful
  60. end
  61. end
  62. 1 describe 'POST /create' do
  63. 1 context 'with valid parameters' do
  64. 1 it 'creates a new Diagnosis' do
  65. 1 expect do
  66. 1 post regular_inspection_diagnoses_url(@regular_inspection), params: { diagnosis: valid_attributes }
  67. end.to change(Diagnosis, :count).by(1)
  68. end
  69. 1 it 'redirects to the created diagnosis' do
  70. 1 post regular_inspection_diagnoses_url(@regular_inspection), params: { diagnosis: valid_attributes }
  71. 1 expect(response).to redirect_to(regular_inspection_diagnosis_url(@regular_inspection, Diagnosis.last))
  72. end
  73. end
  74. 1 context 'with invalid parameters' do
  75. 1 it 'does not create a new Diagnosis' do
  76. 1 expect do
  77. 1 post regular_inspection_diagnoses_url(@regular_inspection), params: { diagnosis: invalid_attributes }
  78. end.to change(Diagnosis, :count).by(0)
  79. end
  80. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  81. 1 post regular_inspection_diagnoses_url(@regular_inspection), params: { diagnosis: invalid_attributes }
  82. 1 expect(response).to be_successful
  83. end
  84. end
  85. end
  86. 1 describe 'PATCH /update' do
  87. 1 context 'with valid parameters' do
  88. 1 let(:new_attributes) do
  89. 2 regular_inspection = FactoryBot.build(:diagnosis, regular_inspection: @regular_inspection, injury: @injury)
  90. 2 regular_inspection.result = Diagnosis.diagnosis_results[:three]
  91. 2 regular_inspection.attributes
  92. end
  93. 1 it 'updates the requested diagnosis' do
  94. 1 diagnosis = Diagnosis.create! valid_attributes
  95. 1 patch regular_inspection_diagnosis_url(@regular_inspection, diagnosis), params: { diagnosis: new_attributes }
  96. 1 diagnosis.reload
  97. 1 expect(diagnosis.result).to eq(Diagnosis.diagnosis_results[:three])
  98. end
  99. 1 it 'redirects to the diagnosis' do
  100. 1 diagnosis = Diagnosis.create! valid_attributes
  101. 1 patch regular_inspection_diagnosis_url(@regular_inspection, diagnosis), params: { diagnosis: new_attributes }
  102. 1 diagnosis.reload
  103. 1 expect(response).to redirect_to(regular_inspection_diagnosis_url(@regular_inspection, diagnosis))
  104. end
  105. end
  106. 1 context 'with invalid parameters' do
  107. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  108. 1 diagnosis = Diagnosis.create! valid_attributes
  109. 1 patch regular_inspection_diagnosis_url(@regular_inspection, diagnosis),
  110. params: { diagnosis: invalid_attributes }
  111. 1 expect(response).to be_successful
  112. end
  113. end
  114. end
  115. 1 describe 'DELETE /destroy' do
  116. 1 it 'destroys the requested diagnosis' do
  117. 1 diagnosis = Diagnosis.create! valid_attributes
  118. 1 expect do
  119. 1 delete regular_inspection_diagnosis_url(@regular_inspection, diagnosis)
  120. end.to change(Diagnosis, :count).by(-1)
  121. end
  122. 1 it 'redirects to the diagnoses list' do
  123. 1 diagnosis = Diagnosis.create! valid_attributes
  124. 1 delete regular_inspection_diagnosis_url(@regular_inspection, diagnosis)
  125. 1 expect(response).to redirect_to(regular_inspection_diagnoses_url(@regular_inspection))
  126. end
  127. end
  128. end
  129. # rubocop:enable Metrics/BlockLength

spec/requests/injuries_spec.rb

100.0% lines covered

80 relevant lines. 80 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/injuries', type: :request do
  16. 1 before do
  17. 13 @user = FactoryBot.create(:user)
  18. 13 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  19. 13 @bridge = FactoryBot.create(:bridge)
  20. 13 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: @bridge)
  21. 13 @component = FactoryBot.create(:component, bridge: @bridge)
  22. end
  23. # Injury. As you add validations to Injury, be sure to
  24. # adjust the attributes here as well.
  25. 1 let(:valid_attributes) do
  26. 10 FactoryBot.build(:injury, regular_inspection: @regular_inspection, component: @component).attributes
  27. end
  28. 1 let(:invalid_attributes) do
  29. 3 invalid_value = FactoryBot.build(:injury, regular_inspection: @regular_inspection, component: @component)
  30. 3 invalid_value.component = nil
  31. 3 invalid_value.attributes
  32. end
  33. 1 describe 'GET /index' do
  34. 1 it 'renders a successful response' do
  35. 1 Injury.create! valid_attributes
  36. 1 get regular_inspection_injuries_url(@regular_inspection)
  37. 1 expect(response).to be_successful
  38. end
  39. end
  40. 1 describe 'GET /show' do
  41. 1 it 'renders a successful response' do
  42. 1 injury = Injury.create! valid_attributes
  43. 1 get regular_inspection_injury_url(@regular_inspection, injury)
  44. 1 expect(response).to be_successful
  45. end
  46. end
  47. 1 describe 'GET /new' do
  48. 1 it 'renders a successful response' do
  49. 1 get new_regular_inspection_injury_url(@regular_inspection)
  50. 1 expect(response).to be_successful
  51. end
  52. end
  53. 1 describe 'GET /edit' do
  54. 1 it 'render a successful response' do
  55. 1 injury = Injury.create! valid_attributes
  56. 1 get edit_regular_inspection_injury_url(@regular_inspection, injury)
  57. 1 expect(response).to be_successful
  58. end
  59. end
  60. 1 describe 'POST /create' do
  61. 1 context 'with valid parameters' do
  62. 1 it 'creates a new Injury' do
  63. 1 expect do
  64. 1 post regular_inspection_injuries_url(@regular_inspection), params: { injury: valid_attributes }
  65. end.to change(Injury, :count).by(1)
  66. end
  67. 1 it 'redirects to the created injury' do
  68. 1 post regular_inspection_injuries_url(@regular_inspection), params: { injury: valid_attributes }
  69. 1 expect(response).to redirect_to(regular_inspection_injury_url(@regular_inspection, Injury.last))
  70. end
  71. end
  72. 1 context 'with invalid parameters' do
  73. 1 it 'does not create a new Injury' do
  74. 1 expect do
  75. 1 post regular_inspection_injuries_url(@regular_inspection), params: { injury: invalid_attributes }
  76. end.to change(Injury, :count).by(0)
  77. end
  78. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  79. 1 post regular_inspection_injuries_url(@regular_inspection), params: { injury: invalid_attributes }
  80. 1 expect(response).to be_successful
  81. end
  82. end
  83. end
  84. 1 describe 'PATCH /update' do
  85. 1 context 'with valid parameters' do
  86. 1 let(:new_attributes) do
  87. 2 new_value = FactoryBot.build(:injury, regular_inspection: @regular_inspection, component: @component).attributes
  88. 2 new_value['injury_type'] = 'test!'
  89. 2 new_value['unit'] = 'm'
  90. 2 new_value
  91. end
  92. 1 it 'updates the requested injury' do
  93. 1 injury = Injury.create! valid_attributes
  94. 1 patch regular_inspection_injury_url(@regular_inspection, injury), params: { injury: new_attributes }
  95. 1 injury.reload
  96. 1 expect(injury.injury_type).to eq('test!')
  97. 1 expect(injury.unit).to eq('m')
  98. end
  99. 1 it 'redirects to the injury' do
  100. 1 injury = Injury.create! valid_attributes
  101. 1 patch regular_inspection_injury_url(@regular_inspection, injury), params: { injury: new_attributes }
  102. 1 injury.reload
  103. 1 expect(response).to redirect_to(regular_inspection_injury_url(@regular_inspection, injury))
  104. end
  105. end
  106. 1 context 'with invalid parameters' do
  107. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  108. 1 injury = Injury.create! valid_attributes
  109. 1 patch regular_inspection_injury_url(@regular_inspection, injury), params: { injury: invalid_attributes }
  110. 1 expect(response).to be_successful
  111. end
  112. end
  113. end
  114. 1 describe 'DELETE /destroy' do
  115. 1 it 'destroys the requested injury' do
  116. 1 injury = Injury.create! valid_attributes
  117. 1 expect do
  118. 1 delete regular_inspection_injury_url(@regular_inspection, injury)
  119. end.to change(Injury, :count).by(-1)
  120. end
  121. 1 it 'redirects to the injuries list' do
  122. 1 injury = Injury.create! valid_attributes
  123. 1 delete regular_inspection_injury_url(@regular_inspection, injury)
  124. 1 expect(response).to redirect_to(regular_inspection_injury_url(@regular_inspection))
  125. end
  126. end
  127. end
  128. # rubocop:enable Metrics/BlockLength

spec/requests/mlit_importers_spec.rb

100.0% lines covered

41 relevant lines. 41 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe 'MlitImporters', type: :request do
  5. 1 before do
  6. 7 @user = FactoryBot.create(:user)
  7. 7 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  8. end
  9. 1 let(:valid_attributes) do
  10. 2 file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001.xlsx')
  11. 2 MlitImporter.import(file).attributes
  12. end
  13. 1 let(:invalid_attributes) do
  14. 2 file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001-invalid.xlsx')
  15. 2 MlitImporter.import(file).attributes
  16. end
  17. 1 describe 'GET /new' do
  18. 1 it 'returns http success' do
  19. 1 get new_mlit_importer_url
  20. 1 expect(response).to have_http_status(:success)
  21. end
  22. end
  23. 1 describe 'GET /preview' do
  24. 1 it 'returns http success' do
  25. 1 file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001.xlsx')
  26. 1 post preview_mlit_importer_url, params: {
  27. upload_file: Rack::Test::UploadedFile.new(file)
  28. }
  29. 1 expect(response).to have_http_status(:success)
  30. 1 expect(response.body).to include('bridge[title]')
  31. end
  32. 1 it 'render new' do
  33. 1 file = File.join(File.dirname(__FILE__), '../testdata/mlit-testdata-001-invalid.xlsx')
  34. 1 post preview_mlit_importer_url, params: {
  35. upload_file: Rack::Test::UploadedFile.new(file)
  36. }
  37. 1 expect(response).to have_http_status(:success)
  38. 1 expect(response.body).to include('file')
  39. end
  40. end
  41. 1 describe 'POST /create' do
  42. 1 describe 'with valid data' do
  43. 1 it 'creates a new Bridge' do
  44. 1 expect do
  45. 1 post mlit_importer_url, params: { bridge: valid_attributes }
  46. end.to change(Bridge, :count).by(1)
  47. end
  48. 1 it 'redirects to the created bridge' do
  49. 1 post mlit_importer_url, params: { bridge: valid_attributes }
  50. 1 expect(response).to redirect_to(bridge_url(Bridge.last))
  51. end
  52. end
  53. 1 describe 'with invalid data' do
  54. 1 it 'cannot creates a new Bridge' do
  55. 1 expect do
  56. 1 post mlit_importer_url, params: { bridge: invalid_attributes }
  57. end.to change(Bridge, :count).by(0)
  58. end
  59. 1 it 'render new page' do
  60. 1 post mlit_importer_url, params: { bridge: invalid_attributes }
  61. 1 expect(response.body).to include('file')
  62. end
  63. end
  64. end
  65. end
  66. # rubocop:enable Metrics/BlockLength

spec/requests/regular_inspections_spec.rb

100.0% lines covered

84 relevant lines. 84 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/regular_inspections', type: :request do
  16. 1 before do
  17. 15 @user = FactoryBot.create(:user)
  18. 15 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  19. 15 @bridge = FactoryBot.create(:bridge)
  20. end
  21. # RegularInspection. As you add validations to RegularInspection, be sure to
  22. # adjust the attributes here as well.
  23. 1 let(:valid_attributes) do
  24. 12 FactoryBot.build(:regular_inspection, bridge: @bridge).attributes
  25. end
  26. 1 let(:invalid_attributes) do
  27. 3 regular_inspection = FactoryBot.build(:regular_inspection, bridge: @bridge)
  28. 3 regular_inspection.title = ''
  29. 3 regular_inspection.attributes
  30. end
  31. 1 describe 'GET /index' do
  32. 1 it 'renders a successful response' do
  33. 1 RegularInspection.create! valid_attributes
  34. 1 get regular_inspections_url
  35. 1 expect(response).to be_successful
  36. end
  37. end
  38. 1 describe 'GET /show' do
  39. 1 it 'renders a successful response' do
  40. 1 regular_inspection = RegularInspection.create! valid_attributes
  41. 1 get regular_inspection_url(regular_inspection)
  42. 1 expect(response).to be_successful
  43. end
  44. end
  45. 1 describe 'GET /new' do
  46. 1 it 'renders a successful response' do
  47. 1 get new_regular_inspection_url
  48. 1 expect(response).to be_successful
  49. end
  50. end
  51. 1 describe 'GET /edit' do
  52. 1 it 'render a successful response' do
  53. 1 regular_inspection = RegularInspection.create! valid_attributes
  54. 1 get edit_regular_inspection_url(regular_inspection)
  55. 1 expect(response).to be_successful
  56. end
  57. end
  58. 1 describe 'POST /create' do
  59. 1 context 'with valid parameters' do
  60. 1 it 'creates a new RegularInspection' do
  61. 1 expect do
  62. 1 post regular_inspections_url, params: { regular_inspection: valid_attributes }
  63. end.to change(RegularInspection, :count).by(1)
  64. end
  65. 1 it 'redirects to the created regular_inspection' do
  66. 1 post regular_inspections_url, params: { regular_inspection: valid_attributes }
  67. 1 expect(response).to redirect_to(regular_inspection_url(RegularInspection.last))
  68. end
  69. end
  70. 1 context 'with invalid parameters' do
  71. 1 it 'does not create a new RegularInspection' do
  72. 1 expect do
  73. 1 post regular_inspections_url, params: { regular_inspection: invalid_attributes }
  74. end.to change(RegularInspection, :count).by(0)
  75. end
  76. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  77. 1 post regular_inspections_url, params: { regular_inspection: invalid_attributes }
  78. 1 expect(response).to be_successful
  79. end
  80. end
  81. end
  82. 1 describe 'PATCH /update' do
  83. 1 context 'with valid parameters' do
  84. 1 let(:new_attributes) do
  85. 2 FactoryBot.build(:regular_inspection, bridge: @bridge, title: 'test!').attributes
  86. end
  87. 1 it 'updates the requested regular_inspection' do
  88. 1 regular_inspection = RegularInspection.create! valid_attributes
  89. 1 patch regular_inspection_url(regular_inspection), params: { regular_inspection: new_attributes }
  90. 1 regular_inspection.reload
  91. 1 expect(regular_inspection.title).to eq('test!')
  92. end
  93. 1 it 'redirects to the regular_inspection' do
  94. 1 regular_inspection = RegularInspection.create! valid_attributes
  95. 1 patch regular_inspection_url(regular_inspection), params: { regular_inspection: new_attributes }
  96. 1 regular_inspection.reload
  97. 1 expect(response).to redirect_to(regular_inspection_url(regular_inspection))
  98. end
  99. end
  100. 1 context 'with invalid parameters' do
  101. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  102. 1 regular_inspection = RegularInspection.create! valid_attributes
  103. 1 patch regular_inspection_url(regular_inspection), params: { regular_inspection: invalid_attributes }
  104. 1 expect(response).to be_successful
  105. end
  106. end
  107. end
  108. 1 describe 'DELETE /destroy' do
  109. 1 it 'destroys the requested regular_inspection' do
  110. 1 regular_inspection = RegularInspection.create! valid_attributes
  111. 1 expect do
  112. 1 delete regular_inspection_url(regular_inspection)
  113. end.to change(RegularInspection, :count).by(-1)
  114. end
  115. 1 it 'redirects to the regular_inspections list' do
  116. 1 regular_inspection = RegularInspection.create! valid_attributes
  117. 1 delete regular_inspection_url(regular_inspection)
  118. 1 expect(response).to redirect_to(regular_inspections_url)
  119. end
  120. end
  121. 1 describe 'GET /bridge_id/download_image_metadata' do
  122. 1 it 'download simple template' do
  123. 1 regular_inspection = RegularInspection.create! valid_attributes
  124. 1 get regular_inspection_download_image_metadata_url(regular_inspection)
  125. 1 expect(response).to be_successful
  126. end
  127. end
  128. 1 describe 'GET /bridge_id/download_pointcloud_metadata' do
  129. 1 it 'download simple template' do
  130. 1 regular_inspection = RegularInspection.create! valid_attributes
  131. 1 get regular_inspection_download_pointcloud_metadata_url(regular_inspection)
  132. 1 expect(response).to be_successful
  133. end
  134. end
  135. end
  136. # rubocop:enable Metrics/BlockLength

spec/requests/sessions_request_spec.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'Sessions', type: :request do
  4. end

spec/requests/soundnesses_spec.rb

100.0% lines covered

76 relevant lines. 76 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. # rubocop:disable Metrics/BlockLength
  15. 1 RSpec.describe '/soundnesses', type: :request do
  16. 1 before do
  17. 13 @user = FactoryBot.create(:user)
  18. 13 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  19. 13 @bridge = FactoryBot.create(:bridge)
  20. end
  21. # Soundness. As you add validations to Soundness, be sure to
  22. # adjust the attributes here as well.
  23. 1 let(:valid_attributes) do
  24. 10 FactoryBot.build(:soundness, bridge: @bridge).attributes
  25. end
  26. 1 let(:invalid_attributes) do
  27. 3 attributes = FactoryBot.build(:soundness, bridge: @bridge).attributes
  28. 3 attributes['evaluation'] = ''
  29. 3 attributes
  30. end
  31. 1 describe 'GET /index' do
  32. 1 it 'renders a successful response' do
  33. 1 Soundness.create! valid_attributes
  34. 1 get bridge_soundnesses_url(@bridge)
  35. 1 expect(response).to be_successful
  36. end
  37. end
  38. 1 describe 'GET /show' do
  39. 1 it 'renders a successful response' do
  40. 1 soundness = Soundness.create! valid_attributes
  41. 1 get bridge_soundness_url(@bridge, soundness)
  42. 1 expect(response).to be_successful
  43. end
  44. end
  45. 1 describe 'GET /new' do
  46. 1 it 'renders a successful response' do
  47. 1 get new_bridge_soundness_url(@bridge)
  48. 1 expect(response).to be_successful
  49. end
  50. end
  51. 1 describe 'GET /edit' do
  52. 1 it 'render a successful response' do
  53. 1 soundness = Soundness.create! valid_attributes
  54. 1 get edit_bridge_soundness_url(@bridge, soundness)
  55. 1 expect(response).to be_successful
  56. end
  57. end
  58. 1 describe 'POST /create' do
  59. 1 context 'with valid parameters' do
  60. 1 it 'creates a new Soundness' do
  61. 1 expect do
  62. 1 post bridge_soundnesses_url(@bridge), params: { soundness: valid_attributes }
  63. end.to change(Soundness, :count).by(1)
  64. end
  65. 1 it 'redirects to the created soundness' do
  66. 1 post bridge_soundnesses_url(@bridge), params: { soundness: valid_attributes }
  67. 1 expect(response).to redirect_to(bridge_soundness_url(@bridge, Soundness.last))
  68. end
  69. end
  70. 1 context 'with invalid parameters' do
  71. 1 it 'does not create a new Soundness' do
  72. 1 expect do
  73. 1 post bridge_soundnesses_url(@bridge), params: { soundness: invalid_attributes }
  74. end.to change(Soundness, :count).by(0)
  75. end
  76. 1 it "renders a successful response (i.e. to display the 'new' template)" do
  77. 1 post bridge_soundnesses_url(@bridge), params: { soundness: invalid_attributes }
  78. 1 expect(response).to be_successful
  79. end
  80. end
  81. end
  82. 1 describe 'PATCH /update' do
  83. 1 context 'with valid parameters' do
  84. 1 let(:new_attributes) do
  85. 2 attributes = valid_attributes
  86. 2 attributes['evaluation'] = 'new text'
  87. 2 attributes
  88. end
  89. 1 it 'updates the requested soundness' do
  90. 1 soundness = Soundness.create! valid_attributes
  91. 1 patch bridge_soundness_url(@bridge, soundness), params: { soundness: new_attributes }
  92. 1 soundness.reload
  93. 1 expect(soundness.evaluation).to eq('new text')
  94. end
  95. 1 it 'redirects to the soundness' do
  96. 1 soundness = Soundness.create! valid_attributes
  97. 1 patch bridge_soundness_url(@bridge, soundness), params: { soundness: new_attributes }
  98. 1 soundness.reload
  99. 1 expect(response).to redirect_to(bridge_soundness_url(@bridge, soundness))
  100. end
  101. end
  102. 1 context 'with invalid parameters' do
  103. 1 it "renders a successful response (i.e. to display the 'edit' template)" do
  104. 1 soundness = Soundness.create! valid_attributes
  105. 1 patch bridge_soundness_url(@bridge, soundness), params: { soundness: invalid_attributes }
  106. 1 expect(response).to be_successful
  107. end
  108. end
  109. end
  110. 1 describe 'DELETE /destroy' do
  111. 1 it 'destroys the requested soundness' do
  112. 1 soundness = Soundness.create! valid_attributes
  113. 1 expect do
  114. 1 delete bridge_soundness_url(@bridge, soundness)
  115. end.to change(Soundness, :count).by(-1)
  116. end
  117. 1 it 'redirects to the soundnesses list' do
  118. 1 soundness = Soundness.create! valid_attributes
  119. 1 delete bridge_soundness_url(@bridge, soundness)
  120. 1 expect(response).to redirect_to(bridge_soundnesses_url(@bridge))
  121. end
  122. end
  123. end
  124. # rubocop:enable Metrics/BlockLength

spec/requests/status_request_spec.rb

100.0% lines covered

18 relevant lines. 18 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # This spec was generated by rspec-rails when you ran the scaffold generator.
  4. # It demonstrates how one might use RSpec to test the controller code that
  5. # was generated by Rails when you ran the scaffold generator.
  6. #
  7. # It assumes that the implementation code is generated by the rails scaffold
  8. # generator. If you are using any extension libraries to generate different
  9. # controller code, this generated spec may or may not pass.
  10. #
  11. # It only uses APIs available in rails and/or rspec-rails. There are a number
  12. # of tools you can use to make these specs even more expressive, but we're
  13. # sticking to rails and rspec-rails APIs to keep things simple and stable.
  14. 1 RSpec.describe '/status.json', type: :request do
  15. 1 before do
  16. 2 @bridge = FactoryBot.create(:bridge)
  17. end
  18. 1 describe 'GET /status.json' do
  19. 1 it 'renders a successful response' do
  20. 1 get '/status.json'
  21. 1 expect(response).to be_successful
  22. 1 expect(response_body['bridge_count']).to eq(1)
  23. 1 expect(response_body['message']).to be_nil
  24. end
  25. 1 it 'raise error, message is not null' do
  26. 1 allow(Bridge).to receive(:count).and_raise('some error')
  27. 1 get '/status.json'
  28. 1 expect(response).not_to be_successful
  29. 1 expect(response_body['bridge_count']).to eq(0)
  30. 1 expect(response_body['message']).to eq('some error')
  31. end
  32. end
  33. 1 def response_body
  34. 4 JSON.parse(response.body)
  35. end
  36. end

spec/requests/top_request_spec.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'Tops', type: :request do
  4. 1 before do
  5. 2 @user = FactoryBot.create(:user)
  6. 2 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: @user.id })
  7. end
  8. 1 describe 'GET /top/index' do
  9. 1 it 'enable to access' do
  10. 1 get top_index_path
  11. 1 expect(response).to have_http_status(200)
  12. end
  13. 1 it 'fail without login' do
  14. 1 allow_any_instance_of(ActionDispatch::Request).to receive(:session).and_return({ user_id: '' })
  15. 1 get top_index_path
  16. 1 expect(response).to redirect_to sessions_index_path
  17. end
  18. end
  19. end

spec/routing/admin/users_routing_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe Admin::UsersController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(get: '/admin/users').to route_to('admin/users#index')
  8. end
  9. 1 it 'routes to #new' do
  10. 1 expect(get: '/admin/users/new').to route_to('admin/users#new')
  11. end
  12. 1 it 'routes to #show' do
  13. 1 expect(get: '/admin/users/1').to route_to('admin/users#show', id: '1')
  14. end
  15. 1 it 'routes to #edit' do
  16. 1 expect(get: '/admin/users/1/edit').to route_to('admin/users#edit', id: '1')
  17. end
  18. 1 it 'routes to #create' do
  19. 1 expect(post: '/admin/users').to route_to('admin/users#create')
  20. end
  21. 1 it 'routes to #update via PUT' do
  22. 1 expect(put: '/admin/users/1').to route_to('admin/users#update', id: '1')
  23. end
  24. 1 it 'routes to #update via PATCH' do
  25. 1 expect(patch: '/admin/users/1').to route_to('admin/users#update', id: '1')
  26. end
  27. 1 it 'routes to #destroy' do
  28. 1 expect(delete: '/admin/users/1').to route_to('admin/users#destroy', id: '1')
  29. end
  30. end
  31. end
  32. # rubocop:enable Metrics/BlockLength

spec/routing/bridge_content_injuries_routing_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe BridgeContentInjuriesController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(
  8. get: '/regular_inspections/1/injuries/1/bridge_content_injuries'
  9. ).to route_to('bridge_content_injuries#index', regular_inspection_id: '1', injury_id: '1')
  10. end
  11. 1 it 'routes to #new' do
  12. 1 expect(
  13. get: '/regular_inspections/1/injuries/1/bridge_content_injuries/new'
  14. ).to route_to('bridge_content_injuries#new', regular_inspection_id: '1', injury_id: '1')
  15. end
  16. 1 it 'routes to #show' do
  17. 1 expect(
  18. get: '/regular_inspections/1/injuries/1/bridge_content_injuries/1'
  19. ).to route_to('bridge_content_injuries#show', regular_inspection_id: '1', injury_id: '1', id: '1')
  20. end
  21. 1 it 'routes to #edit' do
  22. 1 expect(
  23. get: '/regular_inspections/1/injuries/1/bridge_content_injuries/1/edit'
  24. ).to route_to('bridge_content_injuries#edit', regular_inspection_id: '1', injury_id: '1', id: '1')
  25. end
  26. 1 it 'routes to #create' do
  27. 1 expect(
  28. post: '/regular_inspections/1/injuries/1/bridge_content_injuries'
  29. ).to route_to('bridge_content_injuries#create', regular_inspection_id: '1', injury_id: '1')
  30. end
  31. 1 it 'routes to #update via PUT' do
  32. 1 expect(
  33. put: '/regular_inspections/1/injuries/1/bridge_content_injuries/1'
  34. ).to route_to('bridge_content_injuries#update', regular_inspection_id: '1', injury_id: '1', id: '1')
  35. end
  36. 1 it 'routes to #update via PATCH' do
  37. 1 expect(
  38. patch: '/regular_inspections/1/injuries/1/bridge_content_injuries/1'
  39. ).to route_to('bridge_content_injuries#update', regular_inspection_id: '1', injury_id: '1', id: '1')
  40. end
  41. 1 it 'routes to #destroy' do
  42. 1 expect(
  43. delete: '/regular_inspections/1/injuries/1/bridge_content_injuries/1'
  44. ).to route_to('bridge_content_injuries#destroy', regular_inspection_id: '1', injury_id: '1', id: '1')
  45. end
  46. end
  47. end
  48. # rubocop:enable Metrics/BlockLength

spec/routing/bridge_contents_routing_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe BridgeContentsController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(
  8. get: '/regular_inspections/1/bridge_contents'
  9. ).to route_to('bridge_contents#index', regular_inspection_id: '1')
  10. end
  11. 1 it 'routes to #new' do
  12. 1 expect(
  13. get: '/regular_inspections/1/bridge_contents/new'
  14. ).to route_to('bridge_contents#new', regular_inspection_id: '1')
  15. end
  16. 1 it 'routes to #show' do
  17. 1 expect(
  18. get: '/regular_inspections/1/bridge_contents/1'
  19. ).to route_to('bridge_contents#show', regular_inspection_id: '1', id: '1')
  20. end
  21. 1 it 'routes to #edit' do
  22. 1 expect(
  23. get: '/regular_inspections/1/bridge_contents/1/edit'
  24. ).to route_to('bridge_contents#edit', regular_inspection_id: '1', id: '1')
  25. end
  26. 1 it 'routes to #create' do
  27. 1 expect(
  28. post: '/regular_inspections/1/bridge_contents'
  29. ).to route_to('bridge_contents#create', regular_inspection_id: '1')
  30. end
  31. 1 it 'routes to #update via PUT' do
  32. 1 expect(
  33. put: '/regular_inspections/1/bridge_contents/1'
  34. ).to route_to('bridge_contents#update', regular_inspection_id: '1', id: '1')
  35. end
  36. 1 it 'routes to #update via PATCH' do
  37. 1 expect(
  38. patch: '/regular_inspections/1/bridge_contents/1'
  39. ).to route_to('bridge_contents#update', regular_inspection_id: '1', id: '1')
  40. end
  41. 1 it 'routes to #destroy' do
  42. 1 expect(
  43. delete: '/regular_inspections/1/bridge_contents/1'
  44. ).to route_to('bridge_contents#destroy', regular_inspection_id: '1', id: '1')
  45. end
  46. end
  47. end
  48. # rubocop:enable Metrics/BlockLength

spec/routing/bridge_main_contents_routing_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe BridgeMainContentsController, type: :routing do
  4. 1 describe 'routing' do
  5. 1 it 'routes to #create' do
  6. 1 expect(
  7. post: '/regular_inspections/1/bridge_main_contents'
  8. ).to route_to('bridge_main_contents#create', regular_inspection_id: '1')
  9. end
  10. 1 it 'routes to #destroy' do
  11. 1 expect(
  12. delete: '/regular_inspections/1/bridge_main_contents/1'
  13. ).to route_to('bridge_main_contents#destroy', regular_inspection_id: '1', id: '1')
  14. end
  15. end
  16. end

spec/routing/bridges_routing_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe BridgesController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(get: '/bridges').to route_to('bridges#index')
  8. end
  9. 1 it 'routes to #new' do
  10. 1 expect(get: '/bridges/new').to route_to('bridges#new')
  11. end
  12. 1 it 'routes to #show' do
  13. 1 expect(get: '/bridges/1').to route_to('bridges#show', id: '1')
  14. end
  15. 1 it 'routes to #edit' do
  16. 1 expect(get: '/bridges/1/edit').to route_to('bridges#edit', id: '1')
  17. end
  18. 1 it 'routes to #create' do
  19. 1 expect(post: '/bridges').to route_to('bridges#create')
  20. end
  21. 1 it 'routes to #update via PUT' do
  22. 1 expect(put: '/bridges/1').to route_to('bridges#update', id: '1')
  23. end
  24. 1 it 'routes to #update via PATCH' do
  25. 1 expect(patch: '/bridges/1').to route_to('bridges#update', id: '1')
  26. end
  27. 1 it 'routes to #destroy' do
  28. 1 expect(delete: '/bridges/1').to route_to('bridges#destroy', id: '1')
  29. end
  30. end
  31. end
  32. # rubocop:enable Metrics/BlockLength

spec/routing/components_routing_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe ComponentsController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(get: '/bridges/1/components').to route_to('components#index', bridge_id: '1')
  8. end
  9. 1 it 'routes to #new' do
  10. 1 expect(get: '/bridges/1/components/new').to route_to('components#new', bridge_id: '1')
  11. end
  12. 1 it 'routes to #show' do
  13. 1 expect(get: '/bridges/1/components/1').to route_to('components#show', bridge_id: '1', id: '1')
  14. end
  15. 1 it 'routes to #edit' do
  16. 1 expect(get: '/bridges/1/components/1/edit').to route_to('components#edit', bridge_id: '1', id: '1')
  17. end
  18. 1 it 'routes to #create' do
  19. 1 expect(post: '/bridges/1/components').to route_to('components#create', bridge_id: '1')
  20. end
  21. 1 it 'routes to #update via PUT' do
  22. 1 expect(put: '/bridges/1/components/1').to route_to('components#update', bridge_id: '1', id: '1')
  23. end
  24. 1 it 'routes to #update via PATCH' do
  25. 1 expect(patch: '/bridges/1/components/1').to route_to('components#update', bridge_id: '1', id: '1')
  26. end
  27. 1 it 'routes to #destroy' do
  28. 1 expect(delete: '/bridges/1/components/1').to route_to('components#destroy', bridge_id: '1', id: '1')
  29. end
  30. end
  31. end
  32. # rubocop:enable Metrics/BlockLength

spec/routing/diagnoses_routing_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe DiagnosesController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(get: '/regular_inspections/1/diagnoses').to route_to('diagnoses#index', regular_inspection_id: '1')
  8. end
  9. 1 it 'routes to #new' do
  10. 1 expect(get: '/regular_inspections/1/diagnoses/new').to route_to('diagnoses#new', regular_inspection_id: '1')
  11. end
  12. 1 it 'routes to #show' do
  13. 1 expect(get: '/regular_inspections/1/diagnoses/1').to route_to('diagnoses#show',
  14. regular_inspection_id: '1',
  15. id: '1')
  16. end
  17. 1 it 'routes to #edit' do
  18. 1 expect(get: '/regular_inspections/1/diagnoses/1/edit').to route_to('diagnoses#edit',
  19. regular_inspection_id: '1',
  20. id: '1')
  21. end
  22. 1 it 'routes to #create' do
  23. 1 expect(post: '/regular_inspections/1/diagnoses').to route_to('diagnoses#create', regular_inspection_id: '1')
  24. end
  25. 1 it 'routes to #update via PUT' do
  26. 1 expect(put: '/regular_inspections/1/diagnoses/1').to route_to('diagnoses#update',
  27. regular_inspection_id: '1',
  28. id: '1')
  29. end
  30. 1 it 'routes to #update via PATCH' do
  31. 1 expect(patch: '/regular_inspections/1/diagnoses/1').to route_to('diagnoses#update',
  32. regular_inspection_id: '1',
  33. id: '1')
  34. end
  35. 1 it 'routes to #destroy' do
  36. 1 expect(delete: '/regular_inspections/1/diagnoses/1').to route_to('diagnoses#destroy',
  37. regular_inspection_id: '1',
  38. id: '1')
  39. end
  40. end
  41. end
  42. # rubocop:enable Metrics/BlockLength

spec/routing/injuries_routing_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe InjuriesController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(get: '/regular_inspections/1/injuries').to route_to('injuries#index', regular_inspection_id: '1')
  8. end
  9. 1 it 'routes to #new' do
  10. 1 expect(get: '/regular_inspections/1/injuries/new').to route_to('injuries#new', regular_inspection_id: '1')
  11. end
  12. 1 it 'routes to #show' do
  13. 1 expect(get: '/regular_inspections/1/injuries/1').to route_to('injuries#show', regular_inspection_id: '1', id: '1')
  14. end
  15. 1 it 'routes to #edit' do
  16. 1 expect(get: '/regular_inspections/1/injuries/1/edit').to route_to('injuries#edit',
  17. regular_inspection_id: '1',
  18. id: '1')
  19. end
  20. 1 it 'routes to #create' do
  21. 1 expect(post: '/regular_inspections/1/injuries').to route_to('injuries#create', regular_inspection_id: '1')
  22. end
  23. 1 it 'routes to #update via PUT' do
  24. 1 expect(put: '/regular_inspections/1/injuries/1').to route_to('injuries#update',
  25. regular_inspection_id: '1',
  26. id: '1')
  27. end
  28. 1 it 'routes to #update via PATCH' do
  29. 1 expect(patch: '/regular_inspections/1/injuries/1').to route_to('injuries#update',
  30. regular_inspection_id: '1',
  31. id: '1')
  32. end
  33. 1 it 'routes to #destroy' do
  34. 1 expect(delete: '/regular_inspections/1/injuries/1').to route_to('injuries#destroy',
  35. regular_inspection_id: '1',
  36. id: '1')
  37. end
  38. end
  39. end
  40. # rubocop:enable Metrics/BlockLength

spec/routing/regular_inspections_routing_spec.rb

100.0% lines covered

23 relevant lines. 23 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe RegularInspectionsController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(get: '/regular_inspections').to route_to('regular_inspections#index')
  8. end
  9. 1 it 'routes to #new' do
  10. 1 expect(get: '/regular_inspections/new').to route_to('regular_inspections#new')
  11. end
  12. 1 it 'routes to #show' do
  13. 1 expect(get: '/regular_inspections/1').to route_to('regular_inspections#show', id: '1')
  14. end
  15. 1 it 'routes to #edit' do
  16. 1 expect(get: '/regular_inspections/1/edit').to route_to('regular_inspections#edit', id: '1')
  17. end
  18. 1 it 'routes to #create' do
  19. 1 expect(post: '/regular_inspections').to route_to('regular_inspections#create')
  20. end
  21. 1 it 'routes to #update via PUT' do
  22. 1 expect(put: '/regular_inspections/1').to route_to('regular_inspections#update', id: '1')
  23. end
  24. 1 it 'routes to #update via PATCH' do
  25. 1 expect(patch: '/regular_inspections/1').to route_to('regular_inspections#update', id: '1')
  26. end
  27. 1 it 'routes to #destroy' do
  28. 1 expect(delete: '/regular_inspections/1').to route_to('regular_inspections#destroy', id: '1')
  29. end
  30. 1 it 'routes to #download_image_metadata' do
  31. 1 expect(
  32. get: '/regular_inspections/1/download_image_metadata'
  33. ).to route_to('regular_inspections#download_image_metadata', regular_inspection_id: '1')
  34. end
  35. 1 it 'routes to #download_pointcloud_metadata' do
  36. 1 expect(
  37. get: '/regular_inspections/1/download_pointcloud_metadata'
  38. ).to route_to('regular_inspections#download_pointcloud_metadata', regular_inspection_id: '1')
  39. end
  40. end
  41. end
  42. # rubocop:enable Metrics/BlockLength

spec/routing/soundnesses_routing_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. # rubocop:disable Metrics/BlockLength
  4. 1 RSpec.describe SoundnessesController, type: :routing do
  5. 1 describe 'routing' do
  6. 1 it 'routes to #index' do
  7. 1 expect(get: '/bridges/1/soundnesses').to route_to('soundnesses#index', bridge_id: '1')
  8. end
  9. 1 it 'routes to #new' do
  10. 1 expect(get: '/bridges/1/soundnesses/new').to route_to('soundnesses#new', bridge_id: '1')
  11. end
  12. 1 it 'routes to #show' do
  13. 1 expect(get: '/bridges/1/soundnesses/1').to route_to('soundnesses#show', bridge_id: '1', id: '1')
  14. end
  15. 1 it 'routes to #edit' do
  16. 1 expect(get: '/bridges/1/soundnesses/1/edit').to route_to('soundnesses#edit', bridge_id: '1', id: '1')
  17. end
  18. 1 it 'routes to #create' do
  19. 1 expect(post: '/bridges/1/soundnesses').to route_to('soundnesses#create', bridge_id: '1')
  20. end
  21. 1 it 'routes to #update via PUT' do
  22. 1 expect(put: '/bridges/1/soundnesses/1').to route_to('soundnesses#update', bridge_id: '1', id: '1')
  23. end
  24. 1 it 'routes to #update via PATCH' do
  25. 1 expect(patch: '/bridges/1/soundnesses/1').to route_to('soundnesses#update', bridge_id: '1', id: '1')
  26. end
  27. 1 it 'routes to #destroy' do
  28. 1 expect(delete: '/bridges/1/soundnesses/1').to route_to('soundnesses#destroy', bridge_id: '1', id: '1')
  29. end
  30. end
  31. end
  32. # rubocop:enable Metrics/BlockLength

spec/routing/status_routing_spec.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe StatusController, type: :routing do
  4. 1 describe 'routing' do
  5. 1 it 'routes to #index' do
  6. 1 expect(get: '/status.json').to route_to('status#index', format: 'json')
  7. end
  8. end
  9. end

spec/views/admin/users/edit.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'admin/users/edit', type: :view do
  4. 1 before(:each) do
  5. 1 @user = assign(:user, FactoryBot.create(:user))
  6. end
  7. 1 it 'renders the edit user form' do
  8. 1 render
  9. 1 assert_select 'form[action=?][method=?]', admin_user_path(@user), 'post' do
  10. end
  11. end
  12. end

spec/views/admin/users/index.html.slim_spec.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'admin/users/index', type: :view do
  4. 1 before(:each) do
  5. 1 assign(:users, [
  6. FactoryBot.create(:user),
  7. FactoryBot.create(:user)
  8. ])
  9. end
  10. 1 it 'renders a list of admin/users' do
  11. 1 render
  12. end
  13. end

spec/views/admin/users/new.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'admin/users/new', type: :view do
  4. 1 before(:each) do
  5. 1 assign(:user, User.new)
  6. end
  7. 1 it 'renders new user form' do
  8. 1 render
  9. 1 assert_select 'form[action=?][method=?]', admin_users_path, 'post' do
  10. end
  11. end
  12. end

spec/views/admin/users/show.html.slim_spec.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'admin/users/show', type: :view do
  4. 1 before(:each) do
  5. 1 @user = assign(:user, FactoryBot.create(:user))
  6. end
  7. 1 it 'renders attributes in <p>' do
  8. 1 render
  9. end
  10. end

spec/views/bridge_content_injuries/edit.html.slim_spec.rb

100.0% lines covered

10 relevant lines. 10 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridge_content_injuries/edit', type: :view do
  4. 1 before(:each) do
  5. 1 @regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
  6. 1 @bridge_content = FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection)
  7. 1 @injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: @regular_inspection))
  8. 1 @bridge_content_injury = assign(:bridge_content_injury,
  9. FactoryBot.create(:bridge_content_injury,
  10. bridge_content: @bridge_content,
  11. injury: @injury))
  12. end
  13. 1 it 'renders the edit bridge_content_injury form' do
  14. 1 render
  15. 1 assert_select 'form[action=?][method=?]',
  16. regular_inspection_injury_bridge_content_injury_path(@regular_inspection,
  17. @injury,
  18. @bridge_content_injury), 'post' do
  19. end
  20. end
  21. end

spec/views/bridge_content_injuries/index.html.slim_spec.rb

100.0% lines covered

10 relevant lines. 10 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridge_content_injuries/index', type: :view do
  4. 1 before(:each) do
  5. 1 regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
  6. 1 bridge_content1 = FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
  7. 1 bridge_content2 = FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
  8. 1 injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: regular_inspection))
  9. 1 assign(:bridge_content_injuries, [
  10. FactoryBot.create(:bridge_content_injury, bridge_content: bridge_content1, injury: injury),
  11. FactoryBot.create(:bridge_content_injury, bridge_content: bridge_content2, injury: injury)
  12. ])
  13. end
  14. 1 it 'renders a list of bridge_content_injuries' do
  15. 1 render
  16. end
  17. end

spec/views/bridge_content_injuries/new.html.slim_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridge_content_injuries/new', type: :view do
  4. 1 before(:each) do
  5. 1 @regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
  6. 1 @injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: @regular_inspection))
  7. 1 assign(:bridge_content_injury, BridgeContentInjury.new(injury: @injury))
  8. end
  9. 1 it 'renders new bridge_content_injury form' do
  10. 1 render
  11. 1 assert_select 'form[action=?][method=?]',
  12. regular_inspection_injury_bridge_content_injuries_path(@regular_inspection, @injury),
  13. 'post' do
  14. end
  15. end
  16. end

spec/views/bridge_content_injuries/show.html.slim_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridge_content_injuries/show', type: :view do
  4. 1 before(:each) do
  5. 1 regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
  6. 1 bridge_content = FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
  7. 1 injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: regular_inspection))
  8. 1 assign(:bridge_content_injury,
  9. FactoryBot.create(:bridge_content_injury, bridge_content: bridge_content, injury: injury))
  10. end
  11. 1 it 'renders attributes in <p>' do
  12. 1 render
  13. end
  14. end

spec/views/bridge_contents/edit.html.slim_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridge_contents/edit', type: :view do
  4. 1 before(:each) do
  5. 1 assign(:components, [])
  6. 1 @regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
  7. 1 @bridge_content = assign(:bridge_content,
  8. FactoryBot.create(:bridge_content, regular_inspection: @regular_inspection))
  9. end
  10. 1 it 'renders the edit bridge_content form' do
  11. 1 render
  12. 1 assert_select 'form[action=?][method=?]',
  13. regular_inspection_bridge_content_path(@regular_inspection, @bridge_content), 'post' do
  14. end
  15. end
  16. end

spec/views/bridge_contents/index.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridge_contents/index', type: :view do
  4. 1 before(:each) do
  5. 1 regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
  6. 1 assign(:bridge_contents, [
  7. FactoryBot.create(:bridge_content, regular_inspection: regular_inspection),
  8. FactoryBot.create(:bridge_content, regular_inspection: regular_inspection)
  9. ])
  10. end
  11. 1 it 'renders a list of bridge_contents' do
  12. 1 render
  13. end
  14. end

spec/views/bridge_contents/new.html.slim_spec.rb

100.0% lines covered

10 relevant lines. 10 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridge_contents/new', type: :view do
  4. 1 before(:each) do
  5. 1 assign(:components, [])
  6. 1 @regular_inspection = FactoryBot.create(:regular_inspection)
  7. 1 assign(:regular_inspection, @regular_inspection)
  8. 1 assign(:bridge_content, BridgeContent.new(regular_inspection: @regular_inspection))
  9. end
  10. 1 it 'renders new bridge_content form' do
  11. 1 render
  12. 1 assert_select 'form[action=?][method=?]', regular_inspection_bridge_contents_path(@regular_inspection), 'post' do
  13. end
  14. end
  15. end

spec/views/bridge_contents/show.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridge_contents/show', type: :view do
  4. 1 before(:each) do
  5. 1 regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection))
  6. 1 assign(:bridge_content, FactoryBot.create(:bridge_content, regular_inspection: regular_inspection))
  7. end
  8. 1 it 'renders attributes in <p>' do
  9. 1 render
  10. end
  11. end

spec/views/bridges/edit.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridges/edit', type: :view do
  4. 1 before(:each) do
  5. 1 @bridge = FactoryBot.create(:bridge)
  6. end
  7. 1 it 'renders the edit bridge form' do
  8. 1 render
  9. 1 assert_select 'form[action=?][method=?]', bridge_path(@bridge), 'post' do
  10. end
  11. end
  12. end

spec/views/bridges/index.html.slim_spec.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridges/index', type: :view do
  4. 1 before(:each) do
  5. 1 assign(:bridges, [
  6. FactoryBot.create(:bridge),
  7. FactoryBot.create(:bridge)
  8. ])
  9. end
  10. 1 it 'renders a list of bridges' do
  11. 1 render
  12. end
  13. end

spec/views/bridges/new.html.slim_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridges/new', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = Bridge.new
  6. 1 bridge.location = 'POINT(140.084556 36.104611)'
  7. 1 assign(:bridge, bridge)
  8. end
  9. 1 it 'renders new bridge form' do
  10. 1 render
  11. 1 assert_select 'form[action=?][method=?]', bridges_path, 'post' do
  12. end
  13. end
  14. end

spec/views/bridges/show.html.slim_spec.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'bridges/show', type: :view do
  4. 1 before(:each) do
  5. 1 @bridge = FactoryBot.create(:bridge)
  6. end
  7. 1 it 'renders attributes in <p>' do
  8. 1 render
  9. end
  10. end

spec/views/components/edit.html.slim_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'components/edit', type: :view do
  4. 1 before(:each) do
  5. 1 @bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 @component = assign(:component, FactoryBot.create(:component, bridge: @bridge))
  7. end
  8. 1 it 'renders the edit component form' do
  9. 1 render
  10. 1 assert_select 'form[action=?][method=?]', bridge_component_path(@bridge, @component), 'post' do
  11. end
  12. end
  13. end

spec/views/components/index.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'components/index', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 assign(:components, [
  7. FactoryBot.create(:component, bridge: bridge),
  8. FactoryBot.create(:component, bridge: bridge)
  9. ])
  10. end
  11. 1 it 'renders a list of components' do
  12. 1 render
  13. end
  14. end

spec/views/components/new.html.slim_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'components/new', type: :view do
  4. 1 before(:each) do
  5. 1 @bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 assign(:component, Component.new(bridge: @bridge))
  7. end
  8. 1 it 'renders new component form' do
  9. 1 render
  10. 1 assert_select 'form[action=?][method=?]', bridge_components_path(@bridge), 'post' do
  11. end
  12. end
  13. end

spec/views/components/show.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'components/show', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 @component = assign(:component, FactoryBot.create(:component, bridge: bridge))
  7. end
  8. 1 it 'renders attributes in <p>' do
  9. 1 render
  10. end
  11. end

spec/views/diagnoses/edit.html.slim_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'diagnoses/edit', type: :view do
  4. 1 before(:each) do
  5. 1 @regular_inspection = FactoryBot.create(:regular_inspection)
  6. 1 assign(:regular_inspection, @regular_inspection)
  7. 1 @diagnosis = assign(:diagnosis, FactoryBot.create(:diagnosis, regular_inspection: @regular_inspection))
  8. end
  9. 1 it 'renders the edit diagnosis form' do
  10. 1 render
  11. 1 assert_select 'form[action=?][method=?]',
  12. regular_inspection_diagnosis_path(@regular_inspection, @diagnosis),
  13. 'post' do
  14. end
  15. end
  16. end

spec/views/diagnoses/index.html.slim_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'diagnoses/index', type: :view do
  4. 1 before(:each) do
  5. 1 regular_inspection = FactoryBot.create(:regular_inspection)
  6. 1 assign(:regular_inspection, regular_inspection)
  7. 1 assign(:diagnoses, [
  8. FactoryBot.create(:diagnosis, regular_inspection: regular_inspection),
  9. FactoryBot.create(:diagnosis,
  10. regular_inspection: regular_inspection,
  11. component_category: Component.categories[:superstructure_horizontal_grider])
  12. ])
  13. end
  14. 1 it 'renders a list of diagnoses' do
  15. 1 render
  16. end
  17. end

spec/views/diagnoses/new.html.slim_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'diagnoses/new', type: :view do
  4. 1 before(:each) do
  5. 1 @regular_inspection = FactoryBot.create(:regular_inspection)
  6. 1 assign(:regular_inspection, @regular_inspection)
  7. 1 assign(:diagnosis, Diagnosis.new)
  8. end
  9. 1 it 'renders new diagnosis form' do
  10. 1 render
  11. 1 assert_select 'form[action=?][method=?]', regular_inspection_diagnoses_path(@regular_inspection), 'post' do
  12. end
  13. end
  14. end

spec/views/diagnoses/show.html.slim_spec.rb

100.0% lines covered

11 relevant lines. 11 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'diagnoses/show', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = FactoryBot.create(:bridge)
  6. 1 regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
  7. 1 component = FactoryBot.create(:component, bridge: bridge)
  8. 1 injury = FactoryBot.create(:injury, regular_inspection: regular_inspection, component: component)
  9. 1 assign(:regular_inspection, regular_inspection)
  10. 1 @diagnosis = assign(:diagnosis, FactoryBot.create(:diagnosis,
  11. regular_inspection: regular_inspection,
  12. injury: injury))
  13. end
  14. 1 it 'renders attributes in <p>' do
  15. 1 render
  16. end
  17. end

spec/views/injuries/edit.html.slim_spec.rb

100.0% lines covered

11 relevant lines. 11 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'injuries/edit', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = FactoryBot.create(:bridge)
  6. 1 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
  7. 1 assign(:components, [])
  8. 1 assign(:regular_inspection, @regular_inspection)
  9. 1 assign(:injury, Injury.new(regular_inspection: @regular_inspection))
  10. end
  11. 1 it 'renders the edit injury form' do
  12. 1 render
  13. 1 assert_select 'form[action=?][method=?]', regular_inspection_injuries_path(@regular_inspection), 'post' do
  14. end
  15. end
  16. end

spec/views/injuries/index.html.slim_spec.rb

100.0% lines covered

10 relevant lines. 10 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'injuries/index', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = FactoryBot.create(:bridge)
  6. 1 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
  7. 1 component1 = FactoryBot.create(:component, bridge: bridge)
  8. 1 component2 = FactoryBot.create(:component, bridge: bridge)
  9. 1 assign(:injuries, [
  10. FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: component1),
  11. FactoryBot.create(:injury, regular_inspection: @regular_inspection, component: component2)
  12. ])
  13. end
  14. 1 it 'renders a list of injuries' do
  15. 1 render
  16. end
  17. end

spec/views/injuries/new.html.slim_spec.rb

100.0% lines covered

11 relevant lines. 11 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'injuries/new', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = FactoryBot.create(:bridge)
  6. 1 @regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
  7. 1 assign(:components, [])
  8. 1 assign(:regular_inspection, @regular_inspection)
  9. 1 assign(:injury, Injury.new(regular_inspection: @regular_inspection))
  10. end
  11. 1 it 'renders new injury form' do
  12. 1 render
  13. 1 assert_select 'form[action=?][method=?]', regular_inspection_injuries_path(@regular_inspection), 'post' do
  14. end
  15. end
  16. end

spec/views/injuries/show.html.slim_spec.rb

100.0% lines covered

10 relevant lines. 10 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'injuries/show', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = FactoryBot.create(:bridge)
  6. 1 regular_inspection = FactoryBot.create(:regular_inspection, bridge: bridge)
  7. 1 component = FactoryBot.create(:component, bridge: bridge)
  8. 1 assign(:regular_inspection, regular_inspection)
  9. 1 @injury = assign(:injury, FactoryBot.create(:injury, regular_inspection: regular_inspection, component: component))
  10. end
  11. 1 it 'renders attributes in <p>' do
  12. 1 render
  13. end
  14. end

spec/views/mlit_importers/create.html.slim_spec.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'mlit_importers/create.html.slim', type: :view do
  4. 1 pending "add some examples to (or delete) #{__FILE__}"
  5. end

spec/views/mlit_importers/new.html.slim_spec.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'mlit_importers/new.html.slim', type: :view do
  4. 1 pending "add some examples to (or delete) #{__FILE__}"
  5. end

spec/views/mlit_importers/preview.html.slim_spec.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'mlit_importers/preview.html.slim', type: :view do
  4. 1 pending "add some examples to (or delete) #{__FILE__}"
  5. end

spec/views/regular_inspections/edit.html.slim_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'regular_inspections/edit', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 @regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection, bridge: bridge))
  7. end
  8. 1 it 'renders the edit regular_inspection form' do
  9. 1 render
  10. 1 assert_select 'form[action=?][method=?]', regular_inspection_path(@regular_inspection), 'post' do
  11. end
  12. end
  13. end

spec/views/regular_inspections/index.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'regular_inspections/index', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 assign(:regular_inspections, [
  7. FactoryBot.create(:regular_inspection, bridge: bridge),
  8. FactoryBot.create(:regular_inspection, bridge: bridge)
  9. ])
  10. end
  11. 1 it 'renders a list of regular_inspections' do
  12. 1 render
  13. end
  14. end

spec/views/regular_inspections/new.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'regular_inspections/new', type: :view do
  4. 1 before(:each) do
  5. 1 assign(:regular_inspection, RegularInspection.new)
  6. end
  7. 1 it 'renders new regular_inspection form' do
  8. 1 render
  9. 1 assert_select 'form[action=?][method=?]', regular_inspections_path, 'post' do
  10. end
  11. end
  12. end

spec/views/regular_inspections/show.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'regular_inspections/show', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 @regular_inspection = assign(:regular_inspection, FactoryBot.create(:regular_inspection, bridge: bridge))
  7. end
  8. 1 it 'renders attributes in <p>' do
  9. 1 render
  10. end
  11. end

spec/views/soundnesses/edit.html.slim_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'soundnesses/edit', type: :view do
  4. 1 before(:each) do
  5. 1 @bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 @soundness = assign(:soundness, FactoryBot.create(:soundness, bridge: @bridge))
  7. end
  8. 1 it 'renders the edit soundness form' do
  9. 1 render
  10. 1 assert_select 'form[action=?][method=?]', bridge_soundness_path(@bridge, @soundness), 'post' do
  11. end
  12. end
  13. end

spec/views/soundnesses/index.html.slim_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'soundnesses/index', type: :view do
  4. 1 before(:each) do
  5. 1 bridge = FactoryBot.create(:bridge)
  6. 1 assign(:bridge, bridge)
  7. 1 assign(:soundnesses, [
  8. FactoryBot.create(:soundness, bridge: bridge),
  9. FactoryBot.create(:soundness, bridge: bridge)
  10. ])
  11. end
  12. 1 it 'renders a list of soundnesses' do
  13. 1 render
  14. end
  15. end

spec/views/soundnesses/new.html.slim_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'soundnesses/new', type: :view do
  4. 1 before(:each) do
  5. 1 @bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 assign(:soundness, Soundness.new)
  7. end
  8. 1 it 'renders new soundness form' do
  9. 1 render
  10. 1 assert_select 'form[action=?][method=?]', bridge_soundnesses_path(@bridge), 'post' do
  11. end
  12. end
  13. end

spec/views/soundnesses/show.html.slim_spec.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. # frozen_string_literal: true
  2. 1 require 'rails_helper'
  3. 1 RSpec.describe 'soundnesses/show', type: :view do
  4. 1 before(:each) do
  5. 1 @bridge = assign(:bridge, FactoryBot.create(:bridge))
  6. 1 @soundness = assign(:soundness, FactoryBot.create(:soundness, bridge: @bridge))
  7. end
  8. 1 it 'renders attributes in <p>' do
  9. 1 render
  10. end
  11. end