diff --git a/.gitignore b/.gitignore index ca8c327d..c2c807d7 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,6 @@ # .idea/misc.xml # *.ipr -# End of https://www.gitignore.io/api/ruby,rails,rubymine \ No newline at end of file +# End of https://www.gitignore.io/api/ruby,rails,rubymine + +/coverage/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..7f78ee20 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "git.ignoreLimitWarning": true, + "python.pythonPath": "C:\\Users\\Lucas\\AppData\\Local\\Programs\\Python\\Python39\\python.exe" +} \ No newline at end of file diff --git a/Gemfile b/Gemfile index bfc41880..da6ffa02 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,6 @@ gem 'jbuilder', '~> 2.5' # Use ActiveModel has_secure_password gem 'bcrypt', '~> 3.1.7' -gem 'webdrivers', '~> 4.0' # Uses HAML templates gem 'haml' @@ -53,6 +52,9 @@ gem 'jquery-rails' # Uses nokogiri gem gem 'nokogiri' + + gem 'cycromatic' + group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] @@ -81,7 +83,7 @@ group :test do gem 'launchy' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome - gem 'webdrivers' + # gem 'webdrivers' # Adds the RSpec stuff gem 'rspec-rails' # RSpec diff --git a/Gemfile.lock b/Gemfile.lock index c2dba9cb..cafb2ee8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,48 +20,43 @@ GIT GEM remote: https://rubygems.org/ specs: - - abstract_type (0.0.7) - actioncable (5.2.4) - actionpack (= 5.2.4) + actioncable (5.2.6) + actionpack (= 5.2.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4) - actionpack (= 5.2.4) - actionview (= 5.2.4) - activejob (= 5.2.4) + actionmailer (5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4) - actionview (= 5.2.4) - activesupport (= 5.2.4) - rack (~> 2.0) + actionpack (5.2.6) + actionview (= 5.2.6) + activesupport (= 5.2.6) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4) - activesupport (= 5.2.4) - + actionview (5.2.6) + activesupport (= 5.2.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - - activejob (5.2.4) - activesupport (= 5.2.4) + activejob (5.2.6) + activesupport (= 5.2.6) globalid (>= 0.3.6) - activemodel (5.2.4) - activesupport (= 5.2.4) - activerecord (5.2.4) - activemodel (= 5.2.4) - activesupport (= 5.2.4) + activemodel (5.2.6) + activesupport (= 5.2.6) + activerecord (5.2.6) + activemodel (= 5.2.6) + activesupport (= 5.2.6) arel (>= 9.0) - activestorage (5.2.4) - actionpack (= 5.2.4) - activerecord (= 5.2.4) - marcel (~> 0.3.1) - activesupport (5.2.4) - + activestorage (5.2.6) + actionpack (= 5.2.6) + activerecord (= 5.2.6) + marcel (~> 1.0.0) + activesupport (5.2.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -70,14 +65,12 @@ GEM public_suffix (>= 2.0.2, < 5.0) arel (9.0.0) arrayfields (4.9.2) - ast (2.4.2) - autoprefixer-rails (10.2.4.0) - - execjs + autoprefixer-rails (10.2.5.0) + execjs (< 2.8.0) bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.7.3) + bootsnap (1.7.5) msgpack (~> 1.0) bootstrap (4.3.1) autoprefixer-rails (>= 9.1.0) @@ -114,7 +107,6 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.8) crass (1.0.6) cucumber (5.3.0) @@ -143,13 +135,12 @@ GEM cucumber-messages (~> 13.0, >= 13.0.1) cucumber-messages (13.2.1) protobuf-cucumber (~> 3.10, >= 3.10.8) - cucumber-rails (2.2.0) + cucumber-rails (2.3.0) capybara (>= 2.18, < 4) cucumber (>= 3.0.2, < 6) mime-types (~> 3.2) - nokogiri (~> 1.8) - rails (>= 5.0, < 7) + railties (>= 5.0, < 7) cucumber-rails-training-wheels (1.0.0) cucumber-rails (>= 1.1.1) cucumber-tag-expressions (2.0.4) @@ -157,26 +148,28 @@ GEM cucumber-core (~> 8.0, >= 8.0.1) cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) cucumber-messages (~> 13.0, >= 13.0.1) + cycromatic (0.1.3) + parser (~> 2.3) + rainbow (~> 2.1) database_cleaner (2.0.1) database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.0) + database_cleaner-active_record (2.0.1) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) diff-lcs (1.4.4) - docile (1.3.5) + docile (1.4.0) erubi (1.10.0) erubis (2.7.0) execjs (2.7.0) - factory_bot (6.1.0) + factory_bot (6.2.0) activesupport (>= 5.0.0) - factory_bot_rails (6.1.0) - factory_bot (~> 6.1.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) railties (>= 5.0.0) fattr (2.4.0) - ffi (1.15.0) - + ffi (1.15.0-x64-mingw32) flay (2.12.1) erubis (~> 2.7.0) path_expander (~> 1.0) @@ -189,9 +182,7 @@ GEM formatador (0.2.5) globalid (0.4.2) activesupport (>= 4.2.0) - - guard (2.16.2) - + guard (2.17.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) @@ -215,22 +206,16 @@ GEM html2haml (>= 1.0.1) railties (>= 5.1) hirb (0.7.3) - html2haml (2.2.0) erubis (~> 2.7.0) haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - http-accept (1.7.0) - http-cookie (1.0.3) - domain_name (~> 0.5) - i18n (1.7.0) + i18n (1.8.10) concurrent-ruby (~> 1.0) - ice_nine (0.11.2) - jbuilder (2.9.1) - activesupport (>= 4.2.0) - jquery-rails (4.3.5) - + jbuilder (2.11.2) + activesupport (>= 5.0.0) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) @@ -242,9 +227,7 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - - loofah (2.9.0) - + loofah (2.9.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.2.8) @@ -256,48 +239,45 @@ GEM fattr (~> 2.2, >= 2.2.0) map (~> 6.1, >= 6.1.0) map (6.6.0) - marcel (0.3.3) - mimemagic (~> 0.3.2) + marcel (1.0.1) method_source (1.0.0) metric_fu-Saikuro (1.1.3) middleware (0.1.0) mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2021.0225) - mimemagic (0.3.6) - mini_mime (1.0.2) - - - mini_portile2 (2.4.0) - minitest (5.13.0) - msgpack (1.3.1) - multi_json (1.14.1) - + mini_mime (1.1.0) + mini_portile2 (2.5.1) + minitest (5.14.4) + msgpack (1.4.2) + multi_json (1.15.0) multi_test (0.1.2) nenv (0.3.0) - netrc (0.11.0) - nio4r (2.5.2) - nokogiri (1.10.7) - mini_portile2 (~> 2.4.0) + nio4r (2.5.7) + nokogiri (1.11.4) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) + nokogiri (1.11.4-x64-mingw32) + racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.19.1) - parser (2.5.3.0) - ast (~> 2.4.0) - + parallel (1.20.1) + parser (2.7.2.0) + ast (~> 2.4.1) path_expander (1.1.0) pg (1.2.3) + pg (1.2.3-x64-mingw32) popper_js (1.16.0) protobuf-cucumber (3.10.8) activesupport (>= 3.2) middleware thor thread_safe - pry (0.14.0) + pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) - psych (3.3.1) + psych (3.3.2) public_suffix (4.0.6) puma (3.12.6) racc (1.5.2) @@ -305,20 +285,18 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) railroady (1.5.3) - - rails (5.2.4.5) - actioncable (= 5.2.4.5) - actionmailer (= 5.2.4.5) - actionpack (= 5.2.4.5) - actionview (= 5.2.4.5) - activejob (= 5.2.4.5) - activemodel (= 5.2.4.5) - activerecord (= 5.2.4.5) - activestorage (= 5.2.4.5) - activesupport (= 5.2.4.5) + rails (5.2.6) + actioncable (= 5.2.6) + actionmailer (= 5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) + activemodel (= 5.2.6) + activerecord (= 5.2.6) + activestorage (= 5.2.6) + activesupport (= 5.2.6) bundler (>= 1.3.0) - railties (= 5.2.4.5) - + railties (= 5.2.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -329,31 +307,30 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - rails_best_practices (1.20.0) + rails_best_practices (1.20.1) activesupport - code_analyzer (>= 0.5.1) + code_analyzer (>= 0.5.2) erubis i18n json require_all (~> 3.0) ruby-progressbar - - railties (5.2.4.5) - actionpack (= 5.2.4.5) - activesupport (= 5.2.4.5) + railties (5.2.6) + actionpack (= 5.2.6) + activesupport (= 5.2.6) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) + rainbow (2.2.2) + rake rake (13.0.3) - rb-fsevent (0.10.4) + rb-fsevent (0.11.0) rb-inotify (0.10.1) - ffi (~> 1.0) redcard (1.1.0) - reek (6.0.3) + reek (6.0.2) kwalify (~> 0.7.0) - parser (~> 3.0.0) + parser (>= 2.5.0.0, < 2.8, != 2.5.1.1) psych (~> 3.1) rainbow (>= 2.0, < 4.0) regexp_parser (2.1.1) @@ -383,10 +360,8 @@ GEM rspec-support (3.10.2) ruby-progressbar (1.11.0) ruby_dep (1.5.0) - - ruby_parser (3.15.1) - - sexp_processor (~> 4.9) + ruby_parser (3.16.0) + sexp_processor (~> 4.15, >= 4.15.1) rubyzip (2.3.0) sass (3.7.4) sass-listen (~> 4.0.0) @@ -401,6 +376,8 @@ GEM tilt (>= 1.1, < 3) sassc (2.4.0) ffi (~> 1.9) + sassc (2.4.0-x64-mingw32) + ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) sassc (>= 2.0) @@ -410,14 +387,14 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - sexp_processor (4.15.2) + sexp_processor (4.15.3) shellany (0.0.1) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.2) + simplecov_json_formatter (0.1.3) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) @@ -440,6 +417,8 @@ GEM turbolinks-source (5.2.0) tzinfo (1.2.9) thread_safe (~> 0.1) + tzinfo-data (1.2021.1) + tzinfo (>= 1.0.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) web-console (3.7.0) @@ -447,22 +426,19 @@ GEM activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - - - webdrivers (4.1.3) + webdrivers (4.6.0) nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) - websocket-driver (0.7.1) - - + websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS - x86_64-linux + ruby + x64-mingw32 DEPENDENCIES bcrypt (~> 3.1.7) @@ -473,6 +449,7 @@ DEPENDENCIES coffee-rails (~> 4.2) cucumber-rails cucumber-rails-training-wheels + cycromatic database_cleaner factory_bot_rails guard-rspec @@ -499,12 +476,10 @@ DEPENDENCIES tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) - webdrivers (~> 4.0) - RUBY VERSION ruby 2.7.2p137 BUNDLED WITH - 2.2.9 + 2.1.4 diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb index dce794e9..e3ccafd0 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admins_controller.rb @@ -1,6 +1,7 @@ class AdminsController < ApplicationController def index ; end + def new ; end def create diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 9f93d455..05e69632 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -216,10 +216,10 @@ def extrai_campos_turma(node) def carregar_disciplinas(disciplinas) disciplinas.each do |d| - if !Disciplina.find_by_cod_disciplina(d[:cod_disciplina]) + if !Disciplina.find_by_id_disciplina(d[:id]) criar_disciplina( - d[:cod_disciplina], + d[:id], d[:nome_disciplina], d[:creditos] ) @@ -229,8 +229,9 @@ def carregar_disciplinas(disciplinas) ## # Método para criar uma disciplina no modelo. - def criar_disciplina(cod_disciplina, nome, creditos) + def criar_disciplina(id_disciplina,cod_disciplina, nome, creditos) Disciplina.create( + :id=> id_disciplina, :cod_disciplina => cod_disciplina, :nome => nome, :c_prat => creditos[:c_prat], diff --git a/app/controllers/disciplinas_controller.rb b/app/controllers/disciplinas_controller.rb index 1631d12c..dc38d254 100644 --- a/app/controllers/disciplinas_controller.rb +++ b/app/controllers/disciplinas_controller.rb @@ -3,10 +3,24 @@ class DisciplinasController < ApplicationController before_action :is_admin, only: [:edit, :new, :create, :update, :destroy] before_action :logged_in + + ## + # Método que instancia um novo objeto de disciplina + # + # Método sem parametros + # + # Retorna uma nova instancia de disciplina def new @disciplina = Disciplina.new end + + ## + # Método que salva uma nova disciplina no banco de dados + # + # Método sem parametros + # + # Retorna para a view de dashboard, caso consiga salvar a disciplina. Caso contrário, retorna uma mensagem de erro. def create @disciplina = Disciplina.new disciplina_params @@ -18,16 +32,37 @@ def create end end - def edit; end + ## + # Método que edita uma disciplina. + # + def edit + + end + + ## + # Método para atualizar uma disciplina. + # + # Método recebe as informações que devem ser alteradas/mantidas na disciplina. + # + # Retorna para a view de dashboard de disciplinas se a atualização foi bem sucedida (parâmetros válidos). Caso contrário mostra uma mensagem de erro e renderiza a view de edição de disciplinas. def update if @disciplina.update disciplina_params redirect_to dashboard_disciplinas_path, notice: "Disciplina atualizada!" else + flash[:danger] = "Ocorreu um erro ao atualizar a disciplina." render 'edit' end end + ## + # Método que exclui uma disciplina do banco de dados. + # + # O Método procura e apaga a disciplina das turmas e monitorias das quais ela pertence, e depois apaga a disciplina. Funciona como um Cascade. + # + # Parâmetro: Código da disciplina . + # + # Redireciona para a view do dashboard de disciplinas após apagar tudo, caso a remoção foi bem sucedida, com uma mensagem de disciplina removida. def destroy Turma.find_each do |t| if t.fk_cod_disciplina == @disciplina.cod_disciplina @@ -44,24 +79,48 @@ def destroy end private + ## + # Método que especifica e filtra os parâmetros da disciplina. + # + # O método recebe parâmetros arbitrários e filtra todos os não permitidos + # + # Retorna quais são os parâmetros permitidos para uma disciplina. def disciplina_params - params.require(:disciplina).permit(:nome, :fk_tipo_disciplina_id, :c_prat, :c_teor, :c_est, :c_ext) + params.require(:disciplina).permit(:nome, :fk_tipo_disciplina_id, :c_prat, :c_teor, :c_est, :c_ext, :monitoria) end + ## + # Método que localiza uma disciplina. + # + # Método com parâmetros: id. + # + # Retorna a disciplina com o id especificado. def find_disciplina @disciplina = Disciplina.find(params[:id]) end + ## + # Método que verifica se o usuário está logado. + # + # Método sem parâmetro. + # + # Redireciona para a view de login com a mensagem de aviso. def logged_in if !logged_in? - redirect_to new_session_path, notice: "Você precisa estar logado para acessar as Disciplinas" - end + redirect_to new_session_path, notice: "Você precisa estar logado para acessar as Disciplinas" + end end + ## + # Método que localiza uma disciplina. + # + # Parâmetro: id. + # + # Retorna a disciplina com o id especificado. def is_admin if !current_user.kind_of?(Admin) flash[:danger] = "Acesso negado." redirect_to dashboard_disciplinas_path end end -end +end \ No newline at end of file diff --git a/app/models/disciplina.rb b/app/models/disciplina.rb index 627e62b4..2aaa58e4 100644 --- a/app/models/disciplina.rb +++ b/app/models/disciplina.rb @@ -1,12 +1,33 @@ class Disciplina < ApplicationRecord + + ## + # Método estático que retorna os tipos das diciplinas + # + # Retorna o tipo da disciplina + # def self.all_tipos return [['Obrigatória', 1], ['Optativa', 2]] end + ## + # Método estático para achar todas as disciplinas + # + # Retorna uma lista de todas as disciplinas, ordenadas por nome + # def self.all_disciplinas order(:nome).all end + ## + # Método estático para achar todas as disciplinas que permitem monitoria + # + # Retorna uma lista de todas as disciplinas que possuem o campo monitoria como true + # + def self.com_monitoria + return where(monitoria: true) + + end + validates_presence_of :nome validates_presence_of :fk_tipo_disciplina_id validates_presence_of :c_prat diff --git a/app/views/dashboard/disciplinas.html.haml b/app/views/dashboard/disciplinas.html.haml index 0cb05b2b..a01f6f47 100644 --- a/app/views/dashboard/disciplinas.html.haml +++ b/app/views/dashboard/disciplinas.html.haml @@ -121,8 +121,8 @@ - if current_user.kind_of?(Admin) .row .col-6 - %a.btn.btn-outline-warning.btn-block{href: edit_disciplina_path(d.cod_disciplina)} + %a.btn.btn-outline-warning.btn-block{href: edit_disciplina_path(d.id)} Editar Disciplina .col-6 - =link_to "Apagar Disciplina", disciplina_path(d.cod_disciplina), method: :delete, + =link_to "Apagar Disciplina", disciplina_path(d.id), method: :delete, class: 'btn btn-outline-danger btn-block' \ No newline at end of file diff --git a/app/views/dashboard/monitorias.html.haml b/app/views/dashboard/monitorias.html.haml index 60280a3e..3742f3c1 100644 --- a/app/views/dashboard/monitorias.html.haml +++ b/app/views/dashboard/monitorias.html.haml @@ -125,7 +125,7 @@ - @disciplinas = Disciplina.all_disciplinas - @disciplinas.each do |disciplina| - @turmas.each do |turma| - - if disciplina.cod_disciplina == turma.fk_cod_disciplina + - if ((disciplina.cod_disciplina == turma.fk_cod_disciplina) && (disciplina.monitoria == true)) .card .card-body %h5 diff --git a/app/views/disciplinas/edit.html.haml b/app/views/disciplinas/edit.html.haml index c36f64a3..ed0d1eec 100644 --- a/app/views/disciplinas/edit.html.haml +++ b/app/views/disciplinas/edit.html.haml @@ -13,10 +13,7 @@ .col -if flash[:danger] .alert.alert-danger - - flash[:danger].each do |msg| - %ul - %li - =msg + = flash[:danger] -if flash[:notice] .alert.alert-success = flash[:notice] @@ -47,11 +44,17 @@ .col-sm-10 = text_field :disciplina, :c_ext, :class => "form-control", :autocomplete => "off" + .form-group.row = label :disciplina, :fk_tipo_disciplina_id, "Tipo", class: "col-sm-2 col-form-label" .col-sm-10 = select :disciplina, :fk_tipo_disciplina_id, options_for_select(Disciplina.all_tipos) + .form-group.row + = label :disciplina, :monitoria, "Monitoria", class: "col-sm-2 col-form-label" + .col-sm-10 + = check_box :disciplina, :monitoria, {:class => "form-control", :id => "checkbox"} + %br = submit_tag 'Atualizar', class: "btn btn-outline-primary btn-block" .col-3 diff --git a/app/views/disciplinas/new.html.haml b/app/views/disciplinas/new.html.haml index adba25cd..aa2d5764 100644 --- a/app/views/disciplinas/new.html.haml +++ b/app/views/disciplinas/new.html.haml @@ -48,6 +48,11 @@ .col-sm-10 = select :disciplina, :fk_tipo_disciplina_id, options_for_select(Disciplina.all_tipos) + .form-group.row + = label :disciplina, :monitoria, "Monitoria", class: "col-sm-2 col-form-label" + .col-sm-10 + = check_box :disciplina, :monitoria, {:class => "form-control"} + %br = submit_tag 'Cadastrar', class: "btn btn-outline-primary btn-block" .col-3 diff --git a/config/database.yml b/config/database.yml index c26fbd59..deaf3275 100644 --- a/config/database.yml +++ b/config/database.yml @@ -11,22 +11,33 @@ default: &default timeout: 5000 development: - <<: *default - database: monitoriacic_development + adapter: postgresql + encoding: utf8 + database: monitoriacic_development + username: + password: # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: &test - <<: *default - database: monitoriacic_test + adapter: postgresql + encoding: utf8 + database: monitoriacic_development + username: + password: production: - <<: *default - database: monitoriacic_production + adapter: postgresql + encoding: utf8 + database: monitoriacic_development + username: + password: cucumber: - <<: *test + adapter: postgresql + encoding: utf8 + database: monitoriacic_development + username: + password: -cucumber: - <<: *test diff --git a/coverage/.last_run.json b/coverage/.last_run.json index 04ed82cb..dc96f216 100644 --- a/coverage/.last_run.json +++ b/coverage/.last_run.json @@ -1,7 +1,5 @@ { "result": { - - "covered_percent": 12.93 - + "line": 8.24 } } diff --git a/coverage/.resultset.json b/coverage/.resultset.json index e69de29b..d664e35c 100644 --- a/coverage/.resultset.json +++ b/coverage/.resultset.json @@ -0,0 +1,1687 @@ +{ + "RSpec": { + "coverage": { + "/home/italo/unb/monitoriaCIC/app/helpers/application_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/atendimentos_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/atividades_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/disciplinas_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/historico_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/home_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/motivos_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/reset_senhas_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/sessions_helper.rb": { + "lines": [ + 1, + 1, + 3, + null, + null, + 1, + 3, + 0, + null, + null, + null, + 1, + null, + 12, + null, + null, + 1, + 3, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/helpers/tarefas_helper.rb": { + "lines": [ + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/admins_controller.rb": { + "lines": [ + 1, + 1, + null, + null, + 1, + null, + 1, + 3, + 3, + null, + null, + 1, + 2, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/application_controller.rb": { + "lines": [ + 1, + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/atendimentos_controller.rb": { + "lines": [ + 1, + 1, + null, + null, + null, + null, + 1, + 1, + 1, + null, + null, + null, + 1, + 0, + null, + null, + null, + null, + null, + null, + null, + 1, + 4, + 4, + null, + 4, + 0, + null, + 4, + null, + null, + 4, + null, + null, + null, + null, + 1, + 0, + 0, + null, + 0, + 0, + null, + 0, + null, + null, + 0, + null, + null, + null, + null, + 1, + 0, + 0, + null, + 0, + 0, + null, + null, + 1, + null, + 1, + 0, + null, + null, + null, + 1, + 3, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/atividades_controller.rb": { + "lines": [ + 1, + 1, + 1, + null, + null, + null, + 1, + 0, + null, + null, + null, + null, + 1, + null, + null, + null, + null, + 1, + 1, + null, + null, + null, + 1, + null, + null, + null, + null, + null, + null, + null, + 1, + 4, + null, + 4, + 3, + 3, + null, + 1, + 1, + null, + null, + null, + null, + null, + null, + null, + 1, + null, + 3, + 3, + null, + 3, + 2, + null, + 1, + null, + null, + 3, + null, + null, + null, + null, + null, + 1, + 2, + 2, + null, + 2, + 2, + null, + null, + 1, + null, + 1, + 0, + 0, + null, + null, + null, + 1, + null, + 1, + 5, + null, + null, + null, + 1, + 6, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/dados_bancarios_controller.rb": { + "lines": [ + 1, + 1, + null, + 1, + null, + 1, + 5, + null, + 1, + 0, + 0, + null, + null, + null, + null, + 0, + null, + 0, + null, + 1, + null, + null, + 1, + null, + null, + 1, + 3, + 3, + null, + null, + 1, + 0, + 0, + null, + 0, + 0, + null, + 0, + null, + null, + 0, + null, + null, + 1, + 0, + 0, + 0, + 0, + null, + 0, + 0, + null, + null, + 1, + 1, + 1, + 1, + null, + null, + null, + 1, + 4, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/dashboard_controller.rb": { + "lines": [ + 1, + 1, + null, + 1, + null, + 1, + 3, + 1, + 2, + 1, + null, + 1, + 1, + null, + null, + null, + 1, + null, + 1, + null, + null, + null, + 1, + null, + 1, + null, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + null, + null, + null, + null, + null, + null, + 1, + 1, + null, + null, + 1, + 2, + null, + null, + 1, + 0, + 0, + 0, + 0, + 0, + null, + null, + null, + null, + 1, + 0, + 0, + 0, + null, + 0, + null, + 0, + 0, + 0, + 0, + null, + null, + 0, + 0, + 0, + null, + null, + 0, + 0, + null, + 0, + 0, + null, + 0, + null, + null, + null, + 0, + null, + null, + 1, + 1, + null, + null, + null, + null, + null, + null, + 1, + 1, + 1, + null, + 1, + null, + null, + 1, + 1, + null, + null, + 1, + 1, + 1, + null, + null, + 1, + 1, + 2, + 2, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + 1, + 1, + 1, + null, + 1, + 1, + null, + 1, + null, + 1, + null, + 0, + null, + null, + null, + 1, + null, + null, + null, + null, + null, + null, + 1, + null, + 0, + null, + 0, + null, + null, + 0, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + 0, + 0, + 0, + null, + 0, + 0, + null, + 0, + null, + 0, + null, + null, + 0, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + 0, + 0, + 0, + null, + 0, + null, + null, + null, + null, + null, + null, + 1, + null, + 0, + null, + null, + null, + null, + null, + null, + 1, + 1, + null, + 0, + null, + 0, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + 0, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + null, + 1, + 1, + null, + null, + null, + 1, + null, + null, + null, + null, + 1, + 87, + null, + null, + 87, + 48, + null, + null, + null, + null, + null, + 1, + 87, + null, + null, + null, + 1, + 48, + 48, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + 48, + 48, + null, + null, + null, + 1, + 48, + null, + 0, + null, + 2, + null, + 32, + null, + 9, + null, + 4, + null, + null, + 0, + null, + null, + 1, + null, + null, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/disciplinas_controller.rb": { + "lines": [ + 1, + 1, + 1, + 1, + null, + 1, + 1, + null, + null, + 1, + 4, + null, + 4, + 3, + null, + 1, + 1, + null, + null, + null, + 1, + null, + 1, + 4, + 3, + null, + 1, + 1, + null, + null, + null, + 1, + 1, + 1, + 1, + null, + null, + 1, + 1, + 0, + null, + null, + 1, + 1, + null, + null, + 1, + 1, + 5, + null, + null, + 1, + 6, + null, + null, + 1, + 0, + 0, + null, + null, + null, + 1, + 0, + 0, + 0, + null, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/faq_controller.rb": { + "lines": [ + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/home_controller.rb": { + "lines": [ + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/monitorias_controller.rb": { + "lines": [ + 1, + 1, + 1, + 1, + null, + 1, + 1, + 1, + null, + null, + 1, + 4, + 4, + 4, + 8, + 8, + null, + null, + null, + 4, + 0, + null, + 4, + 4, + null, + null, + null, + 1, + 1, + null, + null, + 1, + null, + null, + 1, + 3, + 3, + null, + 0, + null, + null, + null, + 1, + 1, + 1, + null, + null, + 1, + 1, + 4, + null, + null, + 1, + 1, + null, + null, + 1, + 5, + null, + null, + 1, + 0, + 0, + null, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/professors_controller.rb": { + "lines": [ + 1, + null, + null, + 1, + null, + 1, + null, + null, + 1, + null, + 1, + 6, + null, + 6, + 2, + 2, + 2, + null, + 4, + 4, + null, + null, + null, + 1, + null, + 2, + null, + 2, + null, + null, + 1, + 6, + 6, + null, + 6, + 4, + null, + 2, + null, + null, + 6, + null, + null, + 1, + null, + 1, + 9, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/reset_senhas_controller.rb": { + "lines": [ + 1, + 1, + 1, + 1, + null, + 1, + null, + null, + 1, + 3, + 3, + 1, + 1, + 1, + 1, + null, + 2, + 2, + null, + null, + null, + 1, + null, + null, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + null, + 0, + null, + null, + null, + 1, + null, + null, + 1, + 5, + null, + null, + null, + 1, + 4, + 4, + null, + null, + null, + null, + 1, + 0, + 0, + 0, + null, + null, + null, + null, + 1, + 0, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/sessions_controller.rb": { + "lines": [ + 1, + 1, + null, + 1, + null, + 3, + null, + null, + null, + 3, + 3, + 3, + null, + 0, + 0, + null, + null, + null, + 1, + 0, + 0, + null, + null, + null, + 1, + 6, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/sobre_controller.rb": { + "lines": [ + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/tarefas_controller.rb": { + "lines": [ + 1, + 1, + null, + null, + null, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + null, + null, + null, + null, + null, + null, + 1, + null, + null, + null, + null, + 1, + 0, + 0, + null, + null, + null, + 1, + null, + null, + null, + null, + 1, + 0, + 0, + 0, + null, + 0, + 0, + null, + null, + null, + null, + null, + null, + null, + 1, + 0, + 0, + null, + 0, + 0, + null, + null, + null, + null, + null, + 1, + 0, + 0, + null, + null, + 1, + null, + 1, + 0, + null, + null, + null, + 1, + 0, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/turmas_controller.rb": { + "lines": [ + 1, + null, + 1, + 1, + null, + null, + 1, + 1, + null, + null, + 1, + 4, + null, + 4, + 3, + null, + 1, + null, + null, + 4, + null, + null, + 1, + 5, + 5, + null, + 5, + 4, + null, + 1, + null, + null, + 5, + null, + null, + 1, + 1, + 1, + 0, + 0, + null, + null, + 1, + 1, + 1, + null, + null, + 1, + 1, + 6, + null, + null, + 1, + 0, + null, + null, + 1, + 0, + 0, + 0, + 0, + null, + null, + 0, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/controllers/users_controller.rb": { + "lines": [ + 1, + null, + 1, + null, + null, + 1, + 6, + null, + 6, + 0, + 0, + 0, + null, + 6, + 6, + null, + null, + null, + 1, + 6, + 6, + null, + 6, + 4, + null, + 2, + null, + null, + 6, + null, + null, + 1, + 1, + 12, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/atendimento.rb": { + "lines": [ + 1, + null, + null, + 1, + null, + null, + null, + 1, + 1, + 1, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/application_record.rb": { + "lines": [ + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/atividade.rb": { + "lines": [ + 1, + null, + null, + 1, + 1, + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/dados_bancarios.rb": { + "lines": [ + 1, + 1, + null, + 1, + 1, + 1, + null, + 1, + null, + null, + null, + null, + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/disciplina.rb": { + "lines": [ + 1, + 1, + 1, + null, + null, + 1, + 0, + null, + null, + 1, + 0, + null, + null, + 1, + 1, + 1, + 1, + 1, + 1, + null, + null, + 1, + 1, + 1, + 1, + 1, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/monitoria.rb": { + "lines": [ + 1, + null, + 1, + 0, + 0, + 0, + null, + 0, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + 1, + null, + 1, + 1, + 1, + 1, + 1, + null, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/professor.rb": { + "lines": [ + 1, + 1, + null, + 1, + null, + 1, + 1, + null, + null, + null, + 1, + 1, + 1, + null, + 1, + 1, + null, + null, + 1, + null, + null, + 1, + null, + null, + null, + 1, + 1, + null, + null, + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/tarefa.rb": { + "lines": [ + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/turma.rb": { + "lines": [ + 1, + 1, + 1, + null, + 1, + 10, + 10, + 10, + null, + null, + 1, + null, + null, + 1, + 0, + null, + 0, + 0, + 0, + 0, + 0, + null, + null, + 0, + null, + null, + 1, + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + null, + 0, + null, + null, + 1, + null, + 1, + null, + null, + null, + null, + 1, + 1, + null, + null, + 1, + 1, + 1, + 1, + 1, + null, + 1, + 33, + null, + 33, + 7, + 3, + null, + null, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/user.rb": { + "lines": [ + 1, + 1, + 1, + null, + 1, + null, + null, + 1, + 1, + 1, + 1, + 1, + null, + null, + 1, + 1, + 1, + 1, + null, + null, + null, + 1, + null, + null, + null, + null, + 1, + null, + 1, + 1, + null, + 1, + 1, + null, + 1, + null, + 1, + 1, + null, + null, + 1, + 230, + 230, + 230, + null, + 230, + 2106, + null, + 2106, + 2106, + null, + 230, + 230, + 103, + null, + null, + 230, + null, + null, + 1, + 115, + 115, + 1228, + null, + null, + 115, + 115, + null, + 115, + 12, + null, + null, + null, + null, + 1, + 1, + null, + 1, + null, + null, + null, + 1, + 13, + null, + null, + null, + 1, + 1, + 1, + 1, + null, + null, + null, + 1, + 1, + null, + null, + null, + 1, + 0, + null, + null, + null, + 1, + 2, + 2, + 0, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/admin.rb": { + "lines": [ + 1, + 1, + null, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/models/motivo.rb": { + "lines": [ + 1, + null, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/mailers/professor_mailer.rb": { + "lines": [ + 1, + 1, + null, + null, + 1, + 2, + 2, + 2, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/mailers/application_mailer.rb": { + "lines": [ + 1, + 1, + 1, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/mailers/user_mailer.rb": { + "lines": [ + 1, + null, + null, + null, + null, + null, + null, + 1, + 2, + 2, + null, + null + ] + }, + "/home/italo/unb/monitoriaCIC/app/channels/application_cable/channel.rb": { + "lines": [ + 0, + 0, + 0, + 0 + ], + "branches": { + } + }, + "/home/italo/unb/monitoriaCIC/app/channels/application_cable/connection.rb": { + "lines": [ + 0, + 0, + 0, + 0 + ], + "branches": { + } + }, + "/home/italo/unb/monitoriaCIC/app/jobs/application_job.rb": { + "lines": [ + 0, + 0 + ], + "branches": { + } + }, + "/home/italo/unb/monitoriaCIC/app/controllers/motivos_controller.rb": { + "lines": [ + 0, + 0, + null, + null, + null, + 0, + 0, + 0, + null, + null, + null, + 0, + 0, + null, + null, + 0, + 0, + 0, + null, + null, + 0, + 0, + null, + null, + null, + 0, + 0, + null, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + null, + null, + null, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + null, + null, + null, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + null, + 0, + null, + 0, + 0, + 0, + null, + null, + 0, + 0, + 0, + 0 + ], + "branches": { + } + }, + "/home/italo/unb/monitoriaCIC/app/controllers/historico_controller.rb": { + "lines": [ + 0, + null, + 0 + ], + "branches": { + } + } + }, + "timestamp": 1620430844 + } +} diff --git a/coverage/index.html b/coverage/index.html index e69de29b..a04ec441 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -0,0 +1,19292 @@ + + + + Code coverage for Monitoriacic + + + + + + + + +
+ loading +
+
+
Generated 2021-05-07T20:40:44-03:00
+ + +
+
+

