diff --git a/Gemfile b/Gemfile index bb09f552..2559d07b 100644 --- a/Gemfile +++ b/Gemfile @@ -46,8 +46,9 @@ gem "will_paginate" # Pagina listados # lógico y no alfabetico como las gemas anteriores) gem "msip", # Motor generico - git: 'https://gitlab.com/pasosdeJesus/msip.git', branch: 'main' - #path: "../msip" + git: "https://gitlab.com/pasosdeJesus/msip.git", + branch: "main" +# path: "../msip" group :development do gem "puma" diff --git a/Gemfile.lock b/Gemfile.lock index 22b44f4f..41a7be34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT GIT remote: https://gitlab.com/pasosdeJesus/msip.git - revision: d2e9f711f4b4bf8b8a7f33a14d3045d8e0bd18fc + revision: 08d275ebea019da674b2b4e049bd4890784de702 branch: main specs: msip (2.3.0.alfa3) @@ -39,29 +39,29 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.2.2) - actionpack (= 7.2.2) - activesupport (= 7.2.2) + actioncable (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.2) - actionpack (= 7.2.2) - activejob (= 7.2.2) - activerecord (= 7.2.2) - activestorage (= 7.2.2) - activesupport (= 7.2.2) + actionmailbox (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) mail (>= 2.8.0) - actionmailer (7.2.2) - actionpack (= 7.2.2) - actionview (= 7.2.2) - activejob (= 7.2.2) - activesupport (= 7.2.2) + actionmailer (7.2.2.1) + actionpack (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activesupport (= 7.2.2.1) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.2) - actionview (= 7.2.2) - activesupport (= 7.2.2) + actionpack (7.2.2.1) + actionview (= 7.2.2.1) + activesupport (= 7.2.2.1) nokogiri (>= 1.8.5) racc rack (>= 2.2.4, < 3.2) @@ -70,35 +70,35 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (7.2.2) - actionpack (= 7.2.2) - activerecord (= 7.2.2) - activestorage (= 7.2.2) - activesupport (= 7.2.2) + actiontext (7.2.2.1) + actionpack (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.2) - activesupport (= 7.2.2) + actionview (7.2.2.1) + activesupport (= 7.2.2.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.2) - activesupport (= 7.2.2) + activejob (7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.3.6) - activemodel (7.2.2) - activesupport (= 7.2.2) - activerecord (7.2.2) - activemodel (= 7.2.2) - activesupport (= 7.2.2) + activemodel (7.2.2.1) + activesupport (= 7.2.2.1) + activerecord (7.2.2.1) + activemodel (= 7.2.2.1) + activesupport (= 7.2.2.1) timeout (>= 0.4.0) - activestorage (7.2.2) - actionpack (= 7.2.2) - activejob (= 7.2.2) - activerecord (= 7.2.2) - activesupport (= 7.2.2) + activestorage (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activesupport (= 7.2.2.1) marcel (~> 1.0) - activesupport (7.2.2) + activesupport (7.2.2.1) base64 benchmark (>= 0.3) bigdecimal @@ -114,7 +114,7 @@ GEM base64 (0.2.0) bcrypt (3.1.20) benchmark (0.4.0) - bigdecimal (3.1.8) + bigdecimal (3.1.9) bindex (0.8.1) bootsnap (1.18.4) msgpack (~> 1.2) @@ -148,37 +148,37 @@ GEM devise-i18n (1.12.1) devise (>= 4.9.0) docile (1.4.1) - dotenv (3.1.4) - dotenv-rails (3.1.4) - dotenv (= 3.1.4) + dotenv (3.1.7) + dotenv-rails (3.1.7) + dotenv (= 3.1.7) railties (>= 6.1) drb (2.2.1) - erubi (1.13.0) - ffi (1.17.0) - ffi (1.17.0-aarch64-linux-gnu) - ffi (1.17.0-aarch64-linux-musl) - ffi (1.17.0-arm-linux-gnu) - ffi (1.17.0-arm-linux-musl) - ffi (1.17.0-arm64-darwin) - ffi (1.17.0-x86-linux-gnu) - ffi (1.17.0-x86-linux-musl) - ffi (1.17.0-x86_64-darwin) - ffi (1.17.0-x86_64-linux-gnu) - ffi (1.17.0-x86_64-linux-musl) + erubi (1.13.1) + ffi (1.17.1) + ffi (1.17.1-aarch64-linux-gnu) + ffi (1.17.1-aarch64-linux-musl) + ffi (1.17.1-arm-linux-gnu) + ffi (1.17.1-arm-linux-musl) + ffi (1.17.1-arm64-darwin) + ffi (1.17.1-x86-linux-gnu) + ffi (1.17.1-x86-linux-musl) + ffi (1.17.1-x86_64-darwin) + ffi (1.17.1-x86_64-linux-gnu) + ffi (1.17.1-x86_64-linux-musl) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.6) concurrent-ruby (~> 1.0) io-console (0.8.0) - irb (1.14.1) + irb (1.14.3) rdoc (>= 4.0.0) reline (>= 0.4.2) jsbundling-rails (1.3.1) railties (>= 6.0.0) - json (2.9.0) + json (2.9.1) language_server-protocol (3.17.0.3) - logger (1.6.2) - loofah (2.23.1) + logger (1.6.4) + loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -195,7 +195,7 @@ GEM mini_portile2 (2.8.8) minitest (5.25.4) msgpack (1.7.5) - net-imap (0.5.1) + net-imap (0.5.5) date net-protocol net-pop (0.1.2) @@ -230,33 +230,34 @@ GEM ast (~> 2.4.1) racc pg (1.5.9) - psych (5.2.1) + psych (5.2.2) date stringio puma (6.5.0) nio4r (~> 2.0) racc (1.8.1) rack (3.1.8) - rack-session (2.0.0) + rack-session (2.1.0) + base64 (>= 0.1.0) rack (>= 3.0.0) - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) rackup (2.2.1) rack (>= 3) - rails (7.2.2) - actioncable (= 7.2.2) - actionmailbox (= 7.2.2) - actionmailer (= 7.2.2) - actionpack (= 7.2.2) - actiontext (= 7.2.2) - actionview (= 7.2.2) - activejob (= 7.2.2) - activemodel (= 7.2.2) - activerecord (= 7.2.2) - activestorage (= 7.2.2) - activesupport (= 7.2.2) + rails (7.2.2.1) + actioncable (= 7.2.2.1) + actionmailbox (= 7.2.2.1) + actionmailer (= 7.2.2.1) + actionpack (= 7.2.2.1) + actiontext (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activemodel (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) bundler (>= 1.15.0) - railties (= 7.2.2) + railties (= 7.2.2.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -270,15 +271,15 @@ GEM activesupport (>= 4.2) choice (~> 0.2.0) ruby-graphviz (~> 1.2) - rails-html-sanitizer (1.6.1) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.2.2) - actionpack (= 7.2.2) - activesupport (= 7.2.2) + railties (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -286,17 +287,17 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) - rdoc (6.8.1) + rdoc (6.10.0) psych (>= 4.0.0) redcarpet (3.6.0) - regexp_parser (2.9.3) - reline (0.5.12) + regexp_parser (2.10.0) + reline (0.6.0) io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.3.9) - rubocop (1.69.1) + rexml (3.4.0) + rubocop (1.69.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -306,7 +307,7 @@ GEM rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.36.2) + rubocop-ast (1.37.0) parser (>= 3.3.1.0) rubocop-minitest (0.36.0) rubocop (>= 1.61, < 2.0) @@ -329,7 +330,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - securerandom (0.4.0) + securerandom (0.4.1) simple_form (5.3.1) actionpack (>= 5.2) activemodel (>= 5.2) @@ -353,8 +354,8 @@ GEM terrapin (1.0.1) climate_control thor (1.3.2) - tilt (2.4.0) - timeout (0.4.2) + tilt (2.5.0) + timeout (0.4.3) turbo-rails (1.5.0) actionpack (>= 6.0.0) activejob (>= 6.0.0) @@ -365,7 +366,7 @@ GEM tzinfo tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (3.1.2) + unicode-display_width (3.1.3) unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) useragent (0.16.11) @@ -376,7 +377,8 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - websocket-driver (0.7.6) + websocket-driver (0.7.7) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) will_paginate (3.3.1) diff --git a/Makefile b/Makefile index 6b79d8a3..28060427 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,9 @@ all: sintaxis-js sintaxis-ruby bundler-audit brakeman rubocop sintaxis-js: - for i in `find app/assets/javascripts/ -name "*js" -or -name "*es6"`; do \ - node -c $$i; \ - done - for i in `find app/assets/javascripts/ -name "*coffee"`; do \ - coffee -o /tmp/ $$i; \ - done + for i in `find app/assets/javascripts/ -name "*js"`; do \ + node -c $$i; \ + done # Falta es6 sintaxis-ruby: find . -name "*\.rb" -exec ruby -w -W2 -c {} ';' diff --git a/Rakefile b/Rakefile index e7793b5c..e990eb8a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "bundler/setup" APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__) diff --git a/app/helpers/mr519_gen/application_helper.rb b/app/helpers/mr519_gen/application_helper.rb index bd85f948..f97dfa1d 100644 --- a/app/helpers/mr519_gen/application_helper.rb +++ b/app/helpers/mr519_gen/application_helper.rb @@ -66,12 +66,11 @@ def nombre_a_nombreinterno(nombre) module_function :nombre_a_nombreinterno # resps es una serie de registros con asociación respuestafor a - # Mr519::Respuestafor para una - # mismo formulario + # Mr519::Respuestafor para un mismo formulario def analiza_respuestas(respuestafor_ids, titulo, consolidado, _menserr) resps = Mr519Gen::Respuestafor.where(id: respuestafor_ids) if resps.count == 0 - menserr = "No hay encuestas respondidas" + _menserr << "No hay encuestas respondidas" return false end titulo << "Resultados de encuesta: " + @@ -156,11 +155,11 @@ def analiza_respuestas(respuestafor_ids, titulo, consolidado, _menserr) # Dado un objeto que puede tener varios respuestafor y un formulario_id # y un campo_id retorna el valor del campo en el formulario o nil def presenta_valor(objeto, formulario_id, campo_id) - rf = objeto.respuestafor.where(formulario_id: formulario_id).take - return nil unless rf + rf = objeto.respuestafor.find_by(formulario_id: formulario_id) + return unless rf - vc = rf.valorcampo.where(campo_id: campo_id).take - return nil unless vc + vc = rf.valorcampo.find_by(campo_id: campo_id) + return unless vc vc.presenta_valor(false) end diff --git a/app/models/mr519_gen/ability.rb b/app/models/mr519_gen/ability.rb index accb3f60..b0d16654 100644 --- a/app/models/mr519_gen/ability.rb +++ b/app/models/mr519_gen/ability.rb @@ -70,4 +70,4 @@ def initialize_mr519_gen(usuario = nil) end end # def initialize_jn316_gen end # class -end # module +end # module diff --git a/app/models/mr519_gen/respuestafor.rb b/app/models/mr519_gen/respuestafor.rb index 3e5ea89a..ef33ccca 100644 --- a/app/models/mr519_gen/respuestafor.rb +++ b/app/models/mr519_gen/respuestafor.rb @@ -3,7 +3,7 @@ require "mr519_gen/concerns/models/respuestafor" module Mr519Gen - # Respuesta a un formulario, relaciona los campos del formulario con + # Respuesta a un formulario, relaciona los campos del formulario con # los valores que una persona diligencia. class Respuestafor < ActiveRecord::Base include Mr519Gen::Concerns::Models::Respuestafor diff --git a/config/routes.rb b/config/routes.rb index e7c78064..d9afce71 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,18 +1,17 @@ # frozen_string_literal: true Mr519Gen::Engine.routes.draw do - resources :campos, only: [], param: :index do member do - delete '(:id)', to: "campos#destroy", as: "eliminar" - post '/' => "campos#create", as: "crear" + delete "(:id)", to: "campos#destroy", as: "eliminar" + post "/" => "campos#create", as: "crear" end end resources :opcionescs, only: [], param: :index do member do - delete '(:id)', to: "opcionescs#destroy", as: "eliminar" - post '/' => "opcionescs#create", as: "crear" + delete "(:id)", to: "opcionescs#destroy", as: "eliminar" + post "/" => "opcionescs#create", as: "crear" end end diff --git a/lib/mr519_gen/concerns/controllers/campos_controller.rb b/lib/mr519_gen/concerns/controllers/campos_controller.rb index 6acd626a..f7660b5e 100644 --- a/lib/mr519_gen/concerns/controllers/campos_controller.rb +++ b/lib/mr519_gen/concerns/controllers/campos_controller.rb @@ -7,7 +7,6 @@ module CamposController extend ActiveSupport::Concern included do - def destroy end @@ -18,12 +17,11 @@ def create def preparar_campo_formulario @registro = @formulario = Mr519Gen::Formulario.new( - campo: [Mr519Gen::Campo.new]) + campo: [Mr519Gen::Campo.new], + ) end end # included - end end end end - diff --git a/lib/mr519_gen/concerns/controllers/encuestaspersona_controller.rb b/lib/mr519_gen/concerns/controllers/encuestaspersona_controller.rb index 80710507..2bde1822 100644 --- a/lib/mr519_gen/concerns/controllers/encuestaspersona_controller.rb +++ b/lib/mr519_gen/concerns/controllers/encuestaspersona_controller.rb @@ -28,17 +28,17 @@ def atributos_index r << :fechacambio_localizada r << :adurl end - r += [ + r + [ :respuestafor, ] end def atributos_form atributos_show - [ - :id, - :fechacambio_localizada + :id, + :fechacambio_localizada, ] + [ - :fechacambio + :fechacambio, ] end @@ -114,8 +114,7 @@ def externa Mr519Gen::Encuestapersona, ) end - @registro = Mr519Gen::Encuestapersona.where(adurl: adurl) - .take + @registro = Mr519Gen::Encuestapersona.find_by(adurl: adurl) self.class.asegura_camposdinamicos( @registro, current_usuario ? current_usuario.id : nil ) diff --git a/lib/mr519_gen/concerns/controllers/encuestasusuario_controller.rb b/lib/mr519_gen/concerns/controllers/encuestasusuario_controller.rb index d51def5d..f9e20653 100644 --- a/lib/mr519_gen/concerns/controllers/encuestasusuario_controller.rb +++ b/lib/mr519_gen/concerns/controllers/encuestasusuario_controller.rb @@ -29,7 +29,7 @@ def atributos_index :fechainicio_localizada, ] end - r += [ + r + [ :formulario, :fechacambio_localizada, :fechafin_localizada, @@ -38,12 +38,12 @@ def atributos_index def atributos_form r = atributos_show - [ - :id, + :id, :formulario, :fechaini_localizada, :fechainicio_localizada, :fechacambio_localizada, - :fechafin_localizada + :fechafin_localizada, ] + [ :formulario_id, :fechaini, diff --git a/lib/mr519_gen/concerns/controllers/formularios_controller.rb b/lib/mr519_gen/concerns/controllers/formularios_controller.rb index ba127fa2..3a4cc4f0 100644 --- a/lib/mr519_gen/concerns/controllers/formularios_controller.rb +++ b/lib/mr519_gen/concerns/controllers/formularios_controller.rb @@ -38,7 +38,7 @@ def index_reordenar(c) end # GET /formularios/new - + def new @registro = @formulario = Formulario.new @formulario.nombre = "Formulario Nuevo" @@ -105,7 +105,8 @@ def set_formulario def mr519_gen_params atributos_form + - [ :id, + [ + :id, campo_attributes: [ :ancho, :ayudauso, diff --git a/lib/mr519_gen/concerns/controllers/opcionescs_controller.rb b/lib/mr519_gen/concerns/controllers/opcionescs_controller.rb index 8f0c5d39..d0755c46 100644 --- a/lib/mr519_gen/concerns/controllers/opcionescs_controller.rb +++ b/lib/mr519_gen/concerns/controllers/opcionescs_controller.rb @@ -7,7 +7,6 @@ module OpcionescsController extend ActiveSupport::Concern included do - def create end @@ -22,7 +21,7 @@ def update def preparar_opcion_campo_formulario @campo = Mr519Gen::Campo.new(opcioncs: [Mr519Gen::Opcioncs.new]) @formulario = Mr519Gen::Formulario.new(campo: [@campo]) - @campo.opcioncs[0].campo = Mr519Gen::Campo.new() + @campo.opcioncs[0].campo = Mr519Gen::Campo.new end end # included end diff --git a/lib/mr519_gen/concerns/models/encuestapersona.rb b/lib/mr519_gen/concerns/models/encuestapersona.rb index 3af0a6df..d7847d2d 100644 --- a/lib/mr519_gen/concerns/models/encuestapersona.rb +++ b/lib/mr519_gen/concerns/models/encuestapersona.rb @@ -67,7 +67,7 @@ def fechacambio def fechacambio=(val) self.respuestafor = Mr519Gen::Respuestafor.new if respuestafor.nil? - respuestafor.fechacambio= val + respuestafor.fechacambio = val end attr_accessor :formulario_id diff --git a/lib/mr519_gen/concerns/models/encuestausuario.rb b/lib/mr519_gen/concerns/models/encuestausuario.rb index 182ea754..af932d41 100644 --- a/lib/mr519_gen/concerns/models/encuestausuario.rb +++ b/lib/mr519_gen/concerns/models/encuestausuario.rb @@ -82,7 +82,7 @@ def fechacambio def fechacambio=(val) self.respuestafor = Mr519Gen::Respuestafor.new if respuestafor.nil? - respuestafor.fechacambio= val + respuestafor.fechacambio = val end attr_accessor :formulario_id diff --git a/lib/mr519_gen/concerns/models/valorcampo.rb b/lib/mr519_gen/concerns/models/valorcampo.rb index 55674389..3d4f5b46 100644 --- a/lib/mr519_gen/concerns/models/valorcampo.rb +++ b/lib/mr519_gen/concerns/models/valorcampo.rb @@ -90,7 +90,7 @@ def presenta_valor(con_nombre_campo = true) " porque hay #{tb.count}" else cla = ::Ability.tb_clase(tb[0]) - o = cla.where(id: valor).take + o = cla.find_by(id: valor) r += o.nombre if o.respond_to?(:nombre) end end diff --git a/lib/tasks/mr519_gen_tasks.rake b/lib/tasks/mr519_gen_tasks.rake index 50d1d33f..a1add6bb 100644 --- a/lib/tasks/mr519_gen_tasks.rake +++ b/lib/tasks/mr519_gen_tasks.rake @@ -1,4 +1,5 @@ # frozen_string_literal: true + # desc "Explaining what the task does" # task :mr519_gen do # # Task goes here diff --git a/test/controllers/mr519_gen/campos_controller_test.rb b/test/controllers/mr519_gen/campos_controller_test.rb index 6fdaf65d..c46bfa23 100644 --- a/test/controllers/mr519_gen/campos_controller_test.rb +++ b/test/controllers/mr519_gen/campos_controller_test.rb @@ -8,7 +8,6 @@ class CamposControllerTest < ActionDispatch::IntegrationTest include Devise::Test::IntegrationHelpers setup do - raise "CONFIG_HOSTS debe ser www.example.com" if ENV["CONFIG_HOSTS"] != "www.example.com" Rails.application.config.x.formato_fecha = "yyyy-mm-dd" @@ -29,10 +28,10 @@ class CamposControllerTest < ActionDispatch::IntegrationTest test "debe mostrar nuevo" do skip assert_difference("Mr519Gen::Campo.count", +1) do - debugger - get crear_campo_url(index: 0) + "?formulario_id=#{@formulario.id}&index=0", + debugger + get crear_campo_url(index: 0) + "?formulario_id=#{@formulario.id}&index=0", as: :json - debugger + debugger assert_response :success end @@ -44,7 +43,8 @@ class CamposControllerTest < ActionDispatch::IntegrationTest debugger delete eliminar_campo_url(@campo.id, 0), as: :json - debugger + debugger + assert_response :success end end diff --git a/test/controllers/mr519_gen/encuestasusuario_controller_test.rb b/test/controllers/mr519_gen/encuestasusuario_controller_test.rb index d5f190a5..f15d044f 100644 --- a/test/controllers/mr519_gen/encuestasusuario_controller_test.rb +++ b/test/controllers/mr519_gen/encuestasusuario_controller_test.rb @@ -43,7 +43,7 @@ class EncuestasusuarioControllerTest < ActionDispatch::IntegrationTest test "debe mostrar nuevo" do get new_encuestausuario_url - assert_response 302 + assert_response :found end test "debe crear encuestausuario" do diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index e9dfa827..b95e7045 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -#require "msip/application_controller" +# require "msip/application_controller" class ApplicationController < Msip::ApplicationController # Previente ataques CSRF elevando una excepción # En el caso de APIs, en cambio puedes querer usar :null_session diff --git a/test/dummy/bin/corre b/test/dummy/bin/corre index 18988423..a49f11fc 100755 --- a/test/dummy/bin/corre +++ b/test/dummy/bin/corre @@ -14,7 +14,7 @@ require "fileutils" -ENV.each {|l,v| puts "#{l}=#{v}" } # Depuración +ENV.each { |l, v| puts "#{l}=#{v}" } # Depuración # Ruta a directorio raíz de aplicación RAIZ_AP = File.expand_path("..", __dir__) @@ -97,8 +97,8 @@ FileUtils.chdir(RAIZ_AP) do ord += "CONFIG_HOSTS=\"#{ENV["CONFIG_HOSTS"].downcase}\" " end ord += "RAILS_RELATIVE_URL_ROOT='' " - ord += "ruby --yjit bin/rails s " - #ord += "ruby bin/rails s " + ord += "ruby --yjit bin/rails s " + # ord += "ruby bin/rails s " if ENV["PUERTODES"] != "" ord += "-p #{ENV["PUERTODES"]} " end diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index efc03774..22f2d8de 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake index 4fbf10b9..e436ea54 100755 --- a/test/dummy/bin/rake +++ b/test/dummy/bin/rake @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require_relative "../config/boot" require "rake" Rake.application.run diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup index 027ead2e..87fc9d9b 100755 --- a/test/dummy/bin/setup +++ b/test/dummy/bin/setup @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require "fileutils" APP_ROOT = File.expand_path("..", __dir__) @@ -8,7 +10,7 @@ def system!(*args) system(*args, exception: true) end -FileUtils.chdir APP_ROOT do +FileUtils.chdir(APP_ROOT) do # This script is a way to set up or update your development environment automatically. # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 3677dff8..c6c1b586 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -4,7 +4,7 @@ require_relative "config/environment" rutarel = ENV.fetch("RUTA_RELATIVA", "msip/") -if rutarel[0] != '/' +if rutarel[0] != "/" rutarel = "/" + rutarel end map rutarel do diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 8137c628..56d3de6a 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -21,10 +21,9 @@ module Dummy class Application < Rails::Application + config.load_defaults(Rails::VERSION::STRING.to_f) - config.load_defaults Rails::VERSION::STRING.to_f - - config.autoload_lib(ignore: %w(assets tasks)) + config.autoload_lib(ignore: ["assets", "tasks"]) # Las configuraciones en config/environments/* tiene precedencia sobre # las especificadas aquí. @@ -45,10 +44,10 @@ class Application < Rails::Application config.i18n.default_locale = :es config.railties_order = [ - :main_app, - Mr519Gen::Engine, - Msip::Engine, - :all + :main_app, + Mr519Gen::Engine, + Msip::Engine, + :all, ] config.colorize_logging = true @@ -60,7 +59,7 @@ class Application < Rails::Application ENV.fetch("CONFIG_HOSTS", "defensor.info").downcase.split(";"), ) - config.relative_url_root = ENV.fetch('RUTA_RELATIVA', '/msip') + config.relative_url_root = ENV.fetch("RUTA_RELATIVA", "/msip") # msip config.x.formato_fecha = ENV.fetch("MSIP_FORMATO_FECHA", "dd/M/yyyy") diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 829088d5..983badd3 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/integer/time" Rails.application.configure do @@ -32,7 +34,7 @@ end # Store uploaded files on the local file system (see config/storage.yml for options). - #config.active_storage.service = :local + # config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index f9486a6a..5aa258cb 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/integer/time" Rails.application.configure do @@ -37,7 +39,7 @@ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX # Store uploaded files on the local file system (see config/storage.yml for options). - #config.active_storage.service = :local + # config.active_storage.service = :local # Mount Action Cable outside main process or domain. # config.action_cable.mount_path = nil @@ -56,11 +58,11 @@ # Log to STDOUT by default config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .tap { |logger| logger.formatter = Logger::Formatter.new } .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # "info" includes generic and useful information about system operation, but avoids logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). If you diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 48464e72..5b8715b0 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/integer/time" # The test environment is used exclusively to run your application's @@ -32,7 +34,7 @@ config.action_controller.allow_forgery_protection = false # Store uploaded files on the local file system in a temporary directory. - #config.active_storage.service = :test + # config.active_storage.service = :test # Disable caching for Action Mailer templates even if Action Controller # caching is enabled. diff --git a/test/dummy/config/initializers/application_controller_renderer.rb b/test/dummy/config/initializers/application_controller_renderer.rb index f4556db3..6d56e439 100644 --- a/test/dummy/config/initializers/application_controller_renderer.rb +++ b/test/dummy/config/initializers/application_controller_renderer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/test/dummy/config/initializers/content_security_policy.rb b/test/dummy/config/initializers/content_security_policy.rb index b3076b38..35ab3fd6 100644 --- a/test/dummy/config/initializers/content_security_policy.rb +++ b/test/dummy/config/initializers/content_security_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Define an application-wide content security policy. diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb index c010b83d..e4d3871c 100644 --- a/test/dummy/config/initializers/filter_parameter_logging.rb +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. # Use this to limit dissemination of sensitive information. # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += [ - :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, ] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb index 3860f659..9e049dcc 100644 --- a/test/dummy/config/initializers/inflections.rb +++ b/test/dummy/config/initializers/inflections.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb index 6e1d16f0..be6fedc5 100644 --- a/test/dummy/config/initializers/mime_types.rb +++ b/test/dummy/config/initializers/mime_types.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/test/dummy/config/initializers/msip.rb b/test/dummy/config/initializers/msip.rb index 6ace7a1e..2022b149 100644 --- a/test/dummy/config/initializers/msip.rb +++ b/test/dummy/config/initializers/msip.rb @@ -5,14 +5,14 @@ Msip.setup do |config| config.ruta_anexos = ENV.fetch( "MSIP_RUTA_ANEXOS", - "#{Rails.root}/archivos/anexos", + "#{Rails.root.join("archivos/anexos")}", ) config.ruta_volcados = ENV.fetch( "MSIP_RUTA_VOLCADOS", - "#{Rails.root}/archivos/bd", + "#{Rails.root.join("archivos/bd")}", ) # En heroku los anexos son super-temporales - config.ruta_anexos = "#{Rails.root}/tmp/" unless ENV["HEROKU_POSTGRESQL_GREEN_URL"].nil? + config.ruta_anexos = "#{Rails.root.join("tmp/")}" unless ENV["HEROKU_POSTGRESQL_GREEN_URL"].nil? config.titulo = "mr519_gen #{Mr519Gen::VERSION}" config.descripcion = "Motor para manejar formularios y encuestas" config.codigofuente = "https://gitlab.com/pasosdeJesus/mr519_gen" diff --git a/test/dummy/config/initializers/new_framework_defaults_7_2.rb b/test/dummy/config/initializers/new_framework_defaults_7_2.rb index b549c4a2..0344a6d0 100644 --- a/test/dummy/config/initializers/new_framework_defaults_7_2.rb +++ b/test/dummy/config/initializers/new_framework_defaults_7_2.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file eases your Rails 7.2 framework defaults upgrade. diff --git a/test/dummy/config/initializers/permissions_policy.rb b/test/dummy/config/initializers/permissions_policy.rb index 7db3b957..e8d0b2ae 100644 --- a/test/dummy/config/initializers/permissions_policy.rb +++ b/test/dummy/config/initializers/permissions_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Define an application-wide HTTP permissions policy. For further diff --git a/test/dummy/config/puma.rb b/test/dummy/config/puma.rb index 03c166f4..6e80052c 100644 --- a/test/dummy/config/puma.rb +++ b/test/dummy/config/puma.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This configuration file will be evaluated by Puma. The top-level methods that # are invoked here are part of Puma's configuration DSL. For more information # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index edd02f24..da503b88 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true Rails.application.routes.draw do - devise_scope :usuario do - get "sign_out" => "devise/sessions#destroy" - end - devise_for :usuarios, skip: [:registrations], module: :devise - as :usuario do - get "usuarios/edit" => "devise/registrations#edit", - :as => "editar_registro_usuario" - put "usuarios/:id" => "devise/registrations#update", - :as => "registro_usuario" - end - resources :usuarios, path_names: { new: "nuevo", edit: "edita" } + devise_scope :usuario do + get "sign_out" => "devise/sessions#destroy" + end + devise_for :usuarios, skip: [:registrations], module: :devise + as :usuario do + get "usuarios/edit" => "devise/registrations#edit", + :as => "editar_registro_usuario" + put "usuarios/:id" => "devise/registrations#update", + :as => "registro_usuario" + end + resources :usuarios, path_names: { new: "nuevo", edit: "edita" } - root "msip/hogar#index" + root "msip/hogar#index" mount Msip::Engine, at: "/", as: "msip" mount Mr519Gen::Engine, at: "/", as: "mr519_gen" end diff --git a/test/models/mr519_gen/campo_test.rb b/test/models/mr519_gen/campo_test.rb index 776d1054..3ad5b180 100644 --- a/test/models/mr519_gen/campo_test.rb +++ b/test/models/mr519_gen/campo_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative "./formulario_test" +require_relative "formulario_test" require_relative "../../test_helper" module Mr519Gen diff --git a/test/models/mr519_gen/encuestapersona_test.rb b/test/models/mr519_gen/encuestapersona_test.rb index 4fa27f0b..562f1ca7 100644 --- a/test/models/mr519_gen/encuestapersona_test.rb +++ b/test/models/mr519_gen/encuestapersona_test.rb @@ -51,7 +51,7 @@ class EncuestapersonaTest < ActiveSupport::TestCase assert Mr519Gen::Encuestapersona.filtro_fechainifin("2010-01-01") assert Mr519Gen::Encuestapersona.filtro_persona(1) - assert e.formulario_id > 0 + assert_operator e.formulario_id, :>, 0 e.formulario_id = 1 assert_equal 1, e.formulario_id diff --git a/test/models/mr519_gen/encuestausuario_test.rb b/test/models/mr519_gen/encuestausuario_test.rb index f5236fd8..b7deb515 100644 --- a/test/models/mr519_gen/encuestausuario_test.rb +++ b/test/models/mr519_gen/encuestausuario_test.rb @@ -45,7 +45,7 @@ class EncuestausuarioTest < ActiveSupport::TestCase assert Mr519Gen::Encuestausuario.filtro_usuario(1) assert Mr519Gen::Encuestausuario.filtro_formulario(22) - assert e.formulario_id > 0 + assert_operator e.formulario_id, :>, 0 e.formulario_id = 1 assert_equal 1, e.formulario_id diff --git a/test/models/mr519_gen/opcioncs_test.rb b/test/models/mr519_gen/opcioncs_test.rb index 05e5241f..a72e977a 100644 --- a/test/models/mr519_gen/opcioncs_test.rb +++ b/test/models/mr519_gen/opcioncs_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative "./formulario_test" +require_relative "formulario_test" require_relative "../../test_helper" module Mr519Gen diff --git a/test/models/mr519_gen/valorcampo_test.rb b/test/models/mr519_gen/valorcampo_test.rb index 585f7e6f..728edf90 100644 --- a/test/models/mr519_gen/valorcampo_test.rb +++ b/test/models/mr519_gen/valorcampo_test.rb @@ -9,7 +9,6 @@ class ValorcampoTest < ActiveSupport::TestCase end test "valido" do - f = Mr519Gen::Formulario.create(PRUEBA_FORMULARIO) assert_predicate f, :valid?