loading
Generated 2021-03-12T09:35:54+00:00

All Files ( 100.0% covered at 2.09 hits/line )

56 files in total.
459 relevant lines, 459 lines covered and 0 lines missed. ( 100.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/helpers/application_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/pages_helper.rb 100.00 % 2 1 1 0 1.00
app/models/application_record.rb 100.00 % 3 2 2 0 1.00
app/models/comment.rb 100.00 % 4 3 3 0 1.00
app/models/email_domain.rb 100.00 % 2 1 1 0 1.00
app/models/floor.rb 100.00 % 4 3 3 0 1.00
app/models/helper.rb 100.00 % 2 1 1 0 1.00
app/models/issue.rb 100.00 % 7 6 6 0 1.00
app/models/material.rb 100.00 % 4 3 3 0 1.00
app/models/member.rb 100.00 % 31 17 17 0 1.00
app/models/notification.rb 100.00 % 3 2 2 0 1.00
app/models/priority.rb 100.00 % 3 2 2 0 1.00
app/models/rank.rb 100.00 % 3 2 2 0 1.00
app/models/room.rb 100.00 % 18 11 11 0 2.55
app/models/setting.rb 100.00 % 3 2 2 0 1.00
app/models/state.rb 100.00 % 3 2 2 0 1.00
config/application.rb 100.00 % 45 24 24 0 1.00
config/boot.rb 100.00 % 4 3 3 0 1.00
config/environment.rb 100.00 % 5 2 2 0 1.00
config/environments/test.rb 100.00 % 49 15 15 0 1.00
config/initializers/application_controller_renderer.rb 100.00 % 8 0 0 0 0.00
config/initializers/assets.rb 100.00 % 14 2 2 0 1.00
config/initializers/backtrace_silencers.rb 100.00 % 7 0 0 0 0.00
config/initializers/content_security_policy.rb 100.00 % 30 0 0 0 0.00
config/initializers/cookies_serializer.rb 100.00 % 5 1 1 0 1.00
config/initializers/cors.rb 100.00 % 10 4 4 0 1.00
config/initializers/filter_parameter_logging.rb 100.00 % 4 1 1 0 1.00
config/initializers/inflections.rb 100.00 % 16 0 0 0 0.00
config/initializers/mime_types.rb 100.00 % 4 0 0 0 0.00
config/initializers/secure_headers.rb 100.00 % 37 8 8 0 1.00
config/initializers/session_store.rb 100.00 % 7 2 2 0 1.00
config/initializers/wrap_parameters.rb 100.00 % 14 2 2 0 1.50
config/routes.rb 100.00 % 70 49 49 0 1.02
spec/factories/floors.rb 100.00 % 6 4 4 0 9.00
spec/factories/issues.rb 100.00 % 11 9 9 0 3.67
spec/factories/materials.rb 100.00 % 7 5 5 0 5.80
spec/factories/members.rb 100.00 % 19 15 15 0 8.67
spec/factories/priorities.rb 100.00 % 5 3 3 0 3.67
spec/factories/ranks.rb 100.00 % 5 3 3 0 8.67
spec/factories/rooms.rb 100.00 % 10 8 8 0 13.00
spec/factories/settings.rb 100.00 % 9 7 7 0 4.57
spec/factories/states.rb 100.00 % 6 4 4 0 5.00
spec/models/comment_spec.rb 100.00 % 35 18 18 0 1.61
spec/models/email_domain_spec.rb 100.00 % 31 16 16 0 1.56
spec/models/floor_spec.rb 100.00 % 31 16 16 0 1.56
spec/models/helper_spec.rb 100.00 % 31 16 16 0 1.56
spec/models/issue_spec.rb 100.00 % 33 17 17 0 1.47
spec/models/material_spec.rb 100.00 % 31 16 16 0 1.56
spec/models/member_spec.rb 100.00 % 31 16 16 0 1.56
spec/models/notification_spec.rb 100.00 % 32 17 17 0 1.47
spec/models/priority_spec.rb 100.00 % 31 16 16 0 1.56
spec/models/rank_spec.rb 100.00 % 42 22 22 0 1.55
spec/models/room_spec.rb 100.00 % 31 16 16 0 1.56
spec/models/setting_spec.rb 100.00 % 31 16 16 0 1.56
spec/models/state_spec.rb 100.00 % 31 16 16 0 1.56
spec/rails_helper.rb 100.00 % 66 11 11 0 1.00

app/helpers/application_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module ApplicationHelper
  2. end

app/helpers/pages_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module PagesHelper
  2. end

app/models/application_record.rb

100.0% lines covered

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

app/models/comment.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. 1 class Comment < ApplicationRecord
  2. 1 belongs_to :member
  3. 1 belongs_to :issue
  4. end

app/models/email_domain.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 class EmailDomain < ApplicationRecord
  2. end

app/models/floor.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. 1 class Floor < ApplicationRecord
  2. 1 has_many :rooms, dependent: :destroy
  3. 1 has_one_attached :image
  4. end

app/models/helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 class Helper < ApplicationRecord
  2. end

app/models/issue.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 class Issue < ApplicationRecord
  2. 1 belongs_to :member, class_name: 'Member', optional: true
  3. 1 belongs_to :material
  4. 1 belongs_to :state
  5. 1 belongs_to :priority
  6. 1 has_many :comments, dependent: :destroy
  7. end

app/models/material.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. 1 class Material < ApplicationRecord
  2. 1 belongs_to :room
  3. 1 has_many :issues, dependent: :destroy
  4. end

app/models/member.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. 1 class Member < ApplicationRecord
  2. #session
  3. 1 has_secure_password
  4. 1 validates :email, presence: true
  5. 1 validates :email, uniqueness: true
  6. 1 validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
  7. 1 before_destroy :remove_user_notification
  8. 1 belongs_to :rank
  9. 1 has_many :issues, dependent: :destroy
  10. 1 has_many :comments, dependent: :destroy
  11. 1 has_many :notifications, dependent: :destroy
  12. 1 has_many :member_issues, class_name: 'Issue', foreign_key: 'member_id', dependent: :destroy
  13. 1 has_many :room_members
  14. 1 has_many :rooms, through: :room_members
  15. 1 trigger.before(:update).of(:rank_id) do
  16. 1 <<-SQL
  17. IF (SELECT r.name FROM ranks r WHERE r.id = NEW.rank_id) = 'Administrateur' THEN
  18. SET NEW.activate2FA = TRUE;
  19. ELSE
  20. SET NEW.activate2FA = FALSE;
  21. END IF;
  22. SQL
  23. end
  24. 1 def remove_user_notification
  25. 1 ActiveRecord::Base.connection.execute("DELETE FROM room_members WHERE member_id = #{self.id};")
  26. end
  27. end

app/models/notification.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. 1 class Notification < ApplicationRecord
  2. 1 belongs_to :member
  3. end

app/models/priority.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. 1 class Priority < ApplicationRecord
  2. 1 has_many :issues, dependent: :destroy
  3. end

app/models/rank.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. 1 class Rank < ApplicationRecord
  2. 1 has_many :members, dependent: :destroy
  3. end

app/models/room.rb

100.0% lines covered

11 relevant lines. 11 lines covered and 0 lines missed.
    
  1. 1 class Room < ApplicationRecord
  2. 1 has_many :materials, dependent: :destroy
  3. 1 has_many :room_members
  4. 1 has_many :members, through: :room_members
  5. 1 before_create :nameify
  6. 1 before_update :nameify
  7. 1 before_destroy :remove_user_notification
  8. 1 def nameify
  9. 18 self.name_url = name.parameterize
  10. end
  11. 1 def remove_user_notification
  12. 1 ActiveRecord::Base.connection.execute("DELETE FROM room_members WHERE room_id = #{self.id};")
  13. end
  14. end

app/models/setting.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. 1 class Setting < ApplicationRecord
  2. 1 attr_encrypted :pswd, key: 'This is a key that is 256 bits!!'
  3. end

app/models/state.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. 1 class State < ApplicationRecord
  2. 1 has_many :issues, dependent: :destroy
  3. end

config/application.rb

100.0% lines covered

24 relevant lines. 24 lines covered and 0 lines missed.
    
  1. 1 require_relative 'boot'
  2. 1 require "rails"
  3. # Pick the frameworks you want:
  4. 1 require "active_model/railtie"
  5. 1 require "active_job/railtie"
  6. 1 require "active_record/railtie"
  7. 1 require "active_storage/engine"
  8. 1 require "action_controller/railtie"
  9. 1 require "action_mailer/railtie"
  10. 1 require "action_mailbox/engine"
  11. 1 require "action_text/engine"
  12. 1 require "action_view/railtie"
  13. 1 require "action_cable/engine"
  14. 1 require "sprockets/railtie"
  15. # require "rails/test_unit/railtie"
  16. # Require the gems listed in Gemfile, including any gems
  17. # you've limited to :test, :development, or :production.
  18. 1 Bundler.require(*Rails.groups)
  19. 1 module WebApp
  20. 1 class Application < Rails::Application
  21. # Initialize configuration defaults for originally generated Rails version.
  22. 1 config.load_defaults 6.0
  23. # Settings in config/environments/* take precedence over those specified here.
  24. # Application configuration can go into files in config/initializers
  25. # -- all .rb files in that directory are automatically loaded after loading
  26. # the framework and any gems in your application.
  27. # Don't generate system test files.
  28. 1 config.generators.system_tests = nil
  29. 1 config.before_configuration do
  30. 1 env_file = File.join(Rails.root, 'config', 'local_env.yml')
  31. YAML.load(File.open(env_file)).each do |key, value|
  32. 1 ENV[key.to_s] = value
  33. 1 end if File.exists?(env_file)
  34. end
  35. 1 config.middleware.use ActionDispatch::Cookies
  36. 1 config.middleware.use ActionDispatch::Session::CookieStore
  37. end
  38. end

config/boot.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. 1 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
  2. 1 require 'bundler/setup' # Set up gems listed in the Gemfile.
  3. 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. # Load the Rails application.
  2. 1 require_relative 'application'
  3. # Initialize the Rails application.
  4. 1 Rails.application.initialize!

config/environments/test.rb

100.0% lines covered

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

config/initializers/application_controller_renderer.rb

100.0% lines covered

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

config/initializers/assets.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. # Be sure to restart your server when you modify this file.
  2. # Version of your assets, change this if you want to expire all your assets.
  3. 1 Rails.application.config.assets.version = '1.0'
  4. # Add additional assets to the asset load path.
  5. # Rails.application.config.assets.paths << Emoji.images_path
  6. # Add Yarn node_modules folder to the asset load path.
  7. 1 Rails.application.config.assets.paths << Rails.root.join('node_modules')
  8. # Precompile additional assets.
  9. # application.js, application.css, and all non-JS/CSS in the app/assets
  10. # folder are already added.
  11. # 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. # Be sure to restart your server when you modify this file.
  2. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
  3. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
  4. # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
  5. # 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. # Be sure to restart your server when you modify this file.
  2. # Define an application-wide content security policy
  3. # For further information see the following documentation
  4. # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
  5. # Rails.application.config.content_security_policy do |policy|
  6. # policy.default_src :self, :https
  7. # policy.font_src :self, :https, :data
  8. # policy.img_src :self, :https, :data
  9. # policy.object_src :none
  10. # policy.script_src :self, :https
  11. # policy.style_src :self, :https
  12. # # If you are using webpack-dev-server then specify webpack-dev-server host
  13. # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
  14. # # Specify URI for violation reports
  15. # # policy.report_uri "/csp-violation-report-endpoint"
  16. # end
  17. # If you are using UJS then enable automatic nonce generation
  18. # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
  19. # Set the nonce only to specific directives
  20. # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
  21. # Report CSP violations to a specified URI
  22. # For further information see the following documentation:
  23. # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
  24. # 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. # Be sure to restart your server when you modify this file.
  2. # Specify a serializer for the signed and encrypted cookie jars.
  3. # Valid options are :json, :marshal, and :hybrid.
  4. 1 Rails.application.config.action_dispatch.cookies_serializer = :hybrid

config/initializers/cors.rb

100.0% lines covered

4 relevant lines. 4 lines covered and 0 lines missed.
    
  1. 1 Rails.application.config.middleware.insert_before 0, Rack::Cors do
  2. 1 allow do
  3. 1 origins '*' #'http://localhost:3000'
  4. 1 resource '*',
  5. headers: :any,
  6. methods: [:get, :post, :put, :patch, :delete, :options, :head],
  7. credentials: false #true
  8. end
  9. end

config/initializers/filter_parameter_logging.rb

100.0% lines covered

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

config/initializers/mime_types.rb

100.0% lines covered

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

config/initializers/secure_headers.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. 1 SecureHeaders::Configuration.default do |config|
  2. 1 config.cookies = {
  3. secure: true, # mark all cookies as "Secure"
  4. httponly: true, # mark all cookies as "HttpOnly"
  5. }
  6. 1 config.x_content_type_options = "nosniff"
  7. 1 config.x_xss_protection = "1; mode=block"
  8. 1 config.csp = {
  9. 1 default_src: Rails.env.production? ? %w(https: 'self' 'unsafe-inline') : %w(http: 'self' 'unsafe-inline'),
  10. base_uri: %w(
  11. 'self'
  12. ),
  13. form_action: %w(
  14. 'self'
  15. ),
  16. connect_src: %w(
  17. 'self'
  18. ),
  19. font_src: %w(
  20. 'self'
  21. https://fonts.gstatic.com
  22. ),
  23. img_src: %w(
  24. 'self'
  25. https://yt3.ggpht.com
  26. ),
  27. script_src: %w(
  28. 'self'
  29. 'unsafe-inline'
  30. https://*.cloudfront.net)
  31. }
  32. # Use the following if you have CSP issues locally with
  33. # tools like webpack-dev-server
  34. 1 if !Rails.env.production?
  35. 1 config.csp[:connect_src] << "*"
  36. end
  37. end

config/initializers/session_store.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. 1 if Rails.env === 'production'
  2. skipped # :nocov:
  3. skipped Rails.application.config.session_store :cookie_store, key: '_web-app', domain: 'web-app-json-api'
  4. skipped # :nocov:
  5. else
  6. 1 Rails.application.config.session_store :cookie_store, key: '_web-app'
  7. end

config/initializers/wrap_parameters.rb

100.0% lines covered

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

config/routes.rb

100.0% lines covered

49 relevant lines. 49 lines covered and 0 lines missed.
    
  1. 1 Rails.application.routes.draw do
  2. 1 root 'pages#index'
  3. 1 namespace :api do
  4. 1 resources :members, only: [:update, :create, :show, :index, :destroy]
  5. 1 resources :rooms, param: :name_url
  6. 1 resources :issues, only: [:update, :create, :show, :index, :destroy]
  7. 1 resources :materials, only: [:update, :create, :show, :index, :destroy]
  8. 1 resources :ranks, only: [:update, :create, :show, :index, :destroy]
  9. 1 resources :floors, only: [:update, :create, :show, :index, :destroy]
  10. 1 resources :states, only: [:update, :show, :create, :index, :destroy]
  11. 1 resources :priorities, only: [:update, :create, :show, :index, :destroy]
  12. 1 resources :notifications, only: [:update, :create, :show, :index, :destroy]
  13. 1 resources :comments, only: [:update, :create, :show, :index, :destroy]
  14. 1 resources :helpers, only: [:index, :create, :update, :destroy]
  15. 1 resources :email_domains, only: [:index, :show, :create, :update, :destroy]
  16. 1 resources :room_members, only: [:create]
  17. 1 resources :settings, only: [:index]
  18. 1 post '/comments/mobile', to: 'comments#create_mobile'
  19. 1 get '/materials/room/:name_url', to: 'materials#index_by_room'
  20. 1 patch '/floors/image/:id', to: 'floors#update_img'
  21. 1 get '/states/manage/get', to: 'states#manageState'
  22. 1 get '/states/manage/getIdClose', to: 'states#getIdCloseState'
  23. 1 post '/room_members/delete', to: 'room_members#delete'
  24. 1 post '/mailer/sendMaterial', to: 'mailers#sendEmailMaterial'
  25. 1 get '/issues/room/:name_url', to: 'issues#index_by_room'
  26. 1 get '/issues/get/all', to: 'issues#all'
  27. 1 get '/issues/get/all/:id', to: 'issues#allByMember'
  28. 1 post '/issues/mobile', to: 'issues#create_mobile'
  29. 1 post '/rooms/create', to: 'rooms#create'
  30. 1 get '/rooms/where/:floor_id', to: 'rooms#index_floor'
  31. 1 get '/rooms/mobile/where/:floor_id', to: 'rooms#index_floor_mobile'
  32. 1 get '/rooms/localisation/:localisation', to: 'rooms#index_coords'
  33. 1 get '/rooms/informations/:name_url', to: 'rooms#informations'
  34. 1 get '/rooms/notified/:room_id', to: 'rooms#notified'
  35. 1 post '/2fa/send', to: 'twofa#sender'
  36. 1 post '/2fa/handle', to: 'twofa#handle2FA'
  37. 1 patch '/2fa/generate-code/:id', to: 'twofa#generate2FACode'
  38. 1 patch '/settings/update/mail', to: 'settings#updateMailSettings'
  39. 1 get '/members/token/:id', to: 'tokens#create'
  40. 1 get '/members/validate_token/:token', to: 'tokens#validate_token'
  41. 1 post '/auth/login', to: 'sessions#create'
  42. 1 get '/auth/anonymous', to: 'sessions#create_anonymous'
  43. 1 get '/auth/remove-anonymous', to: 'sessions#remove_anonymous'
  44. 1 get '/auth/is-anonymous', to: 'sessions#anonymous?'
  45. 1 post '/auth/checkLogin', to: 'sessions#checkLogin'
  46. 1 get '/auth/logout', to: 'sessions#destroy'
  47. 1 get '/auth/logged_in', to: 'sessions#is_logged_in?'
  48. 1 get '/members/get/tech', to: 'members#all_technicians'
  49. 1 patch '/members/last-connection/:id', to: 'members#updateLastConnection'
  50. end
  51. skipped # :nocov:
  52. skipped get '*path', to: 'pages#index', constraints: lambda { |req|
  53. skipped req.path.exclude? 'rails/active_storage'
  54. skipped }
  55. skipped # :nocov:
  56. end

spec/factories/floors.rb

100.0% lines covered

4 relevant lines. 4 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :floor do
  3. 17 name { 'Étage 8' }
  4. 17 plan_source { 'truc.png' }
  5. end
  6. end

spec/factories/issues.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :issue, aliases: [:ticket] do
  3. 9 description {"Test"}
  4. 9 title {'Ticket'}
  5. 1 material
  6. 1 member
  7. 1 state
  8. 1 priority
  9. 9 technician { nil }
  10. end
  11. end

spec/factories/materials.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :material, aliases: [:item] do
  3. 13 name { "Chaise" }
  4. 13 quantity { 28 }
  5. 1 room
  6. end
  7. end

spec/factories/members.rb

100.0% lines covered

15 relevant lines. 15 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :member, aliases: [:user] do
  3. 1 rank
  4. 23 firstname {'Test'}
  5. 23 lastname {'Membre'}
  6. 23 email { "#{SecureRandom.alphanumeric(15)}@truc.org"}
  7. 23 password {'azeaze'}
  8. 23 user_verified {false}
  9. 1 factory :member_2, aliases: [:user2] do
  10. 1 rank
  11. 2 firstname {'Membre'}
  12. 2 lastname {'NuméroDeux'}
  13. 2 email {"#{SecureRandom.alphanumeric(15)}@test.fr"}
  14. 2 password {'azerergfvdwx'}
  15. 2 user_verified {true}
  16. end
  17. end
  18. end

spec/factories/priorities.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :priority do
  3. 9 sequence(:name) { |i| "Priorité n° #{i}" }
  4. end
  5. end

spec/factories/ranks.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :rank, aliases: [:rang] do
  3. 24 sequence(:name) { |i| "Rang n° #{i}" }
  4. end
  5. end

spec/factories/rooms.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :room do
  3. 17 name { 'Salle 24' }
  4. 17 position_x { '17.22' }
  5. 17 position_y { '8.36' }
  6. 17 localisation_gps { '128.36,39.280,52.123' }
  7. 17 name_url { name.parameterize }
  8. 17 floor_id { FactoryBot.create(:floor).id }
  9. end
  10. end

spec/factories/settings.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :setting do
  3. 6 mailSmtpAddress { 'smtp.gmail.com' }
  4. 6 mailSmtpPort { 587 }
  5. 6 mailAddress { 'azerty@uiop.fr' }
  6. 6 encrypted_pswd { SecureRandom.alphanumeric(255) }
  7. 6 encrypted_pswd_iv { SecureRandom.alphanumeric(18) }
  8. end
  9. end

spec/factories/states.rb

100.0% lines covered

4 relevant lines. 4 lines covered and 0 lines missed.
    
  1. 1 FactoryBot.define do
  2. 1 factory :state, aliases: [:etat] do
  3. 9 name { 'État de test' }
  4. 9 order { 2 }
  5. end
  6. end

spec/models/comment_spec.rb

100.0% lines covered

18 relevant lines. 18 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Comment, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 i = Issue.create(description: "Test", title: 'test issue', material: Material.first, member: Member.first,
  6. state: State.first, technician: nil )
  7. 4 @comment = Comment.create(description: 'Test description', member: FactoryBot.create(:user),
  8. issue: FactoryBot.create(:issue))
  9. end
  10. 1 it 'should persist a comment' do
  11. 2 expect{ Comment.create(description: 'Test description', member: Member.first, issue: Issue.first) }
  12. 2 .to change{ Comment.count }.by(1)
  13. end
  14. 1 it 'should update a comment' do
  15. 1 @comment.update(description: 'Lorem ipsum')
  16. 1 expect(@comment.description).to eq('Lorem ipsum')
  17. end
  18. 1 it 'should delete a comment' do
  19. 1 comment = Comment.last
  20. 4 expect{ comment.destroy }.to change{ Comment.count }.by(-1)
  21. end
  22. 1 it 'should read comments' do
  23. 1 comments = Comment.all
  24. 1 expect(Comment.count).to eq(comments.count)
  25. end
  26. end
  27. end

spec/models/email_domain_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe EmailDomain, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @domain = EmailDomain.create(name: 'test.org')
  6. end
  7. 1 it 'should persist a domain' do
  8. 4 expect{ EmailDomain.create(name: 'other-test.fr') }.to change{ EmailDomain.count }.by(1)
  9. end
  10. 1 it 'should update a domain' do
  11. 1 @domain.update(name: 'test.fr')
  12. 1 expect(@domain.name).to eq('test.fr')
  13. end
  14. 1 it 'should delete a domain' do
  15. 1 domain = EmailDomain.last
  16. 4 expect{ domain.destroy }.to change{ EmailDomain.count }.by(-1)
  17. end
  18. 1 it 'should read domain' do
  19. 1 domains = EmailDomain.all
  20. 1 expect(EmailDomain.count).to eq(domains.count)
  21. end
  22. end
  23. end

spec/models/floor_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Floor, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @floor = Floor.create(name: 'test')
  6. end
  7. 1 it 'should persist a floor' do
  8. 4 expect{ Floor.create(name: 'Floor') }.to change{ Floor.count }.by(1)
  9. end
  10. 1 it 'should update a floor' do
  11. 1 @floor.update(plan_source: 'test.png')
  12. 1 expect(@floor.plan_source).to eq('test.png')
  13. end
  14. 1 it 'should delete a floor' do
  15. 1 floor = Floor.last
  16. 4 expect{ floor.destroy }.to change{ Floor.count }.by(-1)
  17. end
  18. 1 it 'should read floors' do
  19. 1 floors = Floor.all
  20. 1 expect(Floor.count).to eq(floors.count)
  21. end
  22. end
  23. end

spec/models/helper_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Helper, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @helper = Helper.create(heading: 'Title test', description: 'test')
  6. end
  7. 1 it 'should persist a helper' do
  8. 4 expect{ Helper.create(heading: 'Helper') }.to change{ Helper.count }.by(1)
  9. end
  10. 1 it 'should update a helper' do
  11. 1 @helper.update(description: 'A description')
  12. 1 expect(@helper.description).to eq('A description')
  13. end
  14. 1 it 'should delete a helper' do
  15. 1 helper = Helper.last
  16. 4 expect{ helper.destroy }.to change{ Helper.count }.by(-1)
  17. end
  18. 1 it 'should read helpers' do
  19. 1 helpers = Helper.all
  20. 1 expect(Helper.count).to eq(helpers.count)
  21. end
  22. end
  23. end

spec/models/issue_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Issue, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @issue = FactoryBot.create(:issue)
  6. end
  7. 1 it 'should persist an issue' do
  8. 2 expect{ Issue.create(description: "Azerty", title: 'Test2', member: Member.first,
  9. material: Material.first, state: State.first, priority: Priority.first) }
  10. 2 .to change{ Issue.count }.by(1)
  11. end
  12. 1 it 'should update an issue' do
  13. 1 @issue.update(technician: 'Alberto Gonzales')
  14. 1 expect(@issue.technician).to eq('Alberto Gonzales')
  15. end
  16. 1 it 'should delete an issue' do
  17. 1 issue = Issue.last
  18. 4 expect{ issue.destroy }.to change{ Issue.count }.by(-1)
  19. end
  20. 1 it 'should read issues' do
  21. 1 issues = Issue.all
  22. 1 expect(Issue.count).to eq(issues.count)
  23. end
  24. end
  25. end

spec/models/material_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Material, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @material = FactoryBot.create(:item)
  6. end
  7. 1 it 'should persist a material' do
  8. 4 expect{ Material.create(room: Room.first, name: 'name', quantity: 1) }.to change{ Material.count }.by(1)
  9. end
  10. 1 it 'should update a material' do
  11. 1 @material.update(quantity: 123)
  12. 1 expect(@material.quantity).to eq(123)
  13. end
  14. 1 it 'should delete a material' do
  15. 1 material = Material.last
  16. 4 expect{ material.destroy }.to change{ Material.count }.by(-1)
  17. end
  18. 1 it 'should read materials' do
  19. 1 materials = Material.all
  20. 1 expect(Material.count).to eq(materials.count)
  21. end
  22. end
  23. end

spec/models/member_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Member, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @member = FactoryBot.create(:member)
  6. end
  7. 1 it 'should persist a member' do
  8. 4 expect{ FactoryBot.create(:member) }.to change{ Member.count }.by(1)
  9. end
  10. 1 it 'should update a member' do
  11. 1 @member.update(firstname: 'name')
  12. 1 expect(@member.firstname).to eq('name')
  13. end
  14. 1 it 'should delete a member' do
  15. 1 member = Member.last
  16. 4 expect{ member.destroy }.to change{ Member.count }.by(-1)
  17. end
  18. 1 it 'should read members' do
  19. 1 members = Member.all
  20. 1 expect(Member.count).to eq(members.count)
  21. end
  22. end
  23. end

spec/models/notification_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Notification, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @notification = Notification.create(description: 'Test', member: FactoryBot.create(:user))
  6. end
  7. 1 it 'should persist a notification' do
  8. 2 expect{ Notification.create(description: 'Notification', member: FactoryBot.create(:member_2)) }.
  9. 2 to change{ Notification.count }.by(1)
  10. end
  11. 1 it 'should update a notification' do
  12. 1 @notification.update(description: 'A description')
  13. 1 expect(@notification.description).to eq('A description')
  14. end
  15. 1 it 'should delete a notification' do
  16. 1 notification = Notification.last
  17. 4 expect{ notification.destroy }.to change{ Notification.count }.by(-1)
  18. end
  19. 1 it 'should read notifications' do
  20. 1 notifications = Notification.all
  21. 1 expect(Notification.count).to eq(notifications.count)
  22. end
  23. end
  24. end

spec/models/priority_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Priority, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @prio = Priority.create(name: 'test')
  6. end
  7. 1 it 'should persist a priority' do
  8. 4 expect{ Priority.create(name: 'Test') }.to change{ Priority.count }.by(1)
  9. end
  10. 1 it 'should update a priority' do
  11. 1 @prio.update(name: 'New name')
  12. 1 expect(@prio.name).to eq('New name')
  13. end
  14. 1 it 'should delete a priority' do
  15. 1 priority = Priority.last
  16. 4 expect{ priority.destroy }.to change{ Priority.count }.by(-1)
  17. end
  18. 1 it 'should read priorities' do
  19. 1 priorities = Priority.all
  20. 1 expect(Priority.count).to eq(priorities.count)
  21. end
  22. end
  23. end

spec/models/rank_spec.rb

100.0% lines covered

22 relevant lines. 22 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Rank, type: :model do
  3. 1 context 'Member association' do
  4. 1 it 'should increment member count' do
  5. 1 rank = Rank.new(name: 'Test')
  6. 1 rank.members << FactoryBot.build(:user)
  7. 4 expect{ rank.save }.to change{Member.count}.by(1)
  8. end
  9. end
  10. 1 context 'CRUD' do
  11. 1 before do
  12. 4 @rank = Rank.create(name: 'test')
  13. end
  14. 1 it 'should persist a rank' do
  15. 4 expect{ Rank.create(name: 'Test') }.to change{ Rank.count }.by(1)
  16. end
  17. 1 it 'should update a rank' do
  18. 1 @rank = Rank.first
  19. 1 @rank.update(name: 'New name')
  20. 1 expect(@rank.name).to eq('New name')
  21. end
  22. 1 it 'should delete a rank' do
  23. 1 rank = Rank.last
  24. 4 expect{ rank.destroy }.to change{ Rank.count }.by(-1)
  25. end
  26. 1 it 'should read ranks' do
  27. 1 ranks = Rank.all
  28. 1 expect(Rank.count).to eq(ranks.count)
  29. end
  30. end
  31. end

spec/models/room_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Room, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @room = FactoryBot.create(:room)
  6. end
  7. 1 it 'should persist a room' do
  8. 4 expect{ Room.create(name: 'Salle 12', floor_id: Floor.first.id) }.to change{ Room.count }.by(1)
  9. end
  10. 1 it 'should update a room' do
  11. 1 @room.update(position_y: '1478.23')
  12. 1 expect(@room.position_y).to eq('1478.23')
  13. end
  14. 1 it 'should delete a room' do
  15. 1 room = Room.last
  16. 4 expect{ room.destroy }.to change{ Room.count }.by(-1)
  17. end
  18. 1 it 'should read rooms' do
  19. 1 rooms = Room.all
  20. 1 expect(Room.count).to eq(rooms.count)
  21. end
  22. end
  23. end

spec/models/setting_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe Setting, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @setting = FactoryBot.create(:setting)
  6. end
  7. 1 it 'should persist a setting' do
  8. 4 expect{ FactoryBot.create(:setting) }.to change{ Setting.count }.by(1)
  9. end
  10. 1 it 'should update a setting' do
  11. 1 @setting.update(mailSmtpPort: 514)
  12. 1 expect(@setting.mailSmtpPort).to eq(514)
  13. end
  14. 1 it 'should delete a setting' do
  15. 1 setting = Setting.last
  16. 4 expect{ setting.destroy }.to change{ Setting.count }.by(-1)
  17. end
  18. 1 it 'should read settings' do
  19. 1 settings = Setting.all
  20. 1 expect(Setting.count).to eq(settings.count)
  21. end
  22. end
  23. end

spec/models/state_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. 1 require 'rails_helper'
  2. 1 RSpec.describe State, type: :model do
  3. 1 context 'CRUD' do
  4. 1 before do
  5. 4 @state = State.create(name: 'test')
  6. end
  7. 1 it 'should persist a state' do
  8. 4 expect{ State.create(name: 'Test') }.to change{ State.count }.by(1)
  9. end
  10. 1 it 'should update a state' do
  11. 1 @state.update(order: 4)
  12. 1 expect(@state.order).to eq(4)
  13. end
  14. 1 it 'should delete a state' do
  15. 1 state = State.last
  16. 4 expect{ state.destroy }.to change{ State.count }.by(-1)
  17. end
  18. 1 it 'should read states' do
  19. 1 states = State.all
  20. 1 expect(State.count).to eq(states.count)
  21. end
  22. end
  23. end

spec/rails_helper.rb

100.0% lines covered

11 relevant lines. 11 lines covered and 0 lines missed.
    
  1. # This file is copied to spec/ when you run 'rails generate rspec:install'
  2. 1 require 'spec_helper'
  3. 1 ENV['RAILS_ENV'] ||= 'test'
  4. 1 require File.expand_path('../config/environment', __dir__)
  5. # Prevent database truncation if the environment is production
  6. 1 abort("The Rails environment is running in production mode!") if Rails.env.production?
  7. 1 require 'rspec/rails'
  8. # Add additional requires below this line. Rails is not loaded until this point!
  9. # Requires supporting ruby files with custom matchers and macros, etc, in
  10. # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
  11. # run as spec files by default. This means that files in spec/support that end
  12. # in _spec.rb will both be required and run as specs, causing the specs to be
  13. # run twice. It is recommended that you do not name files matching this glob to
  14. # end with _spec.rb. You can configure this pattern with the --pattern
  15. # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
  16. #
  17. # The following line is provided for convenience purposes. It has the downside
  18. # of increasing the boot-up time by auto-requiring all files in the support
  19. # directory. Alternatively, in the individual `*_spec.rb` files, manually
  20. # require only the support files necessary.
  21. #
  22. # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
  23. # Checks for pending migrations and applies them before tests are run.
  24. # If you are not using ActiveRecord, you can remove these lines.
  25. begin
  26. 1 ActiveRecord::Migration.maintain_test_schema!
  27. rescue ActiveRecord::PendingMigrationError => e
  28. skipped # :nocov:
  29. skipped puts e.to_s.strip
  30. skipped exit 1
  31. skipped # :nocov:
  32. end
  33. 1 RSpec.configure do |config|
  34. # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  35. 1 config.fixture_path = "#{::Rails.root}/spec/fixtures"
  36. # If you're not using ActiveRecord, or you'd prefer not to run each of your
  37. # examples within a transaction, remove the following line or assign false
  38. # instead of true.
  39. 1 config.use_transactional_fixtures = true
  40. # You can uncomment this line to turn off ActiveRecord support entirely.
  41. # config.use_active_record = false
  42. # RSpec Rails can automatically mix in different behaviours to your tests
  43. # based on their file location, for example enabling you to call `get` and
  44. # `post` in specs under `spec/controllers`.
  45. #
  46. # You can disable this behaviour by removing the line below, and instead
  47. # explicitly tag your specs with their type, e.g.:
  48. #
  49. # RSpec.describe UsersController, type: :controller do
  50. # # ...
  51. # end
  52. #
  53. # The different available types are documented in the features, such as in
  54. # https://relishapp.com/rspec/rspec-rails/docs
  55. 1 config.infer_spec_type_from_file_location!
  56. # Filter lines from Rails gems in backtraces.
  57. 1 config.filter_rails_from_backtrace!
  58. # arbitrary gems may also be filtered via:
  59. # config.filter_gems_from_backtrace("gem name")
  60. end