+ All Files + ( + + 69.95% + + + + covered at + + + 15.13 + + hits/line + ) +

+ + + +
+ 47 files in total. +
+ +
+ 752 relevant lines, + 526 lines covered and + 226 lines missed. + ( + 69.95% + +) +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
app/channels/application_cable/channel.rb0.00 %44040.00
app/channels/application_cable/connection.rb0.00 %44040.00
app/controllers/admins_controller.rb100.00 %158801.63
app/controllers/application_controller.rb100.00 %43301.00
app/controllers/atendimentos_controller.rb58.06 %703118131.13
app/controllers/atividades_controller.rb91.89 %90373431.78
app/controllers/dados_bancarios_controller.rb54.29 %643519160.86
app/controllers/dashboard_controller.rb59.52 %31312675515.27
app/controllers/disciplinas_controller.rb84.62 %68393361.41
app/controllers/faq_controller.rb100.00 %32201.00
app/controllers/historico_controller.rb0.00 %32020.00
app/controllers/home_controller.rb100.00 %32201.00
app/controllers/monitorias_controller.rb89.19 %66373342.05
app/controllers/motivos_controller.rb0.00 %74500500.00
app/controllers/professors_controller.rb100.00 %49252503.12
app/controllers/reset_senhas_controller.rb66.67 %643624121.11
app/controllers/sessions_controller.rb71.43 %28141041.64
app/controllers/sobre_controller.rb100.00 %32201.00
app/controllers/tarefas_controller.rb36.36 %753312210.36
app/controllers/turmas_controller.rb78.38 %66372981.73
app/controllers/users_controller.rb85.00 %36201733.60
app/helpers/application_helper.rb100.00 %21101.00
app/helpers/atendimentos_helper.rb100.00 %21101.00
app/helpers/atividades_helper.rb100.00 %21101.00
app/helpers/disciplinas_helper.rb100.00 %21101.00
app/helpers/historico_helper.rb100.00 %21101.00
app/helpers/home_helper.rb100.00 %21101.00
app/helpers/motivos_helper.rb100.00 %21101.00
app/helpers/reset_senhas_helper.rb100.00 %21101.00
app/helpers/sessions_helper.rb90.00 %2010912.60
app/helpers/tarefas_helper.rb100.00 %21101.00
app/jobs/application_job.rb0.00 %22020.00
app/mailers/application_mailer.rb100.00 %43301.00
app/mailers/professor_mailer.rb100.00 %106601.50
app/mailers/user_mailer.rb100.00 %124401.50
app/models/admin.rb100.00 %53301.00
app/models/application_record.rb100.00 %32201.00
app/models/atendimento.rb100.00 %125501.00
app/models/atividade.rb100.00 %85501.00
app/models/dados_bancarios.rb100.00 %158801.00
app/models/disciplina.rb88.89 %28181620.89
app/models/monitoria.rb69.23 %2913940.69
app/models/motivo.rb100.00 %42201.00
app/models/professor.rb100.00 %32161601.00
app/models/tarefa.rb100.00 %32201.00
app/models/turma.rb63.16 %663824143.24
app/models/user.rb96.61 %10959572167.78
+
+
+ + + +
+

+ Controllers + ( + + 64.19% + + + + covered at + + + 2.29 + + hits/line + ) +

+ + + +
+ 19 files in total. +
+ +
+ 539 relevant lines, + 346 lines covered and + 193 lines missed. + ( + 64.19% + +) +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
app/controllers/admins_controller.rb100.00 %158801.63
app/controllers/application_controller.rb100.00 %43301.00
app/controllers/atendimentos_controller.rb58.06 %703118131.13
app/controllers/atividades_controller.rb91.89 %90373431.78
app/controllers/dados_bancarios_controller.rb54.29 %643519160.86
app/controllers/dashboard_controller.rb59.52 %31312675515.27
app/controllers/disciplinas_controller.rb84.62 %68393361.41
app/controllers/faq_controller.rb100.00 %32201.00
app/controllers/historico_controller.rb0.00 %32020.00
app/controllers/home_controller.rb100.00 %32201.00
app/controllers/monitorias_controller.rb89.19 %66373342.05
app/controllers/motivos_controller.rb0.00 %74500500.00
app/controllers/professors_controller.rb100.00 %49252503.12
app/controllers/reset_senhas_controller.rb66.67 %643624121.11
app/controllers/sessions_controller.rb71.43 %28141041.64
app/controllers/sobre_controller.rb100.00 %32201.00
app/controllers/tarefas_controller.rb36.36 %753312210.36
app/controllers/turmas_controller.rb78.38 %66372981.73
app/controllers/users_controller.rb85.00 %36201733.60
+
+
+ + +
+

+ Channels + ( + + 0.0% + + + + covered at + + + 0.0 + + hits/line + ) +

+ + + +
+ 2 files in total. +
+ +
+ 8 relevant lines, + 0 lines covered and + 8 lines missed. + ( + 0.0% + +) +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
app/channels/application_cable/channel.rb0.00 %44040.00
app/channels/application_cable/connection.rb0.00 %44040.00
+
+
+ + +
+

+ Models + ( + + 87.13% + + + + covered at + + + 59.01 + + hits/line + ) +

+ + + +
+ 12 files in total. +
+ +
+ 171 relevant lines, + 149 lines covered and + 22 lines missed. + ( + 87.13% + +) +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
app/models/admin.rb100.00 %53301.00
app/models/application_record.rb100.00 %32201.00
app/models/atendimento.rb100.00 %125501.00
app/models/atividade.rb100.00 %85501.00
app/models/dados_bancarios.rb100.00 %158801.00
app/models/disciplina.rb88.89 %28181620.89
app/models/monitoria.rb69.23 %2913940.69
app/models/motivo.rb100.00 %42201.00
app/models/professor.rb100.00 %32161601.00
app/models/tarefa.rb100.00 %32201.00
app/models/turma.rb63.16 %663824143.24
app/models/user.rb96.61 %10959572167.78
+
+
+ + +
+

+ Mailers + ( + + 100.0% + + + + covered at + + + 1.38 + + hits/line + ) +

+ + + +
+ 3 files in total. +
+ +
+ 13 relevant lines, + 13 lines covered and + 0 lines missed. + ( + 100.0% + +) +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
app/mailers/application_mailer.rb100.00 %43301.00
app/mailers/professor_mailer.rb100.00 %106601.50
app/mailers/user_mailer.rb100.00 %124401.50
+
+
+ + +
+

+ Helpers + ( + + 94.74% + + + + covered at + + + 1.84 + + hits/line + ) +

+ + + +
+ 10 files in total. +
+ +
+ 19 relevant lines, + 18 lines covered and + 1 lines missed. + ( + 94.74% + +) +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
app/helpers/application_helper.rb100.00 %21101.00
app/helpers/atendimentos_helper.rb100.00 %21101.00
app/helpers/atividades_helper.rb100.00 %21101.00
app/helpers/disciplinas_helper.rb100.00 %21101.00
app/helpers/historico_helper.rb100.00 %21101.00
app/helpers/home_helper.rb100.00 %21101.00
app/helpers/motivos_helper.rb100.00 %21101.00
app/helpers/reset_senhas_helper.rb100.00 %21101.00
app/helpers/sessions_helper.rb90.00 %2010912.60
app/helpers/tarefas_helper.rb100.00 %21101.00
+
+
+ + +
+

+ Jobs + ( + + 0.0% + + + + covered at + + + 0.0 + + hits/line + ) +

+ + + +
+ 1 files in total. +
+ +
+ 2 relevant lines, + 0 lines covered and + 2 lines missed. + ( + 0.0% + +) +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
app/jobs/application_job.rb0.00 %22020.00
+
+
+ + +
+

+ Libraries + ( + + 100.0% + + + + covered at + + + 0.0 + + hits/line + ) +

+ + + +
+ 0 files in total. +
+ +
+ 0 relevant lines, + 0 lines covered and + 0 lines missed. + ( + 100.0% + +) +
+ + + +
+ + + + + + + + + + + + + + + + +
File% coveredLinesRelevant LinesLines coveredLines missedAvg. Hits / Line
+
+
+ + +
+ + + +
+ +
+
+

app/channels/application_cable/channel.rb

+

+ + 0.0% + + + lines covered +

+ + + +
+ 4 relevant lines. + 0 lines covered and + 4 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + + + + + + module ApplicationCable +
  2. +
    + +
    +
  3. + + + + + + class Channel < ActionCable::Channel::Base +
  4. +
    + +
    +
  5. + + + + + + end +
  6. +
    + +
    +
  7. + + + + + + end +
  8. +
    + +
