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%
)
- 1
module ApplicationHelper
end
- 1
module PagesHelper
end
- 1
class ApplicationRecord < ActiveRecord::Base
- 1
self.abstract_class = true
end
- 1
class Comment < ApplicationRecord
- 1
belongs_to :member
- 1
belongs_to :issue
end
- 1
class EmailDomain < ApplicationRecord
end
- 1
class Floor < ApplicationRecord
- 1
has_many :rooms, dependent: :destroy
- 1
has_one_attached :image
end
- 1
class Helper < ApplicationRecord
end
- 1
class Issue < ApplicationRecord
- 1
belongs_to :member, class_name: 'Member', optional: true
- 1
belongs_to :material
- 1
belongs_to :state
- 1
belongs_to :priority
- 1
has_many :comments, dependent: :destroy
end
- 1
class Material < ApplicationRecord
- 1
belongs_to :room
- 1
has_many :issues, dependent: :destroy
end
- 1
class Member < ApplicationRecord
#session
- 1
has_secure_password
- 1
validates :email, presence: true
- 1
validates :email, uniqueness: true
- 1
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
- 1
before_destroy :remove_user_notification
- 1
belongs_to :rank
- 1
has_many :issues, dependent: :destroy
- 1
has_many :comments, dependent: :destroy
- 1
has_many :notifications, dependent: :destroy
- 1
has_many :member_issues, class_name: 'Issue', foreign_key: 'member_id', dependent: :destroy
- 1
has_many :room_members
- 1
has_many :rooms, through: :room_members
- 1
trigger.before(:update).of(:rank_id) do
- 1
<<-SQL
IF (SELECT r.name FROM ranks r WHERE r.id = NEW.rank_id) = 'Administrateur' THEN
SET NEW.activate2FA = TRUE;
ELSE
SET NEW.activate2FA = FALSE;
END IF;
SQL
end
- 1
def remove_user_notification
- 1
ActiveRecord::Base.connection.execute("DELETE FROM room_members WHERE member_id = #{self.id};")
end
end
- 1
class Notification < ApplicationRecord
- 1
belongs_to :member
end
- 1
class Priority < ApplicationRecord
- 1
has_many :issues, dependent: :destroy
end
- 1
class Rank < ApplicationRecord
- 1
has_many :members, dependent: :destroy
end
- 1
class Room < ApplicationRecord
- 1
has_many :materials, dependent: :destroy
- 1
has_many :room_members
- 1
has_many :members, through: :room_members
- 1
before_create :nameify
- 1
before_update :nameify
- 1
before_destroy :remove_user_notification
- 1
def nameify
- 18
self.name_url = name.parameterize
end
- 1
def remove_user_notification
- 1
ActiveRecord::Base.connection.execute("DELETE FROM room_members WHERE room_id = #{self.id};")
end
end
- 1
class Setting < ApplicationRecord
- 1
attr_encrypted :pswd, key: 'This is a key that is 256 bits!!'
end
- 1
class State < ApplicationRecord
- 1
has_many :issues, dependent: :destroy
end
- 1
require_relative 'boot'
- 1
require "rails"
# Pick the frameworks you want:
- 1
require "active_model/railtie"
- 1
require "active_job/railtie"
- 1
require "active_record/railtie"
- 1
require "active_storage/engine"
- 1
require "action_controller/railtie"
- 1
require "action_mailer/railtie"
- 1
require "action_mailbox/engine"
- 1
require "action_text/engine"
- 1
require "action_view/railtie"
- 1
require "action_cable/engine"
- 1
require "sprockets/railtie"
# require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
- 1
Bundler.require(*Rails.groups)
- 1
module WebApp
- 1
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
- 1
config.load_defaults 6.0
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
# Don't generate system test files.
- 1
config.generators.system_tests = nil
- 1
config.before_configuration do
- 1
env_file = File.join(Rails.root, 'config', 'local_env.yml')
YAML.load(File.open(env_file)).each do |key, value|
- 1
ENV[key.to_s] = value
- 1
end if File.exists?(env_file)
end
- 1
config.middleware.use ActionDispatch::Cookies
- 1
config.middleware.use ActionDispatch::Session::CookieStore
end
end
- 1
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
- 1
require 'bundler/setup' # Set up gems listed in the Gemfile.
- 1
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
# Load the Rails application.
- 1
require_relative 'application'
# Initialize the Rails application.
- 1
Rails.application.initialize!
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
- 1
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
- 1
config.cache_classes = false
- 1
config.action_view.cache_template_loading = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
- 1
config.eager_load = false
# Configure public file server for tests with Cache-Control for performance.
- 1
config.public_file_server.enabled = true
- 1
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching.
- 1
config.consider_all_requests_local = true
- 1
config.action_controller.perform_caching = false
- 1
config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates.
- 1
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
- 1
config.action_controller.allow_forgery_protection = false
# Store uploaded files on the local file system in a temporary directory.
- 1
config.active_storage.service = :test
- 1
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
- 1
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
- 1
config.active_support.deprecation = :stderr
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
end
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
- 1
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
- 1
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Rails.application.config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# Rails.application.config.content_security_policy_report_only = true
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
- 1
Rails.application.config.action_dispatch.cookies_serializer = :hybrid
- 1
Rails.application.config.middleware.insert_before 0, Rack::Cors do
- 1
allow do
- 1
origins '*' #'http://localhost:3000'
- 1
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head],
credentials: false #true
end
end
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
- 1
Rails.application.config.filter_parameters += [:password]
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
- 1
SecureHeaders::Configuration.default do |config|
- 1
config.cookies = {
secure: true, # mark all cookies as "Secure"
httponly: true, # mark all cookies as "HttpOnly"
}
- 1
config.x_content_type_options = "nosniff"
- 1
config.x_xss_protection = "1; mode=block"
- 1
config.csp = {
- 1
default_src: Rails.env.production? ? %w(https: 'self' 'unsafe-inline') : %w(http: 'self' 'unsafe-inline'),
base_uri: %w(
'self'
),
form_action: %w(
'self'
),
connect_src: %w(
'self'
),
font_src: %w(
'self'
https://fonts.gstatic.com
),
img_src: %w(
'self'
https://yt3.ggpht.com
),
script_src: %w(
'self'
'unsafe-inline'
https://*.cloudfront.net)
}
# Use the following if you have CSP issues locally with
# tools like webpack-dev-server
- 1
if !Rails.env.production?
- 1
config.csp[:connect_src] << "*"
end
end
- 1
if Rails.env === 'production'
- skipped
# :nocov:
- skipped
Rails.application.config.session_store :cookie_store, key: '_web-app', domain: 'web-app-json-api'
- skipped
# :nocov:
else
- 1
Rails.application.config.session_store :cookie_store, key: '_web-app'
end
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
- 1
ActiveSupport.on_load(:action_controller) do
- 2
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end
- 1
Rails.application.routes.draw do
- 1
root 'pages#index'
- 1
namespace :api do
- 1
resources :members, only: [:update, :create, :show, :index, :destroy]
- 1
resources :rooms, param: :name_url
- 1
resources :issues, only: [:update, :create, :show, :index, :destroy]
- 1
resources :materials, only: [:update, :create, :show, :index, :destroy]
- 1
resources :ranks, only: [:update, :create, :show, :index, :destroy]
- 1
resources :floors, only: [:update, :create, :show, :index, :destroy]
- 1
resources :states, only: [:update, :show, :create, :index, :destroy]
- 1
resources :priorities, only: [:update, :create, :show, :index, :destroy]
- 1
resources :notifications, only: [:update, :create, :show, :index, :destroy]
- 1
resources :comments, only: [:update, :create, :show, :index, :destroy]
- 1
resources :helpers, only: [:index, :create, :update, :destroy]
- 1
resources :email_domains, only: [:index, :show, :create, :update, :destroy]
- 1
resources :room_members, only: [:create]
- 1
resources :settings, only: [:index]
- 1
post '/comments/mobile', to: 'comments#create_mobile'
- 1
get '/materials/room/:name_url', to: 'materials#index_by_room'
- 1
patch '/floors/image/:id', to: 'floors#update_img'
- 1
get '/states/manage/get', to: 'states#manageState'
- 1
get '/states/manage/getIdClose', to: 'states#getIdCloseState'
- 1
post '/room_members/delete', to: 'room_members#delete'
- 1
post '/mailer/sendMaterial', to: 'mailers#sendEmailMaterial'
- 1
get '/issues/room/:name_url', to: 'issues#index_by_room'
- 1
get '/issues/get/all', to: 'issues#all'
- 1
get '/issues/get/all/:id', to: 'issues#allByMember'
- 1
post '/issues/mobile', to: 'issues#create_mobile'
- 1
post '/rooms/create', to: 'rooms#create'
- 1
get '/rooms/where/:floor_id', to: 'rooms#index_floor'
- 1
get '/rooms/mobile/where/:floor_id', to: 'rooms#index_floor_mobile'
- 1
get '/rooms/localisation/:localisation', to: 'rooms#index_coords'
- 1
get '/rooms/informations/:name_url', to: 'rooms#informations'
- 1
get '/rooms/notified/:room_id', to: 'rooms#notified'
- 1
post '/2fa/send', to: 'twofa#sender'
- 1
post '/2fa/handle', to: 'twofa#handle2FA'
- 1
patch '/2fa/generate-code/:id', to: 'twofa#generate2FACode'
- 1
patch '/settings/update/mail', to: 'settings#updateMailSettings'
- 1
get '/members/token/:id', to: 'tokens#create'
- 1
get '/members/validate_token/:token', to: 'tokens#validate_token'
- 1
post '/auth/login', to: 'sessions#create'
- 1
get '/auth/anonymous', to: 'sessions#create_anonymous'
- 1
get '/auth/remove-anonymous', to: 'sessions#remove_anonymous'
- 1
get '/auth/is-anonymous', to: 'sessions#anonymous?'
- 1
post '/auth/checkLogin', to: 'sessions#checkLogin'
- 1
get '/auth/logout', to: 'sessions#destroy'
- 1
get '/auth/logged_in', to: 'sessions#is_logged_in?'
- 1
get '/members/get/tech', to: 'members#all_technicians'
- 1
patch '/members/last-connection/:id', to: 'members#updateLastConnection'
end
- skipped
# :nocov:
- skipped
get '*path', to: 'pages#index', constraints: lambda { |req|
- skipped
req.path.exclude? 'rails/active_storage'
- skipped
}
- skipped
# :nocov:
end
- 1
FactoryBot.define do
- 1
factory :floor do
- 17
name { 'Étage 8' }
- 17
plan_source { 'truc.png' }
end
end
- 1
FactoryBot.define do
- 1
factory :issue, aliases: [:ticket] do
- 9
description {"Test"}
- 9
title {'Ticket'}
- 1
material
- 1
member
- 1
state
- 1
priority
- 9
technician { nil }
end
end
- 1
FactoryBot.define do
- 1
factory :material, aliases: [:item] do
- 13
name { "Chaise" }
- 13
quantity { 28 }
- 1
room
end
end
- 1
FactoryBot.define do
- 1
factory :member, aliases: [:user] do
- 1
rank
- 23
firstname {'Test'}
- 23
lastname {'Membre'}
- 23
email { "#{SecureRandom.alphanumeric(15)}@truc.org"}
- 23
password {'azeaze'}
- 23
user_verified {false}
- 1
factory :member_2, aliases: [:user2] do
- 1
rank
- 2
firstname {'Membre'}
- 2
lastname {'NuméroDeux'}
- 2
email {"#{SecureRandom.alphanumeric(15)}@test.fr"}
- 2
password {'azerergfvdwx'}
- 2
user_verified {true}
end
end
end
- 1
FactoryBot.define do
- 1
factory :priority do
- 9
sequence(:name) { |i| "Priorité n° #{i}" }
end
end
- 1
FactoryBot.define do
- 1
factory :rank, aliases: [:rang] do
- 24
sequence(:name) { |i| "Rang n° #{i}" }
end
end
- 1
FactoryBot.define do
- 1
factory :room do
- 17
name { 'Salle 24' }
- 17
position_x { '17.22' }
- 17
position_y { '8.36' }
- 17
localisation_gps { '128.36,39.280,52.123' }
- 17
name_url { name.parameterize }
- 17
floor_id { FactoryBot.create(:floor).id }
end
end
- 1
FactoryBot.define do
- 1
factory :setting do
- 6
mailSmtpAddress { 'smtp.gmail.com' }
- 6
mailSmtpPort { 587 }
- 6
mailAddress { 'azerty@uiop.fr' }
- 6
encrypted_pswd { SecureRandom.alphanumeric(255) }
- 6
encrypted_pswd_iv { SecureRandom.alphanumeric(18) }
end
end
- 1
FactoryBot.define do
- 1
factory :state, aliases: [:etat] do
- 9
name { 'État de test' }
- 9
order { 2 }
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Comment, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
i = Issue.create(description: "Test", title: 'test issue', material: Material.first, member: Member.first,
state: State.first, technician: nil )
- 4
@comment = Comment.create(description: 'Test description', member: FactoryBot.create(:user),
issue: FactoryBot.create(:issue))
end
- 1
it 'should persist a comment' do
- 2
expect{ Comment.create(description: 'Test description', member: Member.first, issue: Issue.first) }
- 2
.to change{ Comment.count }.by(1)
end
- 1
it 'should update a comment' do
- 1
@comment.update(description: 'Lorem ipsum')
- 1
expect(@comment.description).to eq('Lorem ipsum')
end
- 1
it 'should delete a comment' do
- 1
comment = Comment.last
- 4
expect{ comment.destroy }.to change{ Comment.count }.by(-1)
end
- 1
it 'should read comments' do
- 1
comments = Comment.all
- 1
expect(Comment.count).to eq(comments.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe EmailDomain, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@domain = EmailDomain.create(name: 'test.org')
end
- 1
it 'should persist a domain' do
- 4
expect{ EmailDomain.create(name: 'other-test.fr') }.to change{ EmailDomain.count }.by(1)
end
- 1
it 'should update a domain' do
- 1
@domain.update(name: 'test.fr')
- 1
expect(@domain.name).to eq('test.fr')
end
- 1
it 'should delete a domain' do
- 1
domain = EmailDomain.last
- 4
expect{ domain.destroy }.to change{ EmailDomain.count }.by(-1)
end
- 1
it 'should read domain' do
- 1
domains = EmailDomain.all
- 1
expect(EmailDomain.count).to eq(domains.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Floor, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@floor = Floor.create(name: 'test')
end
- 1
it 'should persist a floor' do
- 4
expect{ Floor.create(name: 'Floor') }.to change{ Floor.count }.by(1)
end
- 1
it 'should update a floor' do
- 1
@floor.update(plan_source: 'test.png')
- 1
expect(@floor.plan_source).to eq('test.png')
end
- 1
it 'should delete a floor' do
- 1
floor = Floor.last
- 4
expect{ floor.destroy }.to change{ Floor.count }.by(-1)
end
- 1
it 'should read floors' do
- 1
floors = Floor.all
- 1
expect(Floor.count).to eq(floors.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Helper, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@helper = Helper.create(heading: 'Title test', description: 'test')
end
- 1
it 'should persist a helper' do
- 4
expect{ Helper.create(heading: 'Helper') }.to change{ Helper.count }.by(1)
end
- 1
it 'should update a helper' do
- 1
@helper.update(description: 'A description')
- 1
expect(@helper.description).to eq('A description')
end
- 1
it 'should delete a helper' do
- 1
helper = Helper.last
- 4
expect{ helper.destroy }.to change{ Helper.count }.by(-1)
end
- 1
it 'should read helpers' do
- 1
helpers = Helper.all
- 1
expect(Helper.count).to eq(helpers.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Issue, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@issue = FactoryBot.create(:issue)
end
- 1
it 'should persist an issue' do
- 2
expect{ Issue.create(description: "Azerty", title: 'Test2', member: Member.first,
material: Material.first, state: State.first, priority: Priority.first) }
- 2
.to change{ Issue.count }.by(1)
end
- 1
it 'should update an issue' do
- 1
@issue.update(technician: 'Alberto Gonzales')
- 1
expect(@issue.technician).to eq('Alberto Gonzales')
end
- 1
it 'should delete an issue' do
- 1
issue = Issue.last
- 4
expect{ issue.destroy }.to change{ Issue.count }.by(-1)
end
- 1
it 'should read issues' do
- 1
issues = Issue.all
- 1
expect(Issue.count).to eq(issues.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Material, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@material = FactoryBot.create(:item)
end
- 1
it 'should persist a material' do
- 4
expect{ Material.create(room: Room.first, name: 'name', quantity: 1) }.to change{ Material.count }.by(1)
end
- 1
it 'should update a material' do
- 1
@material.update(quantity: 123)
- 1
expect(@material.quantity).to eq(123)
end
- 1
it 'should delete a material' do
- 1
material = Material.last
- 4
expect{ material.destroy }.to change{ Material.count }.by(-1)
end
- 1
it 'should read materials' do
- 1
materials = Material.all
- 1
expect(Material.count).to eq(materials.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Member, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@member = FactoryBot.create(:member)
end
- 1
it 'should persist a member' do
- 4
expect{ FactoryBot.create(:member) }.to change{ Member.count }.by(1)
end
- 1
it 'should update a member' do
- 1
@member.update(firstname: 'name')
- 1
expect(@member.firstname).to eq('name')
end
- 1
it 'should delete a member' do
- 1
member = Member.last
- 4
expect{ member.destroy }.to change{ Member.count }.by(-1)
end
- 1
it 'should read members' do
- 1
members = Member.all
- 1
expect(Member.count).to eq(members.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Notification, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@notification = Notification.create(description: 'Test', member: FactoryBot.create(:user))
end
- 1
it 'should persist a notification' do
- 2
expect{ Notification.create(description: 'Notification', member: FactoryBot.create(:member_2)) }.
- 2
to change{ Notification.count }.by(1)
end
- 1
it 'should update a notification' do
- 1
@notification.update(description: 'A description')
- 1
expect(@notification.description).to eq('A description')
end
- 1
it 'should delete a notification' do
- 1
notification = Notification.last
- 4
expect{ notification.destroy }.to change{ Notification.count }.by(-1)
end
- 1
it 'should read notifications' do
- 1
notifications = Notification.all
- 1
expect(Notification.count).to eq(notifications.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Priority, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@prio = Priority.create(name: 'test')
end
- 1
it 'should persist a priority' do
- 4
expect{ Priority.create(name: 'Test') }.to change{ Priority.count }.by(1)
end
- 1
it 'should update a priority' do
- 1
@prio.update(name: 'New name')
- 1
expect(@prio.name).to eq('New name')
end
- 1
it 'should delete a priority' do
- 1
priority = Priority.last
- 4
expect{ priority.destroy }.to change{ Priority.count }.by(-1)
end
- 1
it 'should read priorities' do
- 1
priorities = Priority.all
- 1
expect(Priority.count).to eq(priorities.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Rank, type: :model do
- 1
context 'Member association' do
- 1
it 'should increment member count' do
- 1
rank = Rank.new(name: 'Test')
- 1
rank.members << FactoryBot.build(:user)
- 4
expect{ rank.save }.to change{Member.count}.by(1)
end
end
- 1
context 'CRUD' do
- 1
before do
- 4
@rank = Rank.create(name: 'test')
end
- 1
it 'should persist a rank' do
- 4
expect{ Rank.create(name: 'Test') }.to change{ Rank.count }.by(1)
end
- 1
it 'should update a rank' do
- 1
@rank = Rank.first
- 1
@rank.update(name: 'New name')
- 1
expect(@rank.name).to eq('New name')
end
- 1
it 'should delete a rank' do
- 1
rank = Rank.last
- 4
expect{ rank.destroy }.to change{ Rank.count }.by(-1)
end
- 1
it 'should read ranks' do
- 1
ranks = Rank.all
- 1
expect(Rank.count).to eq(ranks.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Room, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@room = FactoryBot.create(:room)
end
- 1
it 'should persist a room' do
- 4
expect{ Room.create(name: 'Salle 12', floor_id: Floor.first.id) }.to change{ Room.count }.by(1)
end
- 1
it 'should update a room' do
- 1
@room.update(position_y: '1478.23')
- 1
expect(@room.position_y).to eq('1478.23')
end
- 1
it 'should delete a room' do
- 1
room = Room.last
- 4
expect{ room.destroy }.to change{ Room.count }.by(-1)
end
- 1
it 'should read rooms' do
- 1
rooms = Room.all
- 1
expect(Room.count).to eq(rooms.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe Setting, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@setting = FactoryBot.create(:setting)
end
- 1
it 'should persist a setting' do
- 4
expect{ FactoryBot.create(:setting) }.to change{ Setting.count }.by(1)
end
- 1
it 'should update a setting' do
- 1
@setting.update(mailSmtpPort: 514)
- 1
expect(@setting.mailSmtpPort).to eq(514)
end
- 1
it 'should delete a setting' do
- 1
setting = Setting.last
- 4
expect{ setting.destroy }.to change{ Setting.count }.by(-1)
end
- 1
it 'should read settings' do
- 1
settings = Setting.all
- 1
expect(Setting.count).to eq(settings.count)
end
end
end
- 1
require 'rails_helper'
- 1
RSpec.describe State, type: :model do
- 1
context 'CRUD' do
- 1
before do
- 4
@state = State.create(name: 'test')
end
- 1
it 'should persist a state' do
- 4
expect{ State.create(name: 'Test') }.to change{ State.count }.by(1)
end
- 1
it 'should update a state' do
- 1
@state.update(order: 4)
- 1
expect(@state.order).to eq(4)
end
- 1
it 'should delete a state' do
- 1
state = State.last
- 4
expect{ state.destroy }.to change{ State.count }.by(-1)
end
- 1
it 'should read states' do
- 1
states = State.all
- 1
expect(State.count).to eq(states.count)
end
end
end
# This file is copied to spec/ when you run 'rails generate rspec:install'
- 1
require 'spec_helper'
- 1
ENV['RAILS_ENV'] ||= 'test'
- 1
require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production
- 1
abort("The Rails environment is running in production mode!") if Rails.env.production?
- 1
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove these lines.
begin
- 1
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
- skipped
# :nocov:
- skipped
puts e.to_s.strip
- skipped
exit 1
- skipped
# :nocov:
end
- 1
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- 1
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
- 1
config.use_transactional_fixtures = true
# You can uncomment this line to turn off ActiveRecord support entirely.
# config.use_active_record = false
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, type: :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
- 1
config.infer_spec_type_from_file_location!
# Filter lines from Rails gems in backtraces.
- 1
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end