+
+
+ + +
+
+

app/channels/application_cable/connection.rb

+

+ + 0.0% + + + lines covered +

+ + + +
+ 4 relevant lines. + 0 lines covered and + 4 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + + + + + + module ApplicationCable +
  2. +
    + +
    +
  3. + + + + + + class Connection < ActionCable::Connection::Base +
  4. +
    + +
    +
  5. + + + + + + end +
  6. +
    + +
    +
  7. + + + + + + end +
  8. +
    + +
+
+
+ + +
+
+

app/controllers/admins_controller.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 8 relevant lines. + 8 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class AdminsController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + def index ; end +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + + + + + + +
  8. +
    + +
    +
  9. + 1 + + + + + def new ; end +
  10. +
    + +
    +
  11. + + + + + + +
  12. +
    + +
    +
  13. + 1 + + + + + def create +
  14. +
    + +
    +
  15. + 3 + + + + + @admin = Admin.create(admin_params) +
  16. +
    + +
    +
  17. + 3 + + + + + redirect_to root_path +
  18. +
    + +
    +
  19. + + + + + + end +
  20. +
    + +
    +
  21. + + + + + + +
  22. +
    + +
    +
  23. + 1 + + + + + def admin_params +
  24. +
    + +
    +
  25. + 2 + + + + + params.require(:admin).permit(:id, :name, :email, :password, :password_confirmation) +
  26. +
    + +
    +
  27. + + + + + + end +
  28. +
    + +
    +
  29. + + + + + + end +
  30. +
    + +
+
+
+ + +
+
+

app/controllers/application_controller.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 3 relevant lines. + 3 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class ApplicationController < ActionController::Base +
  2. +
    + +
    +
  3. + 1 + + + + + protect_from_forgery +
  4. +
    + +
    +
  5. + 1 + + + + + include SessionsHelper +
  6. +
    + +
    +
  7. + + + + + + end +
  8. +
    + +
+
+
+ + +
+
+

app/controllers/atendimentos_controller.rb

+

+ + 58.06% + + + lines covered +

+ + + +
+ 31 relevant lines. + 18 lines covered and + 13 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class AtendimentosController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + before_action :set_atendimento, only: [:edit, :update, :destroy] +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + + + + + + # GET /atendimentos/new +
  8. +
    + +
    +
  9. + + + + + + ## +
  10. +
    + +
    +
  11. + + + + + + # busca o usuário logado para associá-lo ao novo atendimento. +
  12. +
    + +
    +
  13. + 1 + + + + + def new +
  14. +
    + +
    +
  15. + 1 + + + + + @atendimento = Atendimento.new +
  16. +
    + +
    +
  17. + 1 + + + + + @user = current_user +
  18. +
    + +
    +
  19. + + + + + + end +
  20. +
    + +
    +
  21. + + + + + + +
  22. +
    + +
    +
  23. + + + + + + # GET /atendimentos/1/edit +
  24. +
    + +
    +
  25. + 1 + + + + + def edit +
  26. +
    + +
    +
  27. + + + + + + @user = current_user +
  28. +
    + +
    +
  29. + + + + + + end +
  30. +
    + +
    +
  31. + + + + + + +
  32. +
    + +
    +
  33. + + + + + + # POST /atendimentos +
  34. +
    + +
    +
  35. + + + + + + # POST /atendimentos.json +
  36. +
    + +
    +
  37. + + + + + + # Método para criar um atendimento, associando o atendimento ao usuário logado, +
  38. +
    + +
    +
  39. + + + + + + # que será passado pelo atendimento_params +
  40. +
    + +
    +
  41. + + + + + + # Retorna para a pagina dashboard/atendimentos +
  42. +
    + +
    +
  43. + 1 + + + + + def create +
  44. +
    + +
    +
  45. + 4 + + + + + @user = current_user +
  46. +
    + +
    +
  47. + 4 + + + + + @atendimento = Atendimento.create(atendimento_params) +
  48. +
    + +
    +
  49. + + + + + + +
  50. +
    + +
    +
  51. + 4 + + + + + if !@atendimento.errors.any? +
  52. +
    + +
    +
  53. + + + + + + flash[:notice] = "Registro de atendimento realizado com sucesso!" +
  54. +
    + +
    +
  55. + + + + + + else +
  56. +
    + +
    +
  57. + 4 + + + + + flash[:danger] = @atendimento.errors.full_messages +
  58. +
    + +
    +
  59. + + + + + + end +
  60. +
    + +
    +
  61. + + + + + + +
  62. +
    + +
    +
  63. + 4 + + + + + redirect_to dashboard_atendimentos_path +
  64. +
    + +
    +
  65. + + + + + + end +
  66. +
    + +
    +
  67. + + + + + + +
  68. +
    + +
    +
  69. + + + + + + # PATCH/PUT /atendimentos/1 +
  70. +
    + +
    +
  71. + + + + + + # PATCH/PUT /atendimentos/1.json +
  72. +
    + +
    +
  73. + 1 + + + + + def update +
  74. +
    + +
    +
  75. + + + + + + @atendimento = Atendimento.find(params[:id]) +
  76. +
    + +
    +
  77. + + + + + + @atendimento.update_attributes(atendimento_params) +
  78. +
    + +
    +
  79. + + + + + + +
  80. +
    + +
    +
  81. + + + + + + if !@atendimento.errors.any? +
  82. +
    + +
    +
  83. + + + + + + flash[:notice] = 'Atendimento atualizado com sucesso!' +
  84. +
    + +
    +
  85. + + + + + + elsif +
  86. +
    + +
    +
  87. + + + + + + flash[:danger] = @atendimento.errors.first[1] +
  88. +
    + +
    +
  89. + + + + + + end +
  90. +
    + +
    +
  91. + + + + + + +
  92. +
    + +
    +
  93. + + + + + + redirect_to dashboard_atendimentos_path +
  94. +
    + +
    +
  95. + + + + + + end +
  96. +
    + +
    +
  97. + + + + + + +
  98. +
    + +
    +
  99. + + + + + + # DELETE /atendimentos/1 +
  100. +
    + +
    +
  101. + + + + + + # DELETE /atendimentos/1.json +
  102. +
    + +
    +
  103. + 1 + + + + + def destroy +
  104. +
    + +
    +
  105. + + + + + + @atendimento = Atendimento.find(params[:id]) +
  106. +
    + +
    +
  107. + + + + + + @atendimento.delete +
  108. +
    + +
    +
  109. + + + + + + +
  110. +
    + +
    +
  111. + + + + + + flash[:notice] = 'Atendimento apagado com sucesso!' +
  112. +
    + +
    +
  113. + + + + + + redirect_to dashboard_atendimentos_path +
  114. +
    + +
    +
  115. + + + + + + end +
  116. +
    + +
    +
  117. + + + + + + +
  118. +
    + +
    +
  119. + 1 + + + + + private +
  120. +
    + +
    +
  121. + + + + + + # Use callbacks to share common setup or constraints between actions. +
  122. +
    + +
    +
  123. + 1 + + + + + def set_atendimento +
  124. +
    + +
    +
  125. + + + + + + @atendimento = Atendimento.find(params[:id]) +
  126. +
    + +
    +
  127. + + + + + + end +
  128. +
    + +
    +
  129. + + + + + + +
  130. +
    + +
    +
  131. + + + + + + # Never trust parameters from the scary internet, only allow the white list through. +
  132. +
    + +
    +
  133. + 1 + + + + + def atendimento_params +
  134. +
    + +
    +
  135. + 3 + + + + + params.require(:atendimento).permit(:motivo_id, :dia, :descricao, :aluno_atendido, :monitor_id) +
  136. +
    + +
    +
  137. + + + + + + end +
  138. +
    + +
    +
  139. + + + + + + end +
  140. +
    + +
+
+
+ + +
+
+

app/controllers/atividades_controller.rb

+

+ + 91.89% + + + lines covered +

+ + + +
+ 37 relevant lines. + 34 lines covered and + 3 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class AtividadesController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + before_action :user_logged +
  4. +
    + +
    +
  5. + 1 + + + + + before_action :set_atividade, only: [:show, :edit, :update, :destroy] +
  6. +
    + +
    +
  7. + + + + + + +
  8. +
    + +
    +
  9. + + + + + + # GET /atividades +
  10. +
    + +
    +
  11. + + + + + + # GET /atividades.json +
  12. +
    + +
    +
  13. + 1 + + + + + def index +
  14. +
    + +
    +
  15. + + + + + + @atividades = Atividade.all +
  16. +
    + +
    +
  17. + + + + + + end +
  18. +
    + +
    +
  19. + + + + + + +
  20. +
    + +
    +
  21. + + + + + + # GET /atividades/1 +
  22. +
    + +
    +
  23. + + + + + + # GET /atividades/1.json +
  24. +
    + +
    +
  25. + 1 + + + + + def show +
  26. +
    + +
    +
  27. + + + + + + end +
  28. +
    + +
    +
  29. + + + + + + +
  30. +
    + +
    +
  31. + + + + + + # GET /atividades/new +
  32. +
    + +
    +
  33. + + + + + + #Associa o registro de atividade ao usuario logado +
  34. +
    + +
    +
  35. + 1 + + + + + def new +
  36. +
    + +
    +
  37. + 1 + + + + + @atividade = Atividade.new +
  38. +
    + +
    +
  39. + + + + + + end +
  40. +
    + +
    +
  41. + + + + + + +
  42. +
    + +
    +
  43. + + + + + + # GET /atividades/1/edit +
  44. +
    + +
    +
  45. + 1 + + + + + def edit +
  46. +
    + +
    +
  47. + + + + + + end +
  48. +
    + +
    +
  49. + + + + + + +
  50. +
    + +
    +
  51. + + + + + + # POST /atividades +
  52. +
    + +
    +
  53. + + + + + + # POST /atividades.json +
  54. +
    + +
    +
  55. + + + + + + # Método para criar o registro de uma atividade, associando a atividade ao usuário logado, +
  56. +
    + +
    +
  57. + + + + + + # que será passado pelo atividade_params +
  58. +
    + +
    +
  59. + + + + + + # Criando ou não, retorna para o dashboard +
  60. +
    + +
    +
  61. + 1 + + + + + def create +
  62. +
    + +
    +
  63. + 4 + + + + + @atividade = Atividade.create(atividade_params) +
  64. +
    + +
    +
  65. + + + + + + +
  66. +
    + +
    +
  67. + 4 + + + + + if !@atividade.errors.any? +
  68. +
    + +
    +
  69. + 3 + + + + + flash[:notice] = "Registro de atividade realizado com sucesso!" +
  70. +
    + +
    +
  71. + 3 + + + + + redirect_to dashboard_atividades_path +
  72. +
    + +
    +
  73. + + + + + + else +
  74. +
    + +
    +
  75. + 1 + + + + + flash[:danger] = @atividade.errors.first[1] +
  76. +
    + +
    +
  77. + 1 + + + + + redirect_to dashboard_atividades_path +
  78. +
    + +
    +
  79. + + + + + + end +
  80. +
    + +
    +
  81. + + + + + + end +
  82. +
    + +
    +
  83. + + + + + + +
  84. +
    + +
    +
  85. + + + + + + # PATCH/PUT /atividades/1 +
  86. +
    + +
    +
  87. + + + + + + # PATCH/PUT /atividades/1.json +
  88. +
    + +
    +
  89. + + + + + + # Método para editar o registro de uma atividade, passando pelo atividade_params a atividade atualizada associada +
  90. +
    + +
    +
  91. + + + + + + # ao usuario que foi capturada por params[:id] +
  92. +
    + +
    +
  93. + 1 + + + + + def update +
  94. +
    + +
    +
  95. + + + + + + +
  96. +
    + +
    +
  97. + 3 + + + + + @atividade = Atividade.find(params[:id]) +
  98. +
    + +
    +
  99. + 3 + + + + + @atividade.update_attributes(atividade_params) +
  100. +
    + +
    +
  101. + + + + + + +
  102. +
    + +
    +
  103. + 3 + + + + + if !@atividade.errors.any? +
  104. +
    + +
    +
  105. + 2 + + + + + flash[:notice] = 'Atividade atualizada com sucesso!' +
  106. +
    + +
    +
  107. + + + + + + elsif +
  108. +
    + +
    +
  109. + 1 + + + + + flash[:danger] = @atividade.errors.first[1] +
  110. +
    + +
    +
  111. + + + + + + end +
  112. +
    + +
    +
  113. + + + + + + +
  114. +
    + +
    +
  115. + 3 + + + + + redirect_to dashboard_atividades_path +
  116. +
    + +
    +
  117. + + + + + + end +
  118. +
    + +
    +
  119. + + + + + + +
  120. +
    + +
    +
  121. + + + + + + # DELETE /atividades/1 +
  122. +
    + +
    +
  123. + + + + + + # DELETE /atividades/1.json +
  124. +
    + +
    +
  125. + + + + + + # Metodo utilizado para apagar uma atividade, utilizando seu id como paramentro +
  126. +
    + +
    +
  127. + 1 + + + + + def destroy +
  128. +
    + +
    +
  129. + 2 + + + + + @atividade = Atividade.find(params[:id]) +
  130. +
    + +
    +
  131. + 2 + + + + + @atividade.delete +
  132. +
    + +
    +
  133. + + + + + + +
  134. +
    + +
    +
  135. + 2 + + + + + flash[:notice] = 'Atividade apagada com sucesso!' +
  136. +
    + +
    +
  137. + 2 + + + + + redirect_to dashboard_atividades_path +
  138. +
    + +
    +
  139. + + + + + + end +
  140. +
    + +
    +
  141. + + + + + + +
  142. +
    + +
    +
  143. + 1 + + + + + private +
  144. +
    + +
    +
  145. + + + + + + # verifica se o usuario está logado para poder acessar a pagina de registro +
  146. +
    + +
    +
  147. + 1 + + + + + def user_logged +
  148. +
    + +
    +
  149. + + + + + + if !logged_in? +
  150. +
    + +
    +
  151. + + + + + + redirect_to new_session_path, notice: "Você precisa estar logado para acessar essa página" +
  152. +
    + +
    +
  153. + + + + + + end +
  154. +
    + +
    +
  155. + + + + + + end +
  156. +
    + +
    +
  157. + + + + + + +
  158. +
    + +
    +
  159. + 1 + + + + + private +
  160. +
    + +
    +
  161. + + + + + + # Use callbacks to share common setup or constraints between actions. +
  162. +
    + +
    +
  163. + 1 + + + + + def set_atividade +
  164. +
    + +
    +
  165. + 5 + + + + + @atividade = Atividade.find(params[:id]) +
  166. +
    + +
    +
  167. + + + + + + end +
  168. +
    + +
    +
  169. + + + + + + +
  170. +
    + +
    +
  171. + + + + + + # Never trust parameters from the scary internet, only allow the white list through. +
  172. +
    + +
    +
  173. + 1 + + + + + def atividade_params +
  174. +
    + +
    +
  175. + 6 + + + + + params.require(:atividade).permit(:titulo, :mensagem, :matricula_monitor, :data) +
  176. +
    + +
    +
  177. + + + + + + end +
  178. +
    + +
    +
  179. + + + + + + end +
  180. +
    + +
+
+
+ + +
+
+

app/controllers/dados_bancarios_controller.rb

+

+ + 54.29% + + + lines covered +

+ + + +
+ 35 relevant lines. + 19 lines covered and + 16 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class DadosBancariosController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + before_action :user_logged +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + 1 + + + + + def new; end +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + 1 + + + + + def create +
  12. +
    + +
    +
  13. + 5 + + + + + @dados_bancarios = DadosBancarios.create(dados_bancarios_params) +
  14. +
    + +
    +
  15. + + + + + + +
  16. +
    + +
    +
  17. + 1 + + + + + if !@dados_bancarios.errors.any? +
  18. +
    + +
    +
  19. + + + + + + @user = current_user +
  20. +
    + +
    +
  21. + + + + + + @fk_banco = DadosBancarios.find_by( +
  22. +
    + +
    +
  23. + + + + + + codigo: @dados_bancarios.codigo, +
  24. +
    + +
    +
  25. + + + + + + agencia: @dados_bancarios.agencia, +
  26. +
    + +
    +
  27. + + + + + + conta_corrente: @dados_bancarios.conta_corrente +
  28. +
    + +
    +
  29. + + + + + + ) +
  30. +
    + +
    +
  31. + + + + + + @user.update(fk_banco: @fk_banco.id) +
  32. +
    + +
    +
  33. + + + + + + +
  34. +
    + +
    +
  35. + + + + + + flash[:notice] = 'Dados bancários cadastrados com sucesso!' +
  36. +
    + +
    +
  37. + + + + + + else +
  38. +
    + +
    +
  39. + 1 + + + + + flash[:danger] = @dados_bancarios.errors.full_messages +
  40. +
    + +
    +
  41. + + + + + + end +
  42. +
    + +
    +
  43. + + + + + + +
  44. +
    + +
    +
  45. + 1 + + + + + redirect_to dashboard_dados_bancarios_path +
  46. +
    + +
    +
  47. + + + + + + end +
  48. +
    + +
    +
  49. + + + + + + +
  50. +
    + +
    +
  51. + 1 + + + + + def edit +
  52. +
    + +
    +
  53. + 3 + + + + + @user = current_user +
  54. +
    + +
    +
  55. + 3 + + + + + @dados_bancarios = DadosBancarios.find(@user.fk_banco) +
  56. +
    + +
    +
  57. + + + + + + end +
  58. +
    + +
    +
  59. + + + + + + +
  60. +
    + +
    +
  61. + 1 + + + + + def update +
  62. +
    + +
    +
  63. + + + + + + @dados_bancarios = DadosBancarios.find(params[:id]) +
  64. +
    + +
    +
  65. + + + + + + @dados_bancarios.update_attributes(dados_bancarios_params) +
  66. +
    + +
    +
  67. + + + + + + +
  68. +
    + +
    +
  69. + + + + + + if !@dados_bancarios.errors.any? +
  70. +
    + +
    +
  71. + + + + + + flash[:notice] = 'Dados atualizados com sucesso!' +
  72. +
    + +
    +
  73. + + + + + + elsif +
  74. +
    + +
    +
  75. + + + + + + flash[:danger] = @dados_bancarios.errors.full_messages +
  76. +
    + +
    +
  77. + + + + + + end +
  78. +
    + +
    +
  79. + + + + + + +
  80. +
    + +
    +
  81. + + + + + + redirect_to dashboard_dados_bancarios_path +
  82. +
    + +
    +
  83. + + + + + + end +
  84. +
    + +
    +
  85. + + + + + + +
  86. +
    + +
    +
  87. + 1 + + + + + def destroy +
  88. +
    + +
    +
  89. + + + + + + @user = current_user +
  90. +
    + +
    +
  91. + + + + + + @dados_bancarios = DadosBancarios.find(params[:id]) +
  92. +
    + +
    +
  93. + + + + + + @dados_bancarios.delete +
  94. +
    + +
    +
  95. + + + + + + @user.update(fk_banco: nil) +
  96. +
    + +
    +
  97. + + + + + + +
  98. +
    + +
    +
  99. + + + + + + flash[:notice] = 'Dados bancários apagados com sucesso!' +
  100. +
    + +
    +
  101. + + + + + + redirect_to dashboard_dados_bancarios_path +
  102. +
    + +
    +
  103. + + + + + + end +
  104. +
    + +
    +
  105. + + + + + + +
  106. +
    + +
    +
  107. + 1 + + + + + private +
  108. +
    + +
    +
  109. + 1 + + + + + def user_logged +
  110. +
    + +
    +
  111. + 1 + + + + + if !logged_in? +
  112. +
    + +
    +
  113. + 1 + + + + + redirect_to new_session_path, notice: "Você precisa estar logado para acessar essa página" +
  114. +
    + +
    +
  115. + + + + + + end +
  116. +
    + +
    +
  117. + + + + + + end +
  118. +
    + +
    +
  119. + + + + + + +
  120. +
    + +
    +
  121. + 1 + + + + + def dados_bancarios_params +
  122. +
    + +
    +
  123. + 4 + + + + + params.require(:dados_bancarios).permit(:codigo, :agencia, :conta_corrente) +
  124. +
    + +
    +
  125. + + + + + + end +
  126. +
    + +
    +
  127. + + + + + + end +
  128. +
    + +
+
+
+ + +
+
+

app/controllers/dashboard_controller.rb

+

+ + 59.52% + + + lines covered +

+ + + +
+ 126 relevant lines. + 75 lines covered and + 51 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class DashboardController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + before_action :user_logged +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + 1 + + + + + def index; end +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + 1 + + + + + def edit_user +
  12. +
    + +
    +
  13. + 3 + + + + + if current_user.kind_of?(User) +
  14. +
    + +
    +
  15. + 1 + + + + + @user = current_user +
  16. +
    + +
    +
  17. + 2 + + + + + elsif current_user.kind_of?(Professor) +
  18. +
    + +
    +
  19. + 1 + + + + + @professor = current_user +
  20. +
    + +
    +
  21. + + + + + + else +
  22. +
    + +
    +
  23. + 1 + + + + + flash[:danger] = "Apenas alunos e professores podem editar o perfil!" +
  24. +
    + +
    +
  25. + 1 + + + + + redirect_to dashboard_path +
  26. +
    + +
    +
  27. + + + + + + end +
  28. +
    + +
    +
  29. + + + + + + end +
  30. +
    + +
    +
  31. + + + + + + +
  32. +
    + +
    +
  33. + 1 + + + + + def dados_bancarios; end +
  34. +
    + +
    +
  35. + + + + + + +
  36. +
    + +
    +
  37. + 1 + + + + + def turmas; end +
  38. +
    + +
    +
  39. + + + + + + +
  40. +
    + +
    +
  41. + + + + + + ## +
  42. +
    + +
    +
  43. + + + + + + # Método chama a view dashboard/atendimentos para renderizar todos os atendimentos +
  44. +
    + +
    +
  45. + 1 + + + + + def atendimentos; end +
  46. +
    + +
    +
  47. + + + + + + +
  48. +
    + +
    +
  49. + 1 + + + + + def atividades; end +
  50. +
    + +
    +
  51. + + + + + + +
  52. +
    + +
    +
  53. + 1 + + + + + def monitorias +
  54. +
    + +
    +
  55. + + + + + + @user = current_user +
  56. +
    + +
    +
  57. + + + + + + @monitorias = Array.new +
  58. +
    + +
    +
  59. + + + + + + Monitoria.find_each do |m| +
  60. +
    + +
    +
  61. + + + + + + if @user.kind_of?(User) +
  62. +
    + +
    +
  63. + + + + + + if m.fk_matricula == @user.matricula +
  64. +
    + +
    +
  65. + + + + + + if m.fk_status_monitoria_id != 4 +
  66. +
    + +
    +
  67. + + + + + + @monitorias << m +
  68. +
    + +
    +
  69. + + + + + + end +
  70. +
    + +
    +
  71. + + + + + + end +
  72. +
    + +
    +
  73. + + + + + + end +
  74. +
    + +
    +
  75. + + + + + + end +
  76. +
    + +
    +
  77. + + + + + + end +
  78. +
    + +
    +
  79. + + + + + + +
  80. +
    + +
    +
  81. + 1 + + + + + def disciplinas +
  82. +
    + +
    +
  83. + 1 + + + + + @disciplinas = Disciplina.find_each +
  84. +
    + +
    +
  85. + + + + + + end +
  86. +
    + +
    +
  87. + + + + + + +
  88. +
    + +
    +
  89. + 1 + + + + + def apagar_alunos +
  90. +
    + +
    +
  91. + 2 + + + + + @users = User.order(:matricula) +
  92. +
    + +
    +
  93. + + + + + + end +
  94. +
    + +
    +
  95. + + + + + + +
  96. +
    + +
    +
  97. + 1 + + + + + def historico +
  98. +
    + +
    +
  99. + + + + + + @user = current_user +
  100. +
    + +
    +
  101. + + + + + + @mostrar = Array.new +
  102. +
    + +
    +
  103. + + + + + + Monitoria.find_each do |m| +
  104. +
    + +
    +
  105. + + + + + + if (@user.kind_of?(User) && m.fk_matricula == @user.matricula && m.fk_status_monitoria_id == 4) +
  106. +
    + +
    +
  107. + + + + + + @mostrar << m +
  108. +
    + +
    +
  109. + + + + + + end +
  110. +
    + +
    +
  111. + + + + + + end +
  112. +
    + +
    +
  113. + + + + + + end +
  114. +
    + +
    +
  115. + + + + + + +
  116. +
    + +
    +
  117. + 1 + + + + + def deletar_aluno +
  118. +
    + +
    +
  119. + + + + + + @matricula = params[:user][:matricula] +
  120. +
    + +
    +
  121. + + + + + + if @matricula.length == 0 +
  122. +
    + +
    +
  123. + + + + + + @matricula = nil +
  124. +
    + +
    +
  125. + + + + + + end +
  126. +
    + +
    +
  127. + + + + + + @user = User.find_by_matricula(@matricula) +
  128. +
    + +
    +
  129. + + + + + + +
  130. +
    + +
    +
  131. + + + + + + if !@user.nil? +
  132. +
    + +
    +
  133. + + + + + + @dados_bancarios = DadosBancarios.where(id: @user.fk_banco) +
  134. +
    + +
    +
  135. + + + + + + if !@dados_bancarios.nil? +
  136. +
    + +
    +
  137. + + + + + + DadosBancarios.delete(@dados_bancarios) +
  138. +
    + +
    +
  139. + + + + + + end +
  140. +
    + +
    +
  141. + + + + + + +
  142. +
    + +
    +
  143. + + + + + + @monitoria = Monitoria.where(fk_matricula: @user.matricula) +
  144. +
    + +
    +
  145. + + + + + + if !@monitoria.nil? +
  146. +
    + +
    +
  147. + + + + + + Monitoria.delete(@monitoria) +
  148. +
    + +
    +
  149. + + + + + + end +
  150. +
    + +
    +
  151. + + + + + + +
  152. +
    + +
    +
  153. + + + + + + @user = User.delete(@user.id) +
  154. +
    + +
    +
  155. + + + + + + flash[:notice] = 'Aluno apagado com sucesso!' +
  156. +
    + +
    +
  157. + + + + + + else +
  158. +
    + +
    +
  159. + + + + + + if !@matricula.nil? +
  160. +
    + +
    +
  161. + + + + + + flash[:danger] = "Aluno de matrícula #{@matricula} não existe." +
  162. +
    + +
    +
  163. + + + + + + else +
  164. +
    + +
    +
  165. + + + + + + flash[:danger] = "Digite uma matrícula para deletar algum aluno." +
  166. +
    + +
    +
  167. + + + + + + end +
  168. +
    + +
    +
  169. + + + + + + end +
  170. +
    + +
    +
  171. + + + + + + +
  172. +
    + +
    +
  173. + + + + + + redirect_to dashboard_apagar_alunos_path +
  174. +
    + +
    +
  175. + + + + + + end +
  176. +
    + +
    +
  177. + + + + + + +
  178. +
    + +
    +
  179. + 1 + + + + + def importar_disciplinas +
  180. +
    + +
    +
  181. + 1 + + + + + @disciplinas = Disciplina.all +
  182. +
    + +
    +
  183. + + + + + + end +
  184. +
    + +
    +
  185. + + + + + + +
  186. +
    + +
    +
  187. + + + + + + ## +
  188. +
    + +
    +
  189. + + + + + + # Método para raspar as disciplinas do site do MatrículaWeb +
  190. +
    + +
    +
  191. + + + + + + # e carregá-las no modelo. +
  192. +
    + +
    +
  193. + + + + + + +
  194. +
    + +
    +
  195. + 1 + + + + + def raspar_disciplinas +
  196. +
    + +
    +
  197. + 1 + + + + + disciplinas = raspar_matriculaweb_disciplinas +
  198. +
    + +
    +
  199. + 1 + + + + + carregar_disciplinas(disciplinas) +
  200. +
    + +
    +
  201. + + + + + + +
  202. +
    + +
    +
  203. + 1 + + + + + redirect_to dashboard_importar_disciplinas_path +
  204. +
    + +
    +
  205. + + + + + + end +
  206. +
    + +
    +
  207. + + + + + + +
  208. +
    + +
    +
  209. + 1 + + + + + def importar_professores +
  210. +
    + +
    +
  211. + 1 + + + + + @teachers = Professor.all +
  212. +
    + +
    +
  213. + + + + + + end +
  214. +
    + +
    +
  215. + + + + + + +
  216. +
    + +
    +
  217. + 1 + + + + + def scrape_professores +
  218. +
    + +
    +
  219. + 1 + + + + + web_scraper +
  220. +
    + +
    +
  221. + 1 + + + + + redirect_to dashboard_importar_professores_path +
  222. +
    + +
    +
  223. + + + + + + end +
  224. +
    + +
    +
  225. + + + + + + +
  226. +
    + +
    +
  227. + 1 + + + + + private +
  228. +
    + +
    +
  229. + 1 + + + + + def user_logged +
  230. +
    + +
    +
  231. + 2 + + + + + if !logged_in? +
  232. +
    + +
    +
  233. + 2 + + + + + redirect_to new_session_path, notice: "Você precisa estar logado para acessar essa página" +
  234. +
    + +
    +
  235. + + + + + + end +
  236. +
    + +
    +
  237. + + + + + + end +
  238. +
    + +
    +
  239. + + + + + + +
  240. +
    + +
    +
  241. + + + + + + +
  242. +
    + +
    +
  243. + + + + + + ## +
  244. +
    + +
    +
  245. + + + + + + # Método que faz a requisição da página das disciplinas. +
  246. +
    + +
    +
  247. + + + + + + # +
  248. +
    + +
    +
  249. + + + + + + # Retorna uma lista de hashes com os dados das disciplinas. +
  250. +
    + +
    +
  251. + + + + + + +
  252. +
    + +
    +
  253. + 1 + + + + + def raspar_matriculaweb_disciplinas(url = "https://matriculaweb.unb.br/graduacao/oferta_dis.aspx?cod=116") +
  254. +
    + +
    +
  255. + 1 + + + + + require 'open-uri' +
  256. +
    + +
    +
  257. + 1 + + + + + require 'openssl' +
  258. +
    + +
    +
  259. + 1 + + + + + require 'nokogiri' +
  260. +
    + +
    +
  261. + + + + + + +
  262. +
    + +
    +
  263. + 1 + + + + + pagina = Nokogiri::HTML(open(url)) +
  264. +
    + +
    +
  265. + 1 + + + + + tbls_disciplinas = pagina.css('#datatable').css('tr').drop(1) +
  266. +
    + +
    +
  267. + + + + + + +
  268. +
    + +
    +
  269. + 1 + + + + + disciplinas = [] +
  270. +
    + +
    +
  271. + + + + + + +
  272. +
    + +
    +
  273. + 1 + + + + + tbls_disciplinas.each do |d| +
  274. +
    + +
    +
  275. + + + + + + +
  276. +
    + +
    +
  277. + + + + + + disciplinas << extrai_campos_disciplina(d) +
  278. +
    + +
    +
  279. + + + + + + +
  280. +
    + +
    +
  281. + + + + + + end +
  282. +
    + +
    +
  283. + + + + + + +
  284. +
    + +
    +
  285. + 1 + + + + + disciplinas +
  286. +
    + +
    +
  287. + + + + + + +
  288. +
    + +
    +
  289. + + + + + + end +
  290. +
    + +
    +
  291. + + + + + + +
  292. +
    + +
    +
  293. + + + + + + ## +
  294. +
    + +
    +
  295. + + + + + + # Método que realiza as extrações dos dados da disciplina. +
  296. +
    + +
    +
  297. + + + + + + # Retorna um hash com as informações da disciplina. +
  298. +
    + +
    +
  299. + 1 + + + + + def extrai_campos_disciplina(node) +
  300. +
    + +
    +
  301. + + + + + + +
  302. +
    + +
    +
  303. + + + + + + link_disciplina = node.css('td')[1].css('a')[0][:href] +
  304. +
    + +
    +
  305. + + + + + + +
  306. +
    + +
    +
  307. + + + + + + info_disciplina = raspar_pagina_disciplina(caminho = link_disciplina) +
  308. +
    + +
    +
  309. + + + + + + +
  310. +
    + +
    +
  311. + + + + + + { +
  312. +
    + +
    +
  313. + + + + + + :cod_disciplina => node.css('td')[0].text, +
  314. +
    + +
    +
  315. + + + + + + :nome_disciplina => node.css('td')[1].text.titleize, +
  316. +
    + +
    +
  317. + + + + + + :creditos => info_disciplina[:creditos], +
  318. +
    + +
    +
  319. + + + + + + :turmas => info_disciplina[:turmas] +
  320. +
    + +
    +
  321. + + + + + + } +
  322. +
    + +
    +
  323. + + + + + + +
  324. +
    + +
    +
  325. + + + + + + end +
  326. +
    + +
    +
  327. + + + + + + +
  328. +
    + +
    +
  329. + + + + + + ## +
  330. +
    + +
    +
  331. + + + + + + # Método para fazer a requisição da página da oferta de uma disciplina específica. +
  332. +
    + +
    +
  333. + + + + + + # Retorna um hash com as informações de créditos e turmas das disciplinas. +
  334. +
    + +
    +
  335. + 1 + + + + + def raspar_pagina_disciplina(caminho, url_base = "https://matriculaweb.unb.br/graduacao/") +
  336. +
    + +
    +
  337. + + + + + + require 'open-uri' +
  338. +
    + +
    +
  339. + + + + + + require 'openssl' +
  340. +
    + +
    +
  341. + + + + + + require 'nokogiri' +
  342. +
    + +
    +
  343. + + + + + + +
  344. +
    + +
    +
  345. + + + + + + pagina = Nokogiri::HTML(open(url_base + caminho)) +
  346. +
    + +
    +
  347. + + + + + + tabelas = pagina.css('#datatable') +
  348. +
    + +
    +
  349. + + + + + + +
  350. +
    + +
    +
  351. + + + + + + c_teor, c_prat, c_ext, c_est = tabelas[0] +
  352. +
    + +
    +
  353. + + + + + + .css('tr:nth-child(4) > td') +
  354. +
    + +
    +
  355. + + + + + + .text.split('-').map {|str| str.to_i} +
  356. +
    + +
    +
  357. + + + + + + +
  358. +
    + +
    +
  359. + + + + + + { +
  360. +
    + +
    +
  361. + + + + + + :creditos => { +
  362. +
    + +
    +
  363. + + + + + + :c_prat => c_prat, +
  364. +
    + +
    +
  365. + + + + + + :c_teor => c_teor, +
  366. +
    + +
    +
  367. + + + + + + :c_est => c_est, +
  368. +
    + +
    +
  369. + + + + + + :c_ext => c_ext +
  370. +
    + +
    +
  371. + + + + + + }, +
  372. +
    + +
    +
  373. + + + + + + :turmas => extrai_turmas(tabelas) +
  374. +
    + +
    +
  375. + + + + + + } +
  376. +
    + +
    +
  377. + + + + + + +
  378. +
    + +
    +
  379. + + + + + + end +
  380. +
    + +
    +
  381. + + + + + + +
  382. +
    + +
    +
  383. + + + + + + ## +
  384. +
    + +
    +
  385. + + + + + + # Método para raspagem das turmas da disciplina. +
  386. +
    + +
    +
  387. + + + + + + # Retorna uma lista de hashes das turmas. +
  388. +
    + +
    +
  389. + 1 + + + + + def extrai_turmas(node) +
  390. +
    + +
    +
  391. + + + + + + turmas = [] +
  392. +
    + +
    +
  393. + + + + + + node.drop(1).each do |t| +
  394. +
    + +
    +
  395. + + + + + + turmas << extrai_campos_turma(t) +
  396. +
    + +
    +
  397. + + + + + + end +
  398. +
    + +
    +
  399. + + + + + + turmas +
  400. +
    + +
    +
  401. + + + + + + end +
  402. +
    + +
    +
  403. + + + + + + +
  404. +
    + +
    +
  405. + + + + + + ## +
  406. +
    + +
    +
  407. + + + + + + # Método para extração das informações da turma da página da oferta da +
  408. +
    + +
    +
  409. + + + + + + # disciplina no MatrículoWeb. +
  410. +
    + +
    +
  411. + + + + + + # Retorna um hash com nome da turma e nome do professor. +
  412. +
    + +
    +
  413. + 1 + + + + + def extrai_campos_turma(node) +
  414. +
    + +
    +
  415. + + + + + + { +
  416. +
    + +
    +
  417. + + + + + + :nome_turma => node.css('td.turma').text, +
  418. +
    + +
    +
  419. + + + + + + :nome_professor => node.css('tbody > tr > td:nth-child(5) td').text +
  420. +
    + +
    +
  421. + + + + + + } +
  422. +
    + +
    +
  423. + + + + + + end +
  424. +
    + +
    +
  425. + + + + + + +
  426. +
    + +
    +
  427. + + + + + + ## +
  428. +
    + +
    +
  429. + + + + + + # Método para carregar as disciplinas no modelo. +
  430. +
    + +
    +
  431. + 1 + + + + + def carregar_disciplinas(disciplinas) +
  432. +
    + +
    +
  433. + 1 + + + + + disciplinas.each do |d| +
  434. +
    + +
    +
  435. + + + + + + +
  436. +
    + +
    +
  437. + + + + + + if !Disciplina.find_by_id_disciplina(d[:id]) +
  438. +
    + +
    +
  439. + + + + + + +
  440. +
    + +
    +
  441. + + + + + + criar_disciplina( +
  442. +
    + +
    +
  443. + + + + + + d[:id], +
  444. +
    + +
    +
  445. + + + + + + d[:nome_disciplina], +
  446. +
    + +
    +
  447. + + + + + + d[:creditos] +
  448. +
    + +
    +
  449. + + + + + + ) +
  450. +
    + +
    +
  451. + + + + + + end +
  452. +
    + +
    +
  453. + + + + + + end +
  454. +
    + +
    +
  455. + + + + + + end +
  456. +
    + +
    +
  457. + + + + + + +
  458. +
    + +
    +
  459. + + + + + + ## +
  460. +
    + +
    +
  461. + + + + + + # Método para criar uma disciplina no modelo. +
  462. +
    + +
    +
  463. + 1 + + + + + def criar_disciplina(id_disciplina,cod_disciplina, nome, creditos) +
  464. +
    + +
    +
  465. + + + + + + Disciplina.create( +
  466. +
    + +
    +
  467. + + + + + + :id=> id_disciplina, +
  468. +
    + +
    +
  469. + + + + + + :cod_disciplina => cod_disciplina, +
  470. +
    + +
    +
  471. + + + + + + :nome => nome, +
  472. +
    + +
    +
  473. + + + + + + :c_prat => creditos[:c_prat], +
  474. +
    + +
    +
  475. + + + + + + :c_teor => creditos[:c_teor], +
  476. +
    + +
    +
  477. + + + + + + :c_est => creditos[:c_est], +
  478. +
    + +
    +
  479. + + + + + + :c_ext => creditos[:c_ext] +
  480. +
    + +
    +
  481. + + + + + + ) +
  482. +
    + +
    +
  483. + + + + + + end +
  484. +
    + +
    +
  485. + + + + + + +
  486. +
    + +
    +
  487. + + + + + + +
  488. +
    + +
    +
  489. + + + + + + # Faz um web scrape da página do CIC para adquirir os dados dos professores e cadastrá-los no BD +
  490. +
    + +
    +
  491. + 1 + + + + + def web_scraper +
  492. +
    + +
    +
  493. + + + + + + # Habilitam a abertura de webpages no código +
  494. +
    + +
    +
  495. + 1 + + + + + require 'open-uri' +
  496. +
    + +
    +
  497. + 1 + + + + + require 'openssl' +
  498. +
    + +
    +
  499. + + + + + + +
  500. +
    + +
    +
  501. + + + + + + # Cria um node a partir da página do CIC, filtrando pela 'div' em questão os elementos 'li'. Esse node contém todas +
  502. +
    + +
    +
  503. + + + + + + # as informações disponíveis de todos os professores +
  504. +
    + +
    +
  505. + 1 + + + + + teachers_list = Nokogiri::HTML(open('https://cic.unb.br/professores/', +
  506. +
    + +
    +
  507. + + + + + + :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)). +
  508. +
    + +
    +
  509. + + + + + + css('div#main-content'). +
  510. +
    + +
    +
  511. + + + + + + css('li') +
  512. +
    + +
    +
  513. + + + + + + +
  514. +
    + +
    +
  515. + 1 + + + + + teachers_list.each do |t| +
  516. +
    + +
    +
  517. + 87 + + + + + email = t.css('span.p-email').text.reverse +
  518. +
    + +
    +
  519. + + + + + + +
  520. +
    + +
    +
  521. + + + + + + # Verifica se o e-mail pertence ao domínio da UnB e se o e-mail já está cadastrado no banco de dados +
  522. +
    + +
    +
  523. + 87 + + + + + if valid_email?(email) && !Professor.find_by_email(email) +
  524. +
    + +
    +
  525. + 48 + + + + + create_teacher(t, email) +
  526. +
    + +
    +
  527. + + + + + + end +
  528. +
    + +
    +
  529. + + + + + + end +
  530. +
    + +
    +
  531. + + + + + + end +
  532. +
    + +
    +
  533. + + + + + + +
  534. +
    + +
    +
  535. + + + + + + # Verifica se o e-mail pertence ao domínio da UnB (retorna 'true' se sim e 'false', caso contrário) +
  536. +
    + +
    +
  537. + 1 + + + + + def valid_email?(email) +
  538. +
    + +
    +
  539. + 87 + + + + + email =~ /\A[\w+\-.]+@unb\.br\z/i +
  540. +
    + +
    +
  541. + + + + + + end +
  542. +
    + +
    +
  543. + + + + + + +
  544. +
    + +
    +
  545. + + + + + + # Cadastra um professor no banco de dados +
  546. +
    + +
    +
  547. + 1 + + + + + def create_teacher(teacher, email) +
  548. +
    + +
    +
  549. + 48 + + + + + pwd = generate_password +
  550. +
    + +
    +
  551. + 48 + + + + + Professor.create(:name => teacher.css('h4.people-details-h4').text.match(/(\S+\.?\s?)+/), +
  552. +
    + +
    +
  553. + + + + + + :email => email, +
  554. +
    + +
    +
  555. + + + + + + :username => email.match(/[^@]+/), +
  556. +
    + +
    +
  557. + + + + + + :role => match_role(teacher.css('span.people-details.p-people').text), +
  558. +
    + +
    +
  559. + + + + + + :password => pwd, +
  560. +
    + +
    +
  561. + + + + + + :password_confirmation => pwd) +
  562. +
    + +
    +
  563. + + + + + + end +
  564. +
    + +
    +
  565. + + + + + + +
  566. +
    + +
    +
  567. + + + + + + # Gera uma string de caracteres aleatórios de tamanho adequado para salvar como senha do professor no BD. +
  568. +
    + +
    +
  569. + + + + + + # Essa senha é apenas um placeholder, durante o cadastro, o professor deverá modifica-la. +
  570. +
    + +
    +
  571. + 1 + + + + + def generate_password +
  572. +
    + +
    +
  573. + 48 + + + + + require 'securerandom' +
  574. +
    + +
    +
  575. + 48 + + + + + SecureRandom.base64(9) +
  576. +
    + +
    +
  577. + + + + + + end +
  578. +
    + +
    +
  579. + + + + + + +
  580. +
    + +
    +
  581. + + + + + + # Faz o match da titularidade do professor com o número esperado no BD +
  582. +
    + +
    +
  583. + 1 + + + + + def match_role(role) +
  584. +
    + +
    +
  585. + 48 + + + + + case role +
  586. +
    + +
    +
  587. + + + + + + when /substituto/i +
  588. +
    + +
    +
  589. + + + + + + 1 +
  590. +
    + +
    +
  591. + + + + + + when /colaborador/i +
  592. +
    + +
    +
  593. + 2 + + + + + 3 +
  594. +
    + +
    +
  595. + + + + + + when /adjunto/i +
  596. +
    + +
    +
  597. + 32 + + + + + 4 +
  598. +
    + +
    +
  599. + + + + + + when /associado/i +
  600. +
    + +
    +
  601. + 9 + + + + + 5 +
  602. +
    + +
    +
  603. + + + + + + when /titular/i +
  604. +
    + +
    +
  605. + 4 + + + + + 6 +
  606. +
    + +
    +
  607. + + + + + + # Cláusula específica para um erro comum do parser: retornar uma string contendo apenas caracteres de espaço +
  608. +
    + +
    +
  609. + + + + + + when /\A\s/ +
  610. +
    + +
    +
  611. + + + + + + 0 +
  612. +
    + +
    +
  613. + + + + + + # Cláusula padrão retorna um valor para cadastrar o professor com o papel de 'professor' no BD +
  614. +
    + +
    +
  615. + + + + + + else +
  616. +
    + +
    +
  617. + 1 + + + + + 2 +
  618. +
    + +
    +
  619. + + + + + + end +
  620. +
    + +
    +
  621. + + + + + + end +
  622. +
    + +
    +
  623. + + + + + + +
  624. +
    + +
    +
  625. + + + + + + end +
  626. +
    + +
+
+
+ + +
+
+

app/controllers/disciplinas_controller.rb

+

+ + 84.62% + + + lines covered +

+ + + +
+ 39 relevant lines. + 33 lines covered and + 6 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class DisciplinasController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + before_action :find_disciplina, only: [:show, :edit, :update, :destroy] +
  4. +
    + +
    +
  5. + 1 + + + + + before_action :is_admin, only: [:edit, :new, :create, :update, :destroy] +
  6. +
    + +
    +
  7. + 1 + + + + + before_action :logged_in +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + 1 + + + + + def new +
  12. +
    + +
    +
  13. + 1 + + + + + @disciplina = Disciplina.new +
  14. +
    + +
    +
  15. + + + + + + end +
  16. +
    + +
    +
  17. + + + + + + +
  18. +
    + +
    +
  19. + 1 + + + + + def create +
  20. +
    + +
    +
  21. + 4 + + + + + @disciplina = Disciplina.new disciplina_params +
  22. +
    + +
    +
  23. + + + + + + +
  24. +
    + +
    +
  25. + 4 + + + + + if @disciplina.save +
  26. +
    + +
    +
  27. + 3 + + + + + redirect_to dashboard_disciplinas_path, notice: "Disciplina cadastrada com sucesso!" +
  28. +
    + +
    +
  29. + + + + + + else +
  30. +
    + +
    +
  31. + 1 + + + + + flash[:danger] = "Ocorreu um erro ao cadastrar a disciplina. Nenhuma disciplina cadastrada." +
  32. +
    + +
    +
  33. + 1 + + + + + render 'new' +
  34. +
    + +
    +
  35. + + + + + + end +
  36. +
    + +
    +
  37. + + + + + + end +
  38. +
    + +
    +
  39. + + + + + + +
  40. +
    + +
    +
  41. + 1 + + + + + def edit; end +
  42. +
    + +
    +
  43. + + + + + + +
  44. +
    + +
    +
  45. + 1 + + + + + def update +
  46. +
    + +
    +
  47. + 4 + + + + + if @disciplina.update disciplina_params +
  48. +
    + +
    +
  49. + 3 + + + + + redirect_to dashboard_disciplinas_path, notice: "Disciplina atualizada!" +
  50. +
    + +
    +
  51. + + + + + + else +
  52. +
    + +
    +
  53. + 1 + + + + + flash[:danger] = "Ocorreu um erro ao atualizar a disciplina." +
  54. +
    + +
    +
  55. + 1 + + + + + render 'edit' +
  56. +
    + +
    +
  57. + + + + + + end +
  58. +
    + +
    +
  59. + + + + + + end +
  60. +
    + +
    +
  61. + + + + + + +
  62. +
    + +
    +
  63. + 1 + + + + + def destroy +
  64. +
    + +
    +
  65. + 1 + + + + + Turma.find_each do |t| +
  66. +
    + +
    +
  67. + 1 + + + + + if t.fk_cod_disciplina == @disciplina.cod_disciplina +
  68. +
    + +
    +
  69. + 1 + + + + + t.destroy +
  70. +
    + +
    +
  71. + + + + + + end +
  72. +
    + +
    +
  73. + + + + + + end +
  74. +
    + +
    +
  75. + 1 + + + + + Monitoria.find_each do |m| +
  76. +
    + +
    +
  77. + 1 + + + + + if m.fk_cod_disciplina == @disciplina.cod_disciplina +
  78. +
    + +
    +
  79. + + + + + + m.destroy +
  80. +
    + +
    +
  81. + + + + + + end +
  82. +
    + +
    +
  83. + + + + + + end +
  84. +
    + +
    +
  85. + 1 + + + + + @disciplina.destroy +
  86. +
    + +
    +
  87. + 1 + + + + + redirect_to dashboard_disciplinas_path, notice: "Disciplina removida!" +
  88. +
    + +
    +
  89. + + + + + + end +
  90. +
    + +
    +
  91. + + + + + + +
  92. +
    + +
    +
  93. + 1 + + + + + private +
  94. +
    + +
    +
  95. + 1 + + + + + def disciplina_params +
  96. +
    + +
    +
  97. + 5 + + + + + params.require(:disciplina).permit(:nome, :fk_tipo_disciplina_id, :c_prat, :c_teor, :c_est, :c_ext, :monitoria) +
  98. +
    + +
    +
  99. + + + + + + end +
  100. +
    + +
    +
  101. + + + + + + +
  102. +
    + +
    +
  103. + 1 + + + + + def find_disciplina +
  104. +
    + +
    +
  105. + 6 + + + + + @disciplina = Disciplina.find(params[:id]) +
  106. +
    + +
    +
  107. + + + + + + end +
  108. +
    + +
    +
  109. + + + + + + +
  110. +
    + +
    +
  111. + 1 + + + + + def logged_in +
  112. +
    + +
    +
  113. + + + + + + if !logged_in? +
  114. +
    + +
    +
  115. + + + + + + redirect_to new_session_path, notice: "Você precisa estar logado para acessar as Disciplinas" +
  116. +
    + +
    +
  117. + + + + + + end +
  118. +
    + +
    +
  119. + + + + + + end +
  120. +
    + +
    +
  121. + + + + + + +
  122. +
    + +
    +
  123. + 1 + + + + + def is_admin +
  124. +
    + +
    +
  125. + + + + + + if !current_user.kind_of?(Admin) +
  126. +
    + +
    +
  127. + + + + + + flash[:danger] = "Acesso negado." +
  128. +
    + +
    +
  129. + + + + + + redirect_to dashboard_disciplinas_path +
  130. +
    + +
    +
  131. + + + + + + end +
  132. +
    + +
    +
  133. + + + + + + end +
  134. +
    + +
    +
  135. + + + + + + end +
  136. +
    + +
+
+
+ + +
+
+

app/controllers/faq_controller.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 2 relevant lines. + 2 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class FaqController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + def index ; end +
  4. +
    + +
    +
  5. + + + + + + end +
  6. +
    + +
+
+
+ + +
+
+

app/controllers/historico_controller.rb

+

+ + 0.0% + + + lines covered +

+ + + +
+ 2 relevant lines. + 0 lines covered and + 2 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + + + + + + class HistoricoController < ApplicationController +
  2. +
    + +
    +
  3. + + + + + + +
  4. +
    + +
    +
  5. + + + + + + end +
  6. +
    + +
+
+
+ + +
+
+

app/controllers/home_controller.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 2 relevant lines. + 2 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class HomeController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + def index ; end +
  4. +
    + +
    +
  5. + + + + + + end +
  6. +
    + +
+
+
+ + +
+
+

app/controllers/monitorias_controller.rb

+

+ + 89.19% + + + lines covered +

+ + + +
+ 37 relevant lines. + 33 lines covered and + 4 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class MonitoriasController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + before_action :find_monitor, only: [:show] +
  4. +
    + +
    +
  5. + 1 + + + + + before_action :find_monitoria, only: [:destroy, :edit, :update] +
  6. +
    + +
    +
  7. + 1 + + + + + before_action :logged_in +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + 1 + + + + + def new +
  12. +
    + +
    +
  13. + 1 + + + + + @cod_disciplina = params[:turma] +
  14. +
    + +
    +
  15. + 1 + + + + + @user = current_user +
  16. +
    + +
    +
  17. + + + + + + end +
  18. +
    + +
    +
  19. + + + + + + +
  20. +
    + +
    +
  21. + 1 + + + + + def create +
  22. +
    + +
    +
  23. + 4 + + + + + @monitoria = Monitoria.new(monitoria_params) +
  24. +
    + +
    +
  25. + 4 + + + + + valid = true +
  26. +
    + +
    +
  27. + 4 + + + + + Monitoria.find_each do |m| +
  28. +
    + +
    +
  29. + 8 + + + + + if m.fk_matricula==@monitoria.fk_matricula and m.fk_turmas_id==@monitoria.fk_turmas_id and m.fk_cod_disciplina==@monitoria.fk_cod_disciplina +
  30. +
    + +
    +
  31. + 8 + + + + + valid = false +
  32. +
    + +
    +
  33. + + + + + + end +
  34. +
    + +
    +
  35. + + + + + + end +
  36. +
    + +
    +
  37. + + + + + + +
  38. +
    + +
    +
  39. + 4 + + + + + if valid and @monitoria.save +
  40. +
    + +
    +
  41. + + + + + + redirect_to dashboard_monitorias_path, notice: "Aplicaçao para monitoria enviada com sucesso!" +
  42. +
    + +
    +
  43. + + + + + + else +
  44. +
    + +
    +
  45. + 4 + + + + + flash[:danger] = "Ocorreu um erro ao cadastrar a monitoria. Nenhuma monitoria cadastrada." +
  46. +
    + +
    +
  47. + 4 + + + + + redirect_to dashboard_monitorias_path +
  48. +
    + +
    +
  49. + + + + + + end +
  50. +
    + +
    +
  51. + + + + + + end +
  52. +
    + +
    +
  53. + + + + + + +
  54. +
    + +
    +
  55. + 1 + + + + + def show +
  56. +
    + +
    +
  57. + 1 + + + + + @alunos = User.find_each +
  58. +
    + +
    +
  59. + + + + + + end +
  60. +
    + +
    +
  61. + + + + + + +
  62. +
    + +
    +
  63. + 1 + + + + + def edit +
  64. +
    + +
    +
  65. + + + + + + end +
  66. +
    + +
    +
  67. + + + + + + +
  68. +
    + +
    +
  69. + 1 + + + + + def update +
  70. +
    + +
    +
  71. + 3 + + + + + if @monitoria.update monitoria_params +
  72. +
    + +
    +
  73. + 3 + + + + + redirect_to dashboard_monitorias_path, notice: "Situaçao atualizada!" +
  74. +
    + +
    +
  75. + + + + + + else +
  76. +
    + +
    +
  77. + + + + + + render 'edit' +
  78. +
    + +
    +
  79. + + + + + + end +
  80. +
    + +
    +
  81. + + + + + + end +
  82. +
    + +
    +
  83. + + + + + + +
  84. +
    + +
    +
  85. + 1 + + + + + def destroy +
  86. +
    + +
    +
  87. + 1 + + + + + @monitoria.destroy +
  88. +
    + +
    +
  89. + 1 + + + + + redirect_to dashboard_monitorias_path, notice: "Monitoria removida!" +
  90. +
    + +
    +
  91. + + + + + + end +
  92. +
    + +
    +
  93. + + + + + + +
  94. +
    + +
    +
  95. + 1 + + + + + private +
  96. +
    + +
    +
  97. + 1 + + + + + def monitoria_params +
  98. +
    + +
    +
  99. + 4 + + + + + params.require(:monitoria).permit(:remuneracao, :fk_matricula, :fk_cod_disciplina, :fk_turmas_id, :descricao_status, :prioridade, :fk_status_monitoria_id) +
  100. +
    + +
    +
  101. + + + + + + end +
  102. +
    + +
    +
  103. + + + + + + +
  104. +
    + +
    +
  105. + 1 + + + + + def find_monitor +
  106. +
    + +
    +
  107. + 1 + + + + + @monitoria = Monitoria.where(fk_turmas_id: params[:id]) +
  108. +
    + +
    +
  109. + + + + + + end +
  110. +
    + +
    +
  111. + + + + + + +
  112. +
    + +
    +
  113. + 1 + + + + + def find_monitoria +
  114. +
    + +
    +
  115. + 5 + + + + + @monitoria = Monitoria.find(params[:id]) +
  116. +
    + +
    +
  117. + + + + + + end +
  118. +
    + +
    +
  119. + + + + + + +
  120. +
    + +
    +
  121. + 1 + + + + + def logged_in +
  122. +
    + +
    +
  123. + + + + + + if !logged_in? +
  124. +
    + +
    +
  125. + + + + + + redirect_to new_session_path, notice: "Você precisa estar logado para acessar a pagina Monitoria" +
  126. +
    + +
    +
  127. + + + + + + end +
  128. +
    + +
    +
  129. + + + + + + end +
  130. +
    + +
    +
  131. + + + + + + end +
  132. +
    + +
+
+
+ + +
+
+

app/controllers/motivos_controller.rb

+

+ + 0.0% + + + lines covered +

+ + + +
+ 50 relevant lines. + 0 lines covered and + 50 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + + + + + + class MotivosController < ApplicationController +
  2. +
    + +
    +
  3. + + + + + + before_action :set_motivo, only: [:show, :edit, :update, :destroy] +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + + + + + + # GET /motivos +
  8. +
    + +
    +
  9. + + + + + + # GET /motivos.json +
  10. +
    + +
    +
  11. + + + + + + def index +
  12. +
    + +
    +
  13. + + + + + + @motivos = Motivo.all +
  14. +
    + +
    +
  15. + + + + + + end +
  16. +
    + +
    +
  17. + + + + + + +
  18. +
    + +
    +
  19. + + + + + + # GET /motivos/1 +
  20. +
    + +
    +
  21. + + + + + + # GET /motivos/1.json +
  22. +
    + +
    +
  23. + + + + + + def show +
  24. +
    + +
    +
  25. + + + + + + end +
  26. +
    + +
    +
  27. + + + + + + +
  28. +
    + +
    +
  29. + + + + + + # GET /motivos/new +
  30. +
    + +
    +
  31. + + + + + + def new +
  32. +
    + +
    +
  33. + + + + + + @motivo = Motivo.new +
  34. +
    + +
    +
  35. + + + + + + end +
  36. +
    + +
    +
  37. + + + + + + +
  38. +
    + +
    +
  39. + + + + + + # GET /motivos/1/edit +
  40. +
    + +
    +
  41. + + + + + + def edit +
  42. +
    + +
    +
  43. + + + + + + end +
  44. +
    + +
    +
  45. + + + + + + +
  46. +
    + +
    +
  47. + + + + + + # POST /motivos +
  48. +
    + +
    +
  49. + + + + + + # POST /motivos.json +
  50. +
    + +
    +
  51. + + + + + + def create +
  52. +
    + +
    +
  53. + + + + + + @motivo = Motivo.new(motivo_params) +
  54. +
    + +
    +
  55. + + + + + + +
  56. +
    + +
    +
  57. + + + + + + respond_to do |format| +
  58. +
    + +
    +
  59. + + + + + + if @motivo.save +
  60. +
    + +
    +
  61. + + + + + + format.html { redirect_to @motivo, notice: 'Motivo was successfully created.' } +
  62. +
    + +
    +
  63. + + + + + + format.json { render :show, status: :created, location: @motivo } +
  64. +
    + +
    +
  65. + + + + + + else +
  66. +
    + +
    +
  67. + + + + + + format.html { render :new } +
  68. +
    + +
    +
  69. + + + + + + format.json { render json: @motivo.errors, status: :unprocessable_entity } +
  70. +
    + +
    +
  71. + + + + + + end +
  72. +
    + +
    +
  73. + + + + + + end +
  74. +
    + +
    +
  75. + + + + + + end +
  76. +
    + +
    +
  77. + + + + + + +
  78. +
    + +
    +
  79. + + + + + + # PATCH/PUT /motivos/1 +
  80. +
    + +
    +
  81. + + + + + + # PATCH/PUT /motivos/1.json +
  82. +
    + +
    +
  83. + + + + + + def update +
  84. +
    + +
    +
  85. + + + + + + respond_to do |format| +
  86. +
    + +
    +
  87. + + + + + + if @motivo.update(motivo_params) +
  88. +
    + +
    +
  89. + + + + + + format.html { redirect_to @motivo, notice: 'Motivo was successfully updated.' } +
  90. +
    + +
    +
  91. + + + + + + format.json { render :show, status: :ok, location: @motivo } +
  92. +
    + +
    +
  93. + + + + + + else +
  94. +
    + +
    +
  95. + + + + + + format.html { render :edit } +
  96. +
    + +
    +
  97. + + + + + + format.json { render json: @motivo.errors, status: :unprocessable_entity } +
  98. +
    + +
    +
  99. + + + + + + end +
  100. +
    + +
    +
  101. + + + + + + end +
  102. +
    + +
    +
  103. + + + + + + end +
  104. +
    + +
    +
  105. + + + + + + +
  106. +
    + +
    +
  107. + + + + + + # DELETE /motivos/1 +
  108. +
    + +
    +
  109. + + + + + + # DELETE /motivos/1.json +
  110. +
    + +
    +
  111. + + + + + + def destroy +
  112. +
    + +
    +
  113. + + + + + + @motivo.destroy +
  114. +
    + +
    +
  115. + + + + + + respond_to do |format| +
  116. +
    + +
    +
  117. + + + + + + format.html { redirect_to motivos_url, notice: 'Motivo was successfully destroyed.' } +
  118. +
    + +
    +
  119. + + + + + + format.json { head :no_content } +
  120. +
    + +
    +
  121. + + + + + + end +
  122. +
    + +
    +
  123. + + + + + + end +
  124. +
    + +
    +
  125. + + + + + + +
  126. +
    + +
    +
  127. + + + + + + private +
  128. +
    + +
    +
  129. + + + + + + # Use callbacks to share common setup or constraints between actions. +
  130. +
    + +
    +
  131. + + + + + + def set_motivo +
  132. +
    + +
    +
  133. + + + + + + @motivo = Motivo.find(params[:id]) +
  134. +
    + +
    +
  135. + + + + + + end +
  136. +
    + +
    +
  137. + + + + + + +
  138. +
    + +
    +
  139. + + + + + + # Never trust parameters from the scary internet, only allow the white list through. +
  140. +
    + +
    +
  141. + + + + + + def motivo_params +
  142. +
    + +
    +
  143. + + + + + + params.require(:motivo).permit(:nome) +
  144. +
    + +
    +
  145. + + + + + + end +
  146. +
    + +
    +
  147. + + + + + + end +
  148. +
    + +
+
+
+ + +
+
+

app/controllers/professors_controller.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 25 relevant lines. + 25 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class ProfessorsController < ApplicationController +
  2. +
    + +
    +
  3. + + + + + + +
  4. +
    + +
    +
  5. + + + + + + # usando como pagina de selecao de professores (issue: select de professores) +
  6. +
    + +
    +
  7. + 1 + + + + + def index +
  8. +
    + +
    +
  9. + + + + + + # conteudo do select de professores +
  10. +
    + +
    +
  11. + 1 + + + + + @professor = Professor.all +
  12. +
    + +
    +
  13. + + + + + + end +
  14. +
    + +
    +
  15. + + + + + + +
  16. +
    + +
    +
  17. + 1 + + + + + def new ; end +
  18. +
    + +
    +
  19. + + + + + + +
  20. +
    + +
    +
  21. + 1 + + + + + def create +
  22. +
    + +
    +
  23. + 6 + + + + + @professor = Professor.create(professor_params) +
  24. +
    + +
    +
  25. + + + + + + +
  26. +
    + +
    +
  27. + 6 + + + + + if !@professor.errors.any? +
  28. +
    + +
    +
  29. + 2 + + + + + flash[:notice] = "Registro realizado com sucesso!" +
  30. +
    + +
    +
  31. + 2 + + + + + log_in(@professor) +
  32. +
    + +
    +
  33. + 2 + + + + + redirect_to dashboard_path +
  34. +
    + +
    +
  35. + + + + + + else +
  36. +
    + +
    +
  37. + 4 + + + + + flash[:danger] = @professor.errors.full_messages +
  38. +
    + +
    +
  39. + 4 + + + + + redirect_to new_professor_path +
  40. +
    + +
    +
  41. + + + + + + end +
  42. +
    + +
    +
  43. + + + + + + end +
  44. +
    + +
    +
  45. + + + + + + # usando como pagina de confirmacao dos professores +
  46. +
    + +
    +
  47. + 1 + + + + + def identityconfirmation +
  48. +
    + +
    +
  49. + + + + + + # procura o professor selecionado na lista +
  50. +
    + +
    +
  51. + 2 + + + + + @professor = Professor.where(:name => params[:professor][:name])[0] +
  52. +
    + +
    +
  53. + + + + + + # faz o envio do e-mail de confirmação para o respectivo professor +
  54. +
    + +
    +
  55. + 2 + + + + + ProfessorMailer.with(professor: @professor).key_email.deliver_now +
  56. +
    + +
    +
  57. + + + + + + end +
  58. +
    + +
    +
  59. + + + + + + +
  60. +
    + +
    +
  61. + 1 + + + + + def update +
  62. +
    + +
    +
  63. + 6 + + + + + @professor = Professor.find_by_email(session[:user_id]) +
  64. +
    + +
    +
  65. + 6 + + + + + @professor.update_attributes(professor_params) +
  66. +
    + +
    +
  67. + + + + + + +
  68. +
    + +
    +
  69. + 6 + + + + + if !@professor.errors.any? +
  70. +
    + +
    +
  71. + 4 + + + + + flash[:notice] = "Cadastro atualizado com sucesso!" +
  72. +
    + +
    +
  73. + + + + + + elsif +
  74. +
    + +
    +
  75. + 2 + + + + + flash[:danger] = @professor.errors.full_messages +
  76. +
    + +
    +
  77. + + + + + + end +
  78. +
    + +
    +
  79. + + + + + + +
  80. +
    + +
    +
  81. + 6 + + + + + redirect_to dashboard_path +
  82. +
    + +
    +
  83. + + + + + + end +
  84. +
    + +
    +
  85. + + + + + + +
  86. +
    + +
    +
  87. + 1 + + + + + protected +
  88. +
    + +
    +
  89. + + + + + + +
  90. +
    + +
    +
  91. + 1 + + + + + def professor_params +
  92. +
    + +
    +
  93. + 9 + + + + + params.require(:professor).permit(:id, :name, :username, :email, :role, :password, :password_confirmation) +
  94. +
    + +
    +
  95. + + + + + + end +
  96. +
    + +
    +
  97. + + + + + + end +
  98. +
    + +
+
+
+ + +
+
+

app/controllers/reset_senhas_controller.rb

+

+ + 66.67% + + + lines covered +

+ + + +
+ 36 relevant lines. + 24 lines covered and + 12 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class ResetSenhasController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + before_action :get_user, only: [:edit, :update] +
  4. +
    + +
    +
  5. + 1 + + + + + before_action :valid_user, only: [:edit, :update] +
  6. +
    + +
    +
  7. + 1 + + + + + before_action :check_expiration, only: [:edit, :update] +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + 1 + + + + + def new +
  12. +
    + +
    +
  13. + + + + + + end +
  14. +
    + +
    +
  15. + + + + + + +
  16. +
    + +
    +
  17. + 1 + + + + + def create +
  18. +
    + +
    +
  19. + 3 + + + + + @user = User.find_by(email: params[:reset_senha][:email].downcase) +
  20. +
    + +
    +
  21. + 3 + + + + + if @user +
  22. +
    + +
    +
  23. + 1 + + + + + @user.create_reset_digest +
  24. +
    + +
    +
  25. + 1 + + + + + @user.send_password_reset_email +
  26. +
    + +
    +
  27. + 1 + + + + + flash[:notice] = "As instruções para resetar sua senha foram enviadas para seu e-mail." +
  28. +
    + +
    +
  29. + 1 + + + + + redirect_to root_url +
  30. +
    + +
    +
  31. + + + + + + else +
  32. +
    + +
    +
  33. + 2 + + + + + flash.now[:danger] = "Seu e-mail não foi encontrado." +
  34. +
    + +
    +
  35. + 2 + + + + + render 'new' +
  36. +
    + +
    +
  37. + + + + + + end +
  38. +
    + +
    +
  39. + + + + + + end +
  40. +
    + +
    +
  41. + + + + + + +
  42. +
    + +
    +
  43. + 1 + + + + + def edit +
  44. +
    + +
    +
  45. + + + + + + end +
  46. +
    + +
    +
  47. + + + + + + +
  48. +
    + +
    +
  49. + 1 + + + + + def update +
  50. +
    + +
    +
  51. + + + + + + if params[:user][:password].empty? +
  52. +
    + +
    +
  53. + + + + + + @user.errors.add(:password, "O campo senha deve ser preenchido.") +
  54. +
    + +
    +
  55. + + + + + + render 'edit' +
  56. +
    + +
    +
  57. + + + + + + elsif @user.update_attributes(user_params) +
  58. +
    + +
    +
  59. + + + + + + log_in @user +
  60. +
    + +
    +
  61. + + + + + + flash[:success] = "Sua nova senha foi salva." +
  62. +
    + +
    +
  63. + + + + + + redirect_to dashboard_path +
  64. +
    + +
    +
  65. + + + + + + else +
  66. +
    + +
    +
  67. + + + + + + render 'edit' +
  68. +
    + +
    +
  69. + + + + + + end +
  70. +
    + +
    +
  71. + + + + + + end +
  72. +
    + +
    +
  73. + + + + + + +
  74. +
    + +
    +
  75. + 1 + + + + + private +
  76. +
    + +
    +
  77. + + + + + + +
  78. +
    + +
    +
  79. + + + + + + # Instancia o usuário em questão procurando por seu e-mail +
  80. +
    + +
    +
  81. + 1 + + + + + def get_user +
  82. +
    + +
    +
  83. + 5 + + + + + @user = User.find_by(email: params[:email]) +
  84. +
    + +
    +
  85. + + + + + + end +
  86. +
    + +
    +
  87. + + + + + + +
  88. +
    + +
    +
  89. + + + + + + # Confirma se o usuário instanciado acima é válido verificando o token que foi passado +
  90. +
    + +
    +
  91. + 1 + + + + + def valid_user +
  92. +
    + +
    +
  93. + 4 + + + + + unless @user && @user.authenticated?(:reset, params[:id]) +
  94. +
    + +
    +
  95. + 4 + + + + + redirect_to root_url +
  96. +
    + +
    +
  97. + + + + + + end +
  98. +
    + +
    +
  99. + + + + + + end +
  100. +
    + +
    +
  101. + + + + + + +
  102. +
    + +
    +
  103. + + + + + + # Verifica se o token em questão expirou +
  104. +
    + +
    +
  105. + 1 + + + + + def check_expiration +
  106. +
    + +
    +
  107. + + + + + + if @user.password_reset_expired? +
  108. +
    + +
    +
  109. + + + + + + flash[:danger] = "Password reset has expired." +
  110. +
    + +
    +
  111. + + + + + + redirect_to new_reset_senha_url +
  112. +
    + +
    +
  113. + + + + + + end +
  114. +
    + +
    +
  115. + + + + + + end +
  116. +
    + +
    +
  117. + + + + + + +
  118. +
    + +
    +
  119. + + + + + + # Filtra os parâmetros que serão passados para o BD +
  120. +
    + +
    +
  121. + 1 + + + + + def user_params +
  122. +
    + +
    +
  123. + + + + + + params.require(:user).permit(:password, :password_confirmation) +
  124. +
    + +
    +
  125. + + + + + + end +
  126. +
    + +
    +
  127. + + + + + + end +
  128. +
    + +
+
+
+ + +
+
+

app/controllers/sessions_controller.rb

+

+ + 71.43% + + + lines covered +

+ + + +
+ 14 relevant lines. + 10 lines covered and + 4 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class SessionsController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + def new ; end +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + 1 + + + + + def create +
  8. +
    + +
    +
  9. + + + + + + ## Busca aluno e professor. Retorna apenas um que for encontrado. +
  10. +
    + +
    +
  11. + 3 + + + + + @login ||= User.find_by_email(login_params[:email]) || +
  12. +
    + +
    +
  13. + + + + + + Professor.find_by_email(login_params[:email]) || +
  14. +
    + +
    +
  15. + + + + + + Admin.find_by_email(login_params[:email]) +
  16. +
    + +
    +
  17. + + + + + + +
  18. +
    + +
    +
  19. + 3 + + + + + if @login&.authenticate(login_params[:password]) +
  20. +
    + +
    +
  21. + 3 + + + + + log_in(@login) +
  22. +
    + +
    +
  23. + 3 + + + + + redirect_to dashboard_path +
  24. +
    + +
    +
  25. + + + + + + else +
  26. +
    + +
    +
  27. + + + + + + flash[:danger] = "Email ou senha inválidos" +
  28. +
    + +
    +
  29. + + + + + + redirect_to new_session_path +
  30. +
    + +
    +
  31. + + + + + + end +
  32. +
    + +
    +
  33. + + + + + + end +
  34. +
    + +
    +
  35. + + + + + + +
  36. +
    + +
    +
  37. + 1 + + + + + def destroy +
  38. +
    + +
    +
  39. + + + + + + session[:user_id] = nil +
  40. +
    + +
    +
  41. + + + + + + redirect_to root_url +
  42. +
    + +
    +
  43. + + + + + + end +
  44. +
    + +
    +
  45. + + + + + + +
  46. +
    + +
    +
  47. + + + + + + ## Define os parâmetros que serão lidos no formulário de login +
  48. +
    + +
    +
  49. + 1 + + + + + def login_params +
  50. +
    + +
    +
  51. + 6 + + + + + params.require(:user).permit(:email, :password) +
  52. +
    + +
    +
  53. + + + + + + end +
  54. +
    + +
    +
  55. + + + + + + end +
  56. +
    + +
+
+
+ + +
+
+

app/controllers/sobre_controller.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 2 relevant lines. + 2 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class SobreController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + def index ; end +
  4. +
    + +
    +
  5. + + + + + + end +
  6. +
    + +
+
+
+ + +
+
+

app/controllers/tarefas_controller.rb

+

+ + 36.36% + + + lines covered +

+ + + +
+ 33 relevant lines. + 12 lines covered and + 21 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class TarefasController < ApplicationController +
  2. +
    + +
    +
  3. + 1 + + + + + before_action :set_tarefa, only: [:show, :edit, :update, :destroy] +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + + + + + + # GET /tarefas +
  8. +
    + +
    +
  9. + + + + + + # GET /tarefas.json +
  10. +
    + +
    +
  11. + 1 + + + + + def index +
  12. +
    + +
    +
  13. + + + + + + @tarefas = [] +
  14. +
    + +
    +
  15. + + + + + + @monitoria_id = params[:monitoria_id].to_i +
  16. +
    + +
    +
  17. + + + + + + @all_tarefas = Tarefa.all +
  18. +
    + +
    +
  19. + + + + + + @all_tarefas.each do |tarefa| +
  20. +
    + +
    +
  21. + + + + + + if tarefa.monitoria_id == @monitoria_id +
  22. +
    + +
    +
  23. + + + + + + @tarefas.push(tarefa) +
  24. +
    + +
    +
  25. + + + + + + end +
  26. +
    + +
    +
  27. + + + + + + end +
  28. +
    + +
    +
  29. + + + + + + end +
  30. +
    + +
    +
  31. + + + + + + +
  32. +
    + +
    +
  33. + + + + + + # GET /tarefas/1 +
  34. +
    + +
    +
  35. + + + + + + # GET /tarefas/1.json +
  36. +
    + +
    +
  37. + 1 + + + + + def show +
  38. +
    + +
    +
  39. + + + + + + +
  40. +
    + +
    +
  41. + + + + + + end +
  42. +
    + +
    +
  43. + + + + + + +
  44. +
    + +
    +
  45. + + + + + + # GET /tarefas/new +
  46. +
    + +
    +
  47. + 1 + + + + + def new +
  48. +
    + +
    +
  49. + + + + + + @monitoria_id = params[:monitoria_id] +
  50. +
    + +
    +
  51. + + + + + + @tarefa = Tarefa.new(:monitoria_id => @monitoria_id) +
  52. +
    + +
    +
  53. + + + + + + end +
  54. +
    + +
    +
  55. + + + + + + +
  56. +
    + +
    +
  57. + + + + + + # GET /tarefas/1/edit +
  58. +
    + +
    +
  59. + 1 + + + + + def edit +
  60. +
    + +
    +
  61. + + + + + + end +
  62. +
    + +
    +
  63. + + + + + + +
  64. +
    + +
    +
  65. + + + + + + # POST /tarefas +
  66. +
    + +
    +
  67. + + + + + + # POST /tarefas.json +
  68. +
    + +
    +
  69. + 1 + + + + + def create +
  70. +
    + +
    +
  71. + + + + + + @tarefa = Tarefa.new(tarefa_params) +
  72. +
    + +
    +
  73. + + + + + + if @tarefa.save +
  74. +
    + +
    +
  75. + + + + + + redirect_to dashboard_monitorias_path, notice: "Tarefa atribuida com sucesso!" +
  76. +
    + +
    +
  77. + + + + + + else +
  78. +
    + +
    +
  79. + + + + + + flash[:danger] = "Ocorreu um erro ao atribuir a tarefa." +
  80. +
    + +
    +
  81. + + + + + + redirect_to dashboard_monitorias_path +
  82. +
    + +
    +
  83. + + + + + + end +
  84. +
    + +
    +
  85. + + + + + + +
  86. +
    + +
    +
  87. + + + + + + +
  88. +
    + +
    +
  89. + + + + + + end +
  90. +
    + +
    +
  91. + + + + + + +
  92. +
    + +
    +
  93. + + + + + + # PATCH/PUT /tarefas/1 +
  94. +
    + +
    +
  95. + + + + + + # PATCH/PUT /tarefas/1.json +
  96. +
    + +
    +
  97. + 1 + + + + + def update +
  98. +
    + +
    +
  99. + + + + + + if @tarefa.update(tarefa_params) +
  100. +
    + +
    +
  101. + + + + + + redirect_to dashboard_monitorias_path, notice: "Tarefa atualizada!" +
  102. +
    + +
    +
  103. + + + + + + else +
  104. +
    + +
    +
  105. + + + + + + flash[:danger] = "Ocorreu um erro ao atualizar a tarefa." +
  106. +
    + +
    +
  107. + + + + + + redirect_to dashboard_monitorias_path +
  108. +
    + +
    +
  109. + + + + + + end +
  110. +
    + +
    +
  111. + + + + + + end +
  112. +
    + +
    +
  113. + + + + + + +
  114. +
    + +
    +
  115. + + + + + + # DELETE /tarefas/1 +
  116. +
    + +
    +
  117. + + + + + + # DELETE /tarefas/1.json +
  118. +
    + +
    +
  119. + 1 + + + + + def destroy +
  120. +
    + +
    +
  121. + + + + + + @tarefa.destroy +
  122. +
    + +
    +
  123. + + + + + + redirect_to dashboard_monitorias_path, notice: "Tarefa removida!" +
  124. +
    + +
    +
  125. + + + + + + end +
  126. +
    + +
    +
  127. + + + + + + +
  128. +
    + +
    +
  129. + 1 + + + + + private +
  130. +
    + +
    +
  131. + + + + + + # Use callbacks to share common setup or constraints between actions. +
  132. +
    + +
    +
  133. + 1 + + + + + def set_tarefa +
  134. +
    + +
    +
  135. + + + + + + @tarefa = Tarefa.find(params[:id]) +
  136. +
    + +
    +
  137. + + + + + + end +
  138. +
    + +
    +
  139. + + + + + + +
  140. +
    + +
    +
  141. + + + + + + # Never trust parameters from the scary internet, only allow the white list through. +
  142. +
    + +
    +
  143. + 1 + + + + + def tarefa_params +
  144. +
    + +
    +
  145. + + + + + + params.require(:tarefa).permit(:titulo, :descricao, :nota, :feito, :inicio, :fim, :monitoria_id) +
  146. +
    + +
    +
  147. + + + + + + end +
  148. +
    + +
    +
  149. + + + + + + end +
  150. +
    + +
+
+
+ + +
+
+

app/controllers/turmas_controller.rb

+

+ + 78.38% + + + lines covered +

+ + + +
+ 37 relevant lines. + 29 lines covered and + 8 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class TurmasController < ApplicationController +
  2. +
    + +
    +
  3. + + + + + + # GET #new +
  4. +
    + +
    +
  5. + 1 + + + + + def new +
  6. +
    + +
    +
  7. + 1 + + + + + @user = current_user +
  8. +
    + +
    +
  9. + + + + + + end +
  10. +
    + +
    +
  11. + + + + + + +
  12. +
    + +
    +
  13. + 1 + + + + + def edit +
  14. +
    + +
    +
  15. + 1 + + + + + @turma = Turma.find(params[:id]) +
  16. +
    + +
    +
  17. + + + + + + end +
  18. +
    + +
    +
  19. + + + + + + +
  20. +
    + +
    +
  21. + 1 + + + + + def create +
  22. +
    + +
    +
  23. + 4 + + + + + @turma = Turma.create(turma_params) +
  24. +
    + +
    +
  25. + + + + + + +
  26. +
    + +
    +
  27. + 4 + + + + + if !@turma.errors.any? +
  28. +
    + +
    +
  29. + 3 + + + + + flash[:notice] = 'Turma cadastrada com sucesso!' +
  30. +
    + +
    +
  31. + + + + + + else +
  32. +
    + +
    +
  33. + 1 + + + + + flash[:danger] = @turma.errors.full_messages +
  34. +
    + +
    +
  35. + + + + + + end +
  36. +
    + +
    +
  37. + + + + + + +
  38. +
    + +
    +
  39. + 4 + + + + + redirect_to dashboard_turmas_path +
  40. +
    + +
    +
  41. + + + + + + end +
  42. +
    + +
    +
  43. + + + + + + +
  44. +
    + +
    +
  45. + 1 + + + + + def update +
  46. +
    + +
    +
  47. + 5 + + + + + @turma = Turma.find(params[:id]) +
  48. +
    + +
    +
  49. + 5 + + + + + @turma.update_attributes(turma_params) +
  50. +
    + +
    +
  51. + + + + + + +
  52. +
    + +
    +
  53. + 5 + + + + + if !@turma.errors.any? +
  54. +
    + +
    +
  55. + 4 + + + + + flash[:notice] = 'Turma atualizada com sucesso!' +
  56. +
    + +
    +
  57. + + + + + + else +
  58. +
    + +
    +
  59. + 1 + + + + + flash[:danger] = @turma.errors.full_messages +
  60. +
    + +
    +
  61. + + + + + + end +
  62. +
    + +
    +
  63. + + + + + + +
  64. +
    + +
    +
  65. + 5 + + + + + redirect_to dashboard_turmas_path +
  66. +
    + +
    +
  67. + + + + + + end +
  68. +
    + +
    +
  69. + + + + + + +
  70. +
    + +
    +
  71. + 1 + + + + + def destroy +
  72. +
    + +
    +
  73. + 1 + + + + + @turma = Turma.find(params[:id]) +
  74. +
    + +
    +
  75. + 1 + + + + + Monitoria.find_each do |m| +
  76. +
    + +
    +
  77. + + + + + + if m.fk_turmas_id == @turma.id +
  78. +
    + +
    +
  79. + + + + + + m.destroy +
  80. +
    + +
    +
  81. + + + + + + end +
  82. +
    + +
    +
  83. + + + + + + end +
  84. +
    + +
    +
  85. + 1 + + + + + @turma.destroy +
  86. +
    + +
    +
  87. + 1 + + + + + flash[:notice] = 'Turma apagada com sucesso!' +
  88. +
    + +
    +
  89. + 1 + + + + + redirect_to dashboard_turmas_path +
  90. +
    + +
    +
  91. + + + + + + end +
  92. +
    + +
    +
  93. + + + + + + +
  94. +
    + +
    +
  95. + 1 + + + + + private +
  96. +
    + +
    +
  97. + 1 + + + + + def turma_params +
  98. +
    + +
    +
  99. + 6 + + + + + params.require(:turma).permit(:id, :turma, :professor, :fk_cod_disciplina, :qnt_bolsas, :fk_vagas_id) +
  100. +
    + +
    +
  101. + + + + + + end +
  102. +
    + +
    +
  103. + + + + + + +
  104. +
    + +
    +
  105. + 1 + + + + + def find_turma +
  106. +
    + +
    +
  107. + + + + + + @turma = Turma.find(params[:id]) +
  108. +
    + +
    +
  109. + + + + + + end +
  110. +
    + +
    +
  111. + + + + + + +
  112. +
    + +
    +
  113. + 1 + + + + + def self.get_turmas(professor) +
  114. +
    + +
    +
  115. + + + + + + @turmas = Array.new +
  116. +
    + +
    +
  117. + + + + + + @turmas_buscadas = Turma.find_each do |turma| +
  118. +
    + +
    +
  119. + + + + + + if turma.professor == professor.name +
  120. +
    + +
    +
  121. + + + + + + @turmas << turma +
  122. +
    + +
    +
  123. + + + + + + end +
  124. +
    + +
    +
  125. + + + + + + end +
  126. +
    + +
    +
  127. + + + + + + @turmas +
  128. +
    + +
    +
  129. + + + + + + end +
  130. +
    + +
    +
  131. + + + + + + end +
  132. +
    + +
+
+
+ + +
+
+

app/controllers/users_controller.rb

+

+ + 85.0% + + + lines covered +

+ + + +
+ 20 relevant lines. + 17 lines covered and + 3 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class UsersController < ApplicationController +
  2. +
    + +
    +
  3. + + + + + + ## GET /users/new +
  4. +
    + +
    +
  5. + 1 + + + + + def new ; end +
  6. +
    + +
    +
  7. + + + + + + +
  8. +
    + +
    +
  9. + + + + + + ## POST /users/sign_up +
  10. +
    + +
    +
  11. + 1 + + + + + def create +
  12. +
    + +
    +
  13. + 6 + + + + + @user = User.create(user_params) +
  14. +
    + +
    +
  15. + + + + + + +
  16. +
    + +
    +
  17. + 6 + + + + + if !@user.errors.any? +
  18. +
    + +
    +
  19. + + + + + + log_in(@user) +
  20. +
    + +
    +
  21. + + + + + + flash[:notice] = "Registro realizado com sucesso!" +
  22. +
    + +
    +
  23. + + + + + + redirect_to dashboard_path +
  24. +
    + +
    +
  25. + + + + + + else +
  26. +
    + +
    +
  27. + 6 + + + + + flash[:danger] = @user.errors.full_messages +
  28. +
    + +
    +
  29. + 6 + + + + + redirect_to new_user_path +
  30. +
    + +
    +
  31. + + + + + + end +
  32. +
    + +
    +
  33. + + + + + + end +
  34. +
    + +
    +
  35. + + + + + + +
  36. +
    + +
    +
  37. + 1 + + + + + def update +
  38. +
    + +
    +
  39. + 6 + + + + + @user = User.find_by_email(session[:user_id]) +
  40. +
    + +
    +
  41. + 6 + + + + + @user.update_attributes(user_params) +
  42. +
    + +
    +
  43. + + + + + + +
  44. +
    + +
    +
  45. + 6 + + + + + if !@user.errors.any? +
  46. +
    + +
    +
  47. + 4 + + + + + flash[:notice] = "Cadastro atualizado com sucesso!" +
  48. +
    + +
    +
  49. + + + + + + elsif +
  50. +
    + +
    +
  51. + 2 + + + + + flash[:danger] = @user.errors.full_messages +
  52. +
    + +
    +
  53. + + + + + + end +
  54. +
    + +
    +
  55. + + + + + + +
  56. +
    + +
    +
  57. + 6 + + + + + redirect_to dashboard_path +
  58. +
    + +
    +
  59. + + + + + + end +
  60. +
    + +
    +
  61. + + + + + + +
  62. +
    + +
    +
  63. + 1 + + + + + private +
  64. +
    + +
    +
  65. + 1 + + + + + def user_params +
  66. +
    + +
    +
  67. + 12 + + + + + params.require(:user).permit(:id, :name, :matricula, :email, :cpf, :rg, :password, :password_confirmation) +
  68. +
    + +
    +
  69. + + + + + + end +
  70. +
    + +
    +
  71. + + + + + + end +
  72. +
    + +
+
+
+ + +
+
+

app/helpers/application_helper.rb

+

+ + 100.0% + + + lines covered +

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

app/helpers/atendimentos_helper.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module AtendimentosHelper +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/helpers/atividades_helper.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module AtividadesHelper +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/helpers/disciplinas_helper.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module DisciplinasHelper +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/helpers/historico_helper.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module HistoricoHelper +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/helpers/home_helper.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module HomeHelper +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/helpers/motivos_helper.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module MotivosHelper +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/helpers/reset_senhas_helper.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module ResetSenhasHelper +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/helpers/sessions_helper.rb

+

+ + 90.0% + + + lines covered +

+ + + +
+ 10 relevant lines. + 9 lines covered and + 1 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module SessionsHelper +
  2. +
    + +
    +
  3. + 1 + + + + + def log_in(user) +
  4. +
    + +
    +
  5. + 3 + + + + + session[:user_id] = user.email +
  6. +
    + +
    +
  7. + + + + + + end +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + 1 + + + + + def logged_user +
  12. +
    + +
    +
  13. + 3 + + + + + if !current_user.nil? +
  14. +
    + +
    +
  15. + + + + + + current_user +
  16. +
    + +
    +
  17. + + + + + + end +
  18. +
    + +
    +
  19. + + + + + + end +
  20. +
    + +
    +
  21. + + + + + + +
  22. +
    + +
    +
  23. + 1 + + + + + def current_user +
  24. +
    + +
    +
  25. + + + + + + ## Determina se o usuário logado é um aluno ou professor +
  26. +
    + +
    +
  27. + 12 + + + + + @current_user ||= User.find_by(email: session[:user_id]) || Professor.find_by(email: session[:user_id]) || Admin.find_by(email: session[:user_id]) +
  28. +
    + +
    +
  29. + + + + + + end +
  30. +
    + +
    +
  31. + + + + + + +
  32. +
    + +
    +
  33. + 1 + + + + + def logged_in? +
  34. +
    + +
    +
  35. + 3 + + + + + !logged_user.nil? +
  36. +
    + +
    +
  37. + + + + + + end +
  38. +
    + +
    +
  39. + + + + + + end +
  40. +
    + +
+
+
+ + +
+
+

app/helpers/tarefas_helper.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 1 relevant lines. + 1 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + module TarefasHelper +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/jobs/application_job.rb

+

+ + 0.0% + + + lines covered +

+ + + +
+ 2 relevant lines. + 0 lines covered and + 2 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + + + + + + class ApplicationJob < ActiveJob::Base +
  2. +
    + +
    +
  3. + + + + + + end +
  4. +
    + +
+
+
+ + +
+
+

app/mailers/application_mailer.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 3 relevant lines. + 3 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class ApplicationMailer < ActionMailer::Base +
  2. +
    + +
    +
  3. + 1 + + + + + default from: 'noreply@example.com' # TODO: mudar esse campo após definir o domínio utilizado pela plataforma +
  4. +
    + +
    +
  5. + 1 + + + + + layout 'mailer' +
  6. +
    + +
    +
  7. + + + + + + end +
  8. +
    + +
+
+
+ + +
+
+

app/mailers/professor_mailer.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 6 relevant lines. + 6 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class ProfessorMailer < ApplicationMailer +
  2. +
    + +
    +
  3. + 1 + + + + + default from: 'notifications@example.com' +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + + + + + + # as configuracoes de envio de email de confirmacao para professores eh feita aqui +
  8. +
    + +
    +
  9. + 1 + + + + + def key_email +
  10. +
    + +
    +
  11. + 2 + + + + + @professor = params[:professor] +
  12. +
    + +
    +
  13. + 2 + + + + + @url = 'http://localhost:3000/sessions/new' +
  14. +
    + +
    +
  15. + 2 + + + + + mail(to: @professor.email, subject: 'Saudações querido(a) professor(a)!') +
  16. +
    + +
    +
  17. + + + + + + end +
  18. +
    + +
    +
  19. + + + + + + end +
  20. +
    + +
+
+
+ + +
+
+

app/mailers/user_mailer.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 4 relevant lines. + 4 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class UserMailer < ApplicationMailer +
  2. +
    + +
    +
  3. + + + + + + +
  4. +
    + +
    +
  5. + + + + + + # Subject can be set in your I18n file at config/locales/en.yml +
  6. +
    + +
    +
  7. + + + + + + # with the following lookup: +
  8. +
    + +
    +
  9. + + + + + + # +
  10. +
    + +
    +
  11. + + + + + + # en.user_mailer.reset_senha.subject +
  12. +
    + +
    +
  13. + + + + + + # +
  14. +
    + +
    +
  15. + 1 + + + + + def reset_senha(user) +
  16. +
    + +
    +
  17. + 2 + + + + + @user = user +
  18. +
    + +
    +
  19. + 2 + + + + + mail to: user.email, subject: "Recuperação de senha" +
  20. +
    + +
    +
  21. + + + + + + end +
  22. +
    + +
    +
  23. + + + + + + end +
  24. +
    + +
+
+
+ + +
+
+

app/models/admin.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 3 relevant lines. + 3 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Admin < ActiveRecord::Base +
  2. +
    + +
    +
  3. + 1 + + + + + has_secure_password +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + 1 + + + + + self.primary_key = :id +
  8. +
    + +
    +
  9. + + + + + + end +
  10. +
    + +
+
+
+ + +
+
+

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. +
    + +
    +
  3. + 1 + + + + + self.abstract_class = true +
  4. +
    + +
    +
  5. + + + + + + end +
  6. +
    + +
+
+
+ + +
+
+

app/models/atendimento.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 5 relevant lines. + 5 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Atendimento < ApplicationRecord +
  2. +
    + +
    +
  3. + + + + + + ## +
  4. +
    + +
    +
  5. + + + + + + # Cada atendimento está associado à um monitor +
  6. +
    + +
    +
  7. + 1 + + + + + belongs_to :motivo +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + + + + + + ## +
  12. +
    + +
    +
  13. + + + + + + # atendimento possui os campos obrigatórios monitor_id, motivo_id e dia +
  14. +
    + +
    +
  15. + 1 + + + + + validates_presence_of :monitor_id +
  16. +
    + +
    +
  17. + 1 + + + + + validates_presence_of :motivo_id +
  18. +
    + +
    +
  19. + 1 + + + + + validates_presence_of :dia +
  20. +
    + +
    +
  21. + + + + + + +
  22. +
    + +
    +
  23. + + + + + + end +
  24. +
    + +
+
+
+ + +
+
+

app/models/atividade.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 5 relevant lines. + 5 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Atividade < ApplicationRecord +
  2. +
    + +
    +
  3. + + + + + + +
  4. +
    + +
    +
  5. + + + + + + ## Verifica se o formulário foi preenchido de acordo com a especificação +
  6. +
    + +
    +
  7. + 1 + + + + + validates_presence_of :titulo, message: "Campo obrigatório 'Título' não preenchido! Registro não realizado." +
  8. +
    + +
    +
  9. + 1 + + + + + validates_presence_of :mensagem, message: "Campo obrigatório 'Descrição' não preenchido! Registro não realizado." +
  10. +
    + +
    +
  11. + 1 + + + + + validates_presence_of :data, message: "Campo obrigatório 'Data' não preenchido! Registro não realizado." +
  12. +
    + +
    +
  13. + 1 + + + + + validates_presence_of :matricula_monitor, message: "Campo obrigatório 'Matrícula' não preenchido! Registro não realizado." +
  14. +
    + +
    +
  15. + + + + + + end +
  16. +
    + +
+
+
+ + +
+
+

app/models/dados_bancarios.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 8 relevant lines. + 8 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class DadosBancarios < ActiveRecord::Base +
  2. +
    + +
    +
  3. + 1 + + + + + self.primary_key = :id +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + 1 + + + + + validates_presence_of :codigo +
  8. +
    + +
    +
  9. + 1 + + + + + validates_presence_of :agencia +
  10. +
    + +
    +
  11. + 1 + + + + + validates_presence_of :conta_corrente +
  12. +
    + +
    +
  13. + + + + + + +
  14. +
    + +
    +
  15. + 1 + + + + + validates :codigo, length: { in: 6..25 }, format: { +
  16. +
    + +
    +
  17. + + + + + + without: /[\d]+|['"!¹@²#³$£%¢¨¬&\*\(\)\-_\+=§`´\[\]{}\^~ªº°\?\/:;>.<,\|\\]+/, +
  18. +
    + +
    +
  19. + + + + + + message: 'only letters and spaces' +
  20. +
    + +
    +
  21. + + + + + + } +
  22. +
    + +
    +
  23. + + + + + + +
  24. +
    + +
    +
  25. + 1 + + + + + validates :agencia, format: { with: /\A[\d]+\z/, message: "only numbers" } +
  26. +
    + +
    +
  27. + 1 + + + + + validates :conta_corrente, format: { with: /\A[\d]+\z/, message: "only numbers" } +
  28. +
    + +
    +
  29. + + + + + + end +
  30. +
    + +
+
+
+ + +
+
+

app/models/disciplina.rb

+

+ + 88.89% + + + lines covered +

+ + + +
+ 18 relevant lines. + 16 lines covered and + 2 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Disciplina < ApplicationRecord +
  2. +
    + +
    +
  3. + 1 + + + + + def self.all_tipos +
  4. +
    + +
    +
  5. + 1 + + + + + return [['Obrigatória', 1], ['Optativa', 2]] +
  6. +
    + +
    +
  7. + + + + + + end +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + 1 + + + + + def self.all_disciplinas +
  12. +
    + +
    +
  13. + + + + + + order(:nome).all +
  14. +
    + +
    +
  15. + + + + + + end +
  16. +
    + +
    +
  17. + + + + + + +
  18. +
    + +
    +
  19. + 1 + + + + + def self.com_monitoria +
  20. +
    + +
    +
  21. + + + + + + return where(monitoria: true) +
  22. +
    + +
    +
  23. + + + + + + end +
  24. +
    + +
    +
  25. + + + + + + +
  26. +
    + +
    +
  27. + 1 + + + + + validates_presence_of :nome +
  28. +
    + +
    +
  29. + 1 + + + + + validates_presence_of :fk_tipo_disciplina_id +
  30. +
    + +
    +
  31. + 1 + + + + + validates_presence_of :c_prat +
  32. +
    + +
    +
  33. + 1 + + + + + validates_presence_of :c_teor +
  34. +
    + +
    +
  35. + 1 + + + + + validates_presence_of :c_est +
  36. +
    + +
    +
  37. + 1 + + + + + validates_presence_of :c_ext +
  38. +
    + +
    +
  39. + + + + + + +
  40. +
    + +
    +
  41. + + + + + + +
  42. +
    + +
    +
  43. + 1 + + + + + validates :nome, format: { without: /[\d]+|['"!¹@²#³$£%¢¨¬&\*\(\)\-_\+=§`´\[\]{}\^~ªº°\?\/:;>.<,\|\\]+/, message: 'apenas letras e espaços'} +
  44. +
    + +
    +
  45. + 1 + + + + + validates :c_prat, format: { with: /\A[\d]+\z/, message: "apenas numeros" } +
  46. +
    + +
    +
  47. + 1 + + + + + validates :c_teor, format: { with: /\A[\d]+\z/, message: "apenas numeros" } +
  48. +
    + +
    +
  49. + 1 + + + + + validates :c_est, format: { with: /\A[\d]+\z/, message: "apenas numeros" } +
  50. +
    + +
    +
  51. + 1 + + + + + validates :c_ext, format: { with: /\A[\d]+\z/, message: "apenas numeros" } +
  52. +
    + +
    +
  53. + + + + + + +
  54. +
    + +
    +
  55. + + + + + + end +
  56. +
    + +
+
+
+ + +
+
+

app/models/monitoria.rb

+

+ + 69.23% + + + lines covered +

+ + + +
+ 13 relevant lines. + 9 lines covered and + 4 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Monitoria < ApplicationRecord +
  2. +
    + +
    +
  3. + + + + + + +
  4. +
    + +
    +
  5. + 1 + + + + + def self.all_disciplinas +
  6. +
    + +
    +
  7. + + + + + + @disciplinas = Array.new +
  8. +
    + +
    +
  9. + + + + + + Disciplina.find_each do |d| +
  10. +
    + +
    +
  11. + + + + + + @disciplinas << [d.nome, d.cod_disciplina] +
  12. +
    + +
    +
  13. + + + + + + end +
  14. +
    + +
    +
  15. + + + + + + @disciplinas +
  16. +
    + +
    +
  17. + + + + + + end +
  18. +
    + +
    +
  19. + + + + + + +
  20. +
    + +
    +
  21. + + + + + + # def self.all_turmas +
  22. +
    + +
    +
  23. + + + + + + # @turmas = Array.new +
  24. +
    + +
    +
  25. + + + + + + # Turma.find_each do |t| +
  26. +
    + +
    +
  27. + + + + + + # @turmas << [t.turma, t.id] +
  28. +
    + +
    +
  29. + + + + + + # end +
  30. +
    + +
    +
  31. + + + + + + # @turmas +
  32. +
    + +
    +
  33. + + + + + + # end +
  34. +
    + +
    +
  35. + + + + + + +
  36. +
    + +
    +
  37. + 1 + + + + + def self.all_status +
  38. +
    + +
    +
  39. + 1 + + + + + return [['Pendente', 1], ['Recusado', 2], ['Aceito', 3], ['Encerrado', 4]] +
  40. +
    + +
    +
  41. + + + + + + end +
  42. +
    + +
    +
  43. + 1 + + + + + validates_presence_of :remuneracao +
  44. +
    + +
    +
  45. + 1 + + + + + validates_presence_of :fk_matricula +
  46. +
    + +
    +
  47. + 1 + + + + + validates_presence_of :fk_cod_disciplina +
  48. +
    + +
    +
  49. + 1 + + + + + validates_presence_of :fk_turmas_id +
  50. +
    + +
    +
  51. + 1 + + + + + validates_presence_of :fk_status_monitoria_id +
  52. +
    + +
    +
  53. + + + + + + +
  54. +
    + +
    +
  55. + + + + + + +
  56. +
    + +
    +
  57. + + + + + + end +
  58. +
    + +
+
+
+ + +
+
+

app/models/motivo.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 2 relevant lines. + 2 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Motivo < ApplicationRecord +
  2. +
    + +
    +
  3. + + + + + + #belongs_to:organization,:class_name=>'User',:foreign_key=>'user_id' +
  4. +
    + +
    +
  5. + 1 + + + + + CLASS_LIST=["Duvida","Pergunta","Falar com o coordenador"] +
  6. +
    + +
    +
  7. + + + + + + end +
  8. +
    + +
+
+
+ + +
+
+

app/models/professor.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 16 relevant lines. + 16 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Professor < ActiveRecord::Base +
  2. +
    + +
    +
  3. + 1 + + + + + has_secure_password +
  4. +
    + +
    +
  5. + + + + + + +
  6. +
    + +
    +
  7. + 1 + + + + + self.primary_key = :id +
  8. +
    + +
    +
  9. + + + + + + +
  10. +
    + +
    +
  11. + 1 + + + + + def self.all_roles +
  12. +
    + +
    +
  13. + 1 + + + + + return [['Professor(a) substituto(a)', 1], ['Professor(a)', 2], ['Professor(a) Colaborador(a)', 3], +
  14. +
    + +
    +
  15. + + + + + + ['Professor(a) Adjunto(a)', 4], ['Professor(a) Associado(a)', 5], ['Professor(a) Titular', 6]] +
  16. +
    + +
    +
  17. + + + + + + end +
  18. +
    + +
    +
  19. + + + + + + +
  20. +
    + +
    +
  21. + 1 + + + + + validates_presence_of :name +
  22. +
    + +
    +
  23. + 1 + + + + + validates_presence_of :username +
  24. +
    + +
    +
  25. + 1 + + + + + validates_presence_of :email +
  26. +
    + +
    +
  27. + + + + + + +
  28. +
    + +
    +
  29. + 1 + + + + + validates_uniqueness_of :username +
  30. +
    + +
    +
  31. + 1 + + + + + validates_uniqueness_of :email +
  32. +
    + +
    +
  33. + + + + + + +
  34. +
    + +
    +
  35. + + + + + + # Verificação do nome +
  36. +
    + +
    +
  37. + 1 + + + + + validates :name, length: { in: 3..50 }, format: { without: /[\d]+|[!@#$%*\(\)\|\\;\:\/?\]\[=\+\-_",\.]+/, +
  38. +
    + +
    +
  39. + + + + + + message: "only letters and spaces" } +
  40. +
    + +
    +
  41. + + + + + + # Verificação do username +
  42. +
    + +
    +
  43. + 1 + + + + + validates :username, length: { in: 3..15 }, format: { +
  44. +
    + +
    +
  45. + + + + + + with: /\A[\w+]+\z/, message: "only word characters (letter, numbers, underscore...)" } +
  46. +
    + +
    +
  47. + + + + + + +
  48. +
    + +
    +
  49. + + + + + + # Verificação do email +
  50. +
    + +
    +
  51. + 1 + + + + + VALID_EMAIL_REGEX = /\A[\w+\-.]+@unb\.br\z/i +
  52. +
    + +
    +
  53. + 1 + + + + + validates :email, format: { with: VALID_EMAIL_REGEX, message: "not a UnB email" } +
  54. +
    + +
    +
  55. + + + + + + +
  56. +
    + +
    +
  57. + + + + + + # Verificação da senha e confirmação de senha +
  58. +
    + +
    +
  59. + 1 + + + + + validates :password, length: { in: 6..12, message: "must be between 6 and 12 characters" }, on: :create +
  60. +
    + +
    +
  61. + 1 + + + + + validates :password_confirmation, length: { in: 6..12, message: "must be between 6 and 12 characters" }, on: :create +
  62. +
    + +
    +
  63. + + + + + + end +
  64. +
    + +
+
+
+ + +
+
+

app/models/tarefa.rb

+

+ + 100.0% + + + lines covered +

+ + + +
+ 2 relevant lines. + 2 lines covered and + 0 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Tarefa < ApplicationRecord +
  2. +
    + +
    +
  3. + 1 + + + + + belongs_to :monitoria +
  4. +
    + +
    +
  5. + + + + + + end +
  6. +
    + +
+
+
+ + +
+
+

app/models/turma.rb

+

+ + 63.16% + + + lines covered +

+ + + +
+ 38 relevant lines. + 24 lines covered and + 14 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class Turma < ActiveRecord::Base +
  2. +
    + +
    +
  3. + 1 + + + + + def self.qnt_bolsas +
  4. +
    + +
    +
  5. + 1 + + + + + @qnt_bolsas = [] +
  6. +
    + +
    +
  7. + + + + + + +
  8. +
    + +
    +
  9. + 1 + + + + + for i in 1..10 +
  10. +
    + +
    +
  11. + 10 + + + + + @vaga = [] +
  12. +
    + +
    +
  13. + 10 + + + + + @vaga = [i.to_s, i] +
  14. +
    + +
    +
  15. + 10 + + + + + @qnt_bolsas.insert(-1, @vaga) +
  16. +
    + +
    +
  17. + + + + + + end +
  18. +
    + +
    +
  19. + + + + + + +
  20. +
    + +
    +
  21. + 1 + + + + + return @qnt_bolsas +
  22. +
    + +
    +
  23. + + + + + + end +
  24. +
    + +
    +
  25. + + + + + + +
  26. +
    + +
    +
  27. + 1 + + + + + def self.sel_disciplinas +
  28. +
    + +
    +
  29. + + + + + + @disciplinas = Disciplina.select('cod_disciplina', 'nome') +
  30. +
    + +
    +
  31. + + + + + + +
  32. +
    + +
    +
  33. + + + + + + @select = [] +
  34. +
    + +
    +
  35. + + + + + + @disciplinas.each do |disciplina| +
  36. +
    + +
    +
  37. + + + + + + @atual = [] +
  38. +
    + +
    +
  39. + + + + + + @atual = [disciplina.nome, disciplina.cod_disciplina] +
  40. +
    + +
    +
  41. + + + + + + @select.insert(-1, @atual) +
  42. +
    + +
    +
  43. + + + + + + end +
  44. +
    + +
    +
  45. + + + + + + +
  46. +
    + +
    +
  47. + + + + + + return @select +
  48. +
    + +
    +
  49. + + + + + + end +
  50. +
    + +
    +
  51. + + + + + + +
  52. +
    + +
    +
  53. + 1 + + + + + def self.show_disciplinas +
  54. +
    + +
    +
  55. + + + + + + @disciplinas = Disciplina.select('nome') +
  56. +
    + +
    +
  57. + + + + + + @show = [] +
  58. +
    + +
    +
  59. + + + + + + +
  60. +
    + +
    +
  61. + + + + + + @disciplinas.each do |disciplina| +
  62. +
    + +
    +
  63. + + + + + + @atual = String.new +
  64. +
    + +
    +
  65. + + + + + + @atual = disciplina.nome +
  66. +
    + +
    +
  67. + + + + + + @show.insert(-1, @atual) +
  68. +
    + +
    +
  69. + + + + + + end +
  70. +
    + +
    +
  71. + + + + + + +
  72. +
    + +
    +
  73. + + + + + + return @show +
  74. +
    + +
    +
  75. + + + + + + end +
  76. +
    + +
    +
  77. + + + + + + +
  78. +
    + +
    +
  79. + 1 + + + + + def self.sel_turmas +
  80. +
    + +
    +
  81. + + + + + + [ +
  82. +
    + +
    +
  83. + 1 + + + + + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', +
  84. +
    + +
    +
  85. + + + + + + 'AA', 'BB', 'CC', 'DD', 'EE', 'FF', 'GG', 'HH' +
  86. +
    + +
    +
  87. + + + + + + ] +
  88. +
    + +
    +
  89. + + + + + + end +
  90. +
    + +
    +
  91. + + + + + + +
  92. +
    + +
    +
  93. + 1 + + + + + def self.all_turmas +
  94. +
    + +
    +
  95. + 1 + + + + + find_each() +
  96. +
    + +
    +
  97. + + + + + + end +
  98. +
    + +
    +
  99. + + + + + + +
  100. +
    + +
    +
  101. + 1 + + + + + validates_presence_of :turma +
  102. +
    + +
    +
  103. + 1 + + + + + validates_presence_of :professor +
  104. +
    + +
    +
  105. + 1 + + + + + validates_presence_of :fk_cod_disciplina +
  106. +
    + +
    +
  107. + 1 + + + + + validates_presence_of :qnt_bolsas +
  108. +
    + +
    +
  109. + 1 + + + + + validate :turma_unica +
  110. +
    + +
    +
  111. + + + + + + +
  112. +
    + +
    +
  113. + 1 + + + + + def turma_unica +
  114. +
    + +
    +
  115. + 33 + + + + + @turmas = Turma.where(fk_cod_disciplina: fk_cod_disciplina) +
  116. +
    + +
    +
  117. + + + + + + +
  118. +
    + +
    +
  119. + 33 + + + + + @turmas.each do |t| +
  120. +
    + +
    +
  121. + 7 + + + + + if t.turma == turma +
  122. +
    + +
    +
  123. + 3 + + + + + errors.add(:turma, "#{turma} não é a única para a disciplina #{Disciplina.find(fk_cod_disciplina).nome}") +
  124. +
    + +
    +
  125. + + + + + + end +
  126. +
    + +
    +
  127. + + + + + + end +
  128. +
    + +
    +
  129. + + + + + + end +
  130. +
    + +
    +
  131. + + + + + + end +
  132. +
    + +
+
+
+ + +
+
+

app/models/user.rb

+

+ + 96.61% + + + lines covered +

+ + + +
+ 59 relevant lines. + 57 lines covered and + 2 lines missed. +
+ + + +
+ +
+    
    + +
    +
  1. + 1 + + + + + class User < ActiveRecord::Base +
  2. +
    + +
    +
  3. + 1 + + + + + attr_accessor :remember_token, :reset_token +
  4. +
    + +
    +
  5. + 1 + + + + + has_secure_password +
  6. +
    + +
    +
  7. + + + + + + +
  8. +
    + +
    +
  9. + 1 + + + + + self.primary_key = :id +
  10. +
    + +
    +
  11. + + + + + + +
  12. +
    + +
    +
  13. + + + + + + ## Verifica se o formulário foi preenchido de acordo com a especificação +
  14. +
    + +
    +
  15. + 1 + + + + + validates_presence_of :name +
  16. +
    + +
    +
  17. + 1 + + + + + validates_presence_of :email +
  18. +
    + +
    +
  19. + 1 + + + + + validates_presence_of :cpf +
  20. +
    + +
    +
  21. + 1 + + + + + validates_presence_of :rg +
  22. +
    + +
    +
  23. + 1 + + + + + validates_presence_of :matricula +
  24. +
    + +
    +
  25. + + + + + + +
  26. +
    + +
    +
  27. + + + + + + ## Verifica se as informações não se repetem no Banco de Dados +
  28. +
    + +
    +
  29. + 1 + + + + + validates_uniqueness_of :email +
  30. +
    + +
    +
  31. + 1 + + + + + validates_uniqueness_of :cpf +
  32. +
    + +
    +
  33. + 1 + + + + + validates_uniqueness_of :rg +
  34. +
    + +
    +
  35. + 1 + + + + + validates_uniqueness_of :matricula +
  36. +
    + +
    +
  37. + + + + + + +
  38. +
    + +
    +
  39. + + + + + + ## Verifica se os campos tem o tamanho correto +
  40. +
    + +
    +
  41. + + + + + + # Verificação do nome +
  42. +
    + +
    +
  43. + 1 + + + + + validates :name, length: { in: 3..50 }, format: { +
  44. +
    + +
    +
  45. + + + + + + without: /[\d]+|['"!¹@²#³$£%¢¨¬&\*\(\)\-_\+=§`´\[\]{}\^~ªº°\?\/:;>.<,\|\\]+/, +
  46. +
    + +
    +
  47. + + + + + + message: 'only letters and spaces' +
  48. +
    + +
    +
  49. + + + + + + } +
  50. +
    + +
    +
  51. + + + + + + # Verificação da matrícula +
  52. +
    + +
    +
  53. + 1 + + + + + validates :matricula, length: { is: 9 }, format: { with: /\A[\d]+\z/, message: "only numbers" } +
  54. +
    + +
    +
  55. + + + + + + # Verificação do email +
  56. +
    + +
    +
  57. + 1 + + + + + VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(?:\.[a-z\d\-]+)*\.[a-z]+\z/i +
  58. +
    + +
    +
  59. + 1 + + + + + validates :email, format: { with: VALID_EMAIL_REGEX, message: "invalid email format" } +
  60. +
    + +
    +
  61. + + + + + + # Verificação do CPF +
  62. +
    + +
    +
  63. + 1 + + + + + validates :cpf, length: { is: 11 }, format: { with: /\A[\d]+\z/, message: "only numbers" } +
  64. +
    + +
    +
  65. + 1 + + + + + validate :valid_cpf +
  66. +
    + +
    +
  67. + + + + + + # Verificação do RG +
  68. +
    + +
    +
  69. + 1 + + + + + validates :rg, length: { minimum: 7 }, format: { with: /\A[\d]+\z/, message: "only numbers" } +
  70. +
    + +
    +
  71. + + + + + + # Verificação da senha e confirmação de senha +
  72. +
    + +
    +
  73. + 1 + + + + + validates :password, length: { in: 6...12, message: "must be between 6 and 12 characters" }, on: :create +
  74. +
    + +
    +
  75. + 1 + + + + + validates :password_confirmation, length: { in: 6...12, message: "must be between 6 and 12 characters" }, on: :create +
  76. +
    + +
    +
  77. + + + + + + +
  78. +
    + +
    +
  79. + + + + + + # Cálculo de validação dp CPF +
  80. +
    + +
    +
  81. + 1 + + + + + def nth_validation_digit(cpf_array, digit) +
  82. +
    + +
    +
  83. + 230 + + + + + @somatorio = 0 +
  84. +
    + +
    +
  85. + 230 + + + + + @aux = 0 +
  86. +
    + +
    +
  87. + 230 + + + + + @peso = 12-digit +
  88. +
    + +
    +
  89. + + + + + + +
  90. +
    + +
    +
  91. + 230 + + + + + cpf_array.each do |value| +
  92. +
    + +
    +
  93. + 2106 + + + + + @somatorio += value*(@peso-(@aux)) +
  94. +
    + +
    +
  95. + + + + + + +
  96. +
    + +
    +
  97. + 2106 + + + + + @aux += 1 +
  98. +
    + +
    +
  99. + 2106 + + + + + break if @aux == (11-digit) +
  100. +
    + +
    +
  101. + + + + + + end +
  102. +
    + +
    +
  103. + 230 + + + + + @validation_digit = 11-(@somatorio%11) +
  104. +
    + +
    +
  105. + 230 + + + + + if @validation_digit > 9 +
  106. +
    + +
    +
  107. + 103 + + + + + @validation_digit = 0 +
  108. +
    + +
    +
  109. + + + + + + end +
  110. +
    + +
    +
  111. + + + + + + +
  112. +
    + +
    +
  113. + 230 + + + + + return @validation_digit +
  114. +
    + +
    +
  115. + + + + + + end +
  116. +
    + +
    +
  117. + + + + + + +
  118. +
    + +
    +
  119. + 1 + + + + + def valid_cpf +
  120. +
    + +
    +
  121. + 115 + + + + + @cpf_array = Array.new +
  122. +
    + +
    +
  123. + 115 + + + + + for x in 0...(cpf.length) +
  124. +
    + +
    +
  125. + 1228 + + + + + @cpf_array[x] = cpf[x].to_i +
  126. +
    + +
    +
  127. + + + + + + end +
  128. +
    + +
    +
  129. + + + + + + +
  130. +
    + +
    +
  131. + 115 + + + + + @first = nth_validation_digit(@cpf_array, 2) # Calcula o @first com base nos 9 digitos +
  132. +
    + +
    +
  133. + 115 + + + + + @second = nth_validation_digit(@cpf_array, 1) # Calcula o @second com base nos 9 digitos + 1o validação +
  134. +
    + +
    +
  135. + + + + + + +
  136. +
    + +
    +
  137. + 115 + + + + + if (cpf[9].to_i) != @first || (cpf[10].to_i) != @second +
  138. +
    + +
    +
  139. + 12 + + + + + errors.add(:cpf, "is invalid") +
  140. +
    + +
    +
  141. + + + + + + end +
  142. +
    + +
    +
  143. + + + + + + end +
  144. +
    + +
    +
  145. + + + + + + +
  146. +
    + +
    +
  147. + + + + + + # Retorna o digest de um hash de uma string passada para o método +
  148. +
    + +
    +
  149. + 1 + + + + + def User.digest(string) +
  150. +
    + +
    +
  151. + 1 + + + + + cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : +
  152. +
    + +
    +
  153. + + + + + + BCrypt::Engine.cost +
  154. +
    + +
    +
  155. + 1 + + + + + BCrypt::Password.create(string, cost: cost) +
  156. +
    + +
    +
  157. + + + + + + end +
  158. +
    + +
    +
  159. + + + + + + +
  160. +
    + +
    +
  161. + + + + + + # Retorna um token aleatório +
  162. +
    + +
    +
  163. + 1 + + + + + def User.new_token +
  164. +
    + +
    +
  165. + 13 + + + + + SecureRandom.urlsafe_base64 +
  166. +
    + +
    +
  167. + + + + + + end +
  168. +
    + +
    +
  169. + + + + + + +
  170. +
    + +
    +
  171. + + + + + + # Define os atributos para resetar a senha +
  172. +
    + +
    +
  173. + 1 + + + + + def create_reset_digest +
  174. +
    + +
    +
  175. + 1 + + + + + self.reset_token = User.new_token +
  176. +
    + +
    +
  177. + 1 + + + + + update_attribute(:reset_digest, User.digest(reset_token)) +
  178. +
    + +
    +
  179. + 1 + + + + + update_attribute(:reset_sent_at, Time.zone.now) +
  180. +
    + +
    +
  181. + + + + + + end +
  182. +
    + +
    +
  183. + + + + + + +
  184. +
    + +
    +
  185. + + + + + + # Envia o e-mail para resetar a senha +
  186. +
    + +
    +
  187. + 1 + + + + + def send_password_reset_email +
  188. +
    + +
    +
  189. + 1 + + + + + UserMailer.reset_senha(self).deliver_now +
  190. +
    + +
    +
  191. + + + + + + end +
  192. +
    + +
    +
  193. + + + + + + +
  194. +
    + +
    +
  195. + + + + + + # Retorna true se o parâmetro password reset expirou +
  196. +
    + +
    +
  197. + 1 + + + + + def password_reset_expired? +
  198. +
    + +
    +
  199. + + + + + + reset_sent_at < 2.hours.ago +
  200. +
    + +
    +
  201. + + + + + + end +
  202. +
    + +
    +
  203. + + + + + + +
  204. +
    + +
    +
  205. + + + + + + # Retorna true se o token passado é o mesmo que o digest armazenado no banco +
  206. +
    + +
    +
  207. + 1 + + + + + def authenticated?(attribute, token) +
  208. +
    + +
    +
  209. + 2 + + + + + digest = send("#{attribute}_digest") +
  210. +
    + +
    +
  211. + 2 + + + + + return false if digest.nil? +
  212. +
    + +
    +
  213. + + + + + + BCrypt::Password.new(digest).is_password?(token) +
  214. +
    + +
    +
  215. + + + + + + end +
  216. +
    + +
    +
  217. + + + + + + end +
  218. +
    + +
+
+
+ + +
+
+ + diff --git a/cyclomatic_disciplina.txt b/cyclomatic_disciplina.txt new file mode 100644 index 00000000..e0f04ea9 Binary files /dev/null and b/cyclomatic_disciplina.txt differ diff --git a/cyclomatic_result.txt b/cyclomatic_result.txt new file mode 100644 index 00000000..8f410d66 Binary files /dev/null and b/cyclomatic_result.txt differ diff --git a/db/migrate/20191121154635_add_monitor_to_atendimentos.rb b/db/migrate/20191121154635_add_monitor_to_atendimentos.rb index 190fa11f..2431b02f 100644 --- a/db/migrate/20191121154635_add_monitor_to_atendimentos.rb +++ b/db/migrate/20191121154635_add_monitor_to_atendimentos.rb @@ -1,5 +1,5 @@ class AddMonitorToAtendimentos < ActiveRecord::Migration[5.2] def change - add_reference :atendimentos, :monitor, foreign_key: true + add_reference :atendimentos, :monitor, foreign_key: {to_table: :users} end end diff --git a/db/migrate/20210505021717_add_monitoria_to_disciplinas.rb b/db/migrate/20210505021717_add_monitoria_to_disciplinas.rb new file mode 100644 index 00000000..d0d183fe --- /dev/null +++ b/db/migrate/20210505021717_add_monitoria_to_disciplinas.rb @@ -0,0 +1,5 @@ +class AddMonitoriaToDisciplinas < ActiveRecord::Migration[5.2] + def change + add_column :disciplinas, :monitoria, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index b3b197b1..5cce6952 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,9 +11,12 @@ # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_12_10_130811) do +ActiveRecord::Schema.define(version: 2021_05_05_021717) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + create_table "admins", force: :cascade do |t| t.string "name", null: false t.string "email", null: false @@ -25,13 +28,13 @@ end create_table "atendimentos", force: :cascade do |t| - t.integer "motivo_id" + t.bigint "motivo_id" t.date "dia" t.string "descricao" t.string "aluno_atendido" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "monitor_id" + t.bigint "monitor_id" t.index ["monitor_id"], name: "index_atendimentos_on_monitor_id" t.index ["motivo_id"], name: "index_atendimentos_on_motivo_id" end @@ -68,6 +71,7 @@ t.integer "c_est", default: 0, null: false t.integer "c_ext", default: 0, null: false t.integer "cod_disciplina", default: 0, null: false + t.boolean "monitoria", default: false t.index ["cod_disciplina"], name: "disciplinas_cod_disciplina_index" t.index ["fk_tipo_disciplina_id"], name: "fk_disciplinas_tipo_disciplina1_idx" end @@ -142,7 +146,7 @@ t.boolean "feito" t.datetime "inicio" t.datetime "fim" - t.integer "monitoria_id" + t.bigint "monitoria_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["monitoria_id"], name: "index_tarefas_on_monitoria_id" @@ -193,4 +197,7 @@ t.integer "c_restantes", default: 0, null: false end + add_foreign_key "atendimentos", "motivos" + add_foreign_key "atendimentos", "users", column: "monitor_id" + add_foreign_key "tarefas", "monitoria", column: "monitoria_id" end diff --git a/db/seeds.rb b/db/seeds.rb index 54463dc5..b80f2fcf 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -13,33 +13,37 @@ Disciplina.destroy_all ###################### -#Admin.create(id: 1, name: "Admin UnB", email: "secretaria@cic.unb.br", password: "123456", -# remember_token: nil, created_at: '2018-06-04 18:12:09.050792', updated_at: '2018-06-04 18:12:09.050792') +Admin.create(id: 1, name: "Admin UnB", email: "secretaria@cic.unb.br", password: "123456", + remember_token: nil, created_at: '2018-06-04 18:12:09.050792', updated_at: '2018-06-04 18:12:09.050792') -###################### -Disciplina.create([{id:1, nome: "APC", + +Disciplina.create([{nome: "APC", fk_tipo_disciplina_id: 1, c_prat: 2, c_teor: 4, - cod_disciplina: 1}]) + cod_disciplina: 1, monitoria: true}]) + -Disciplina.create([{id:2, nome: "ED", +Disciplina.create([{nome: "ED", + fk_tipo_disciplina_id: 1, c_prat: 2, c_teor: 2, cod_disciplina: 2}]) ###################### # User.create(id: 1, name: "Aluno1", email: "aluno1@gmail.com", password: "123456", -# cpf: "03638481182", rg: "2645178", matricula: "140080279") + # cpf: "03638481182", rg: "2645178", matricula: "140080279") + # User.create(id: 2, name: "Aluno2", email: "aluno2@gmail.com", password: "123456", # cpf: "03638481111", rg: "2645111", matricula: "140080211", # fk_banco: nil, remember_token: nil, created_at: '2018-06-04 19:02:24.831795', # updated_at: '2018-06-04 19:02:24.831795') -#Professor.create(id: 1, name: "Carla", email: "carla@unb.br", username: "carla", password: "123456", role: 1) +Professor.create!(id: 1, name: "Genaina", email: "genaina@unb.br", username: "genaina", password: "123456", password_confirmation: '123456', role: 1) +Professor.create!(id: 2, name: "Carla", email: "carla@unb.br", username: "carla", password: "123456", password_confirmation: '123456', role: 1) ###################### ###################### -# Turma.create([{id:1, turma: "A", professor: "Carla", fk_cod_disciplina: 1}]) +# Turma.create([{turma: "A", professor: "Carla", fk_cod_disciplina: 1}]) ###################### diff --git a/doc/3_1_7.html b/doc/3_1_7.html index 85d1e9d1..894b52fc 100644 --- a/doc/3_1_7.html +++ b/doc/3_1_7.html @@ -21,8 +21,6 @@ - -