Initial upgrade to Rails 7.2.2 [SCI-11841] (#8524)

This commit is contained in:
Alex Kriuchykhin 2025-06-04 13:31:57 +02:00 committed by GitHub
parent 169145c405
commit 79098b51b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
58 changed files with 809 additions and 673 deletions

View file

@ -1,4 +1,4 @@
FROM ruby:3.2-bookworm
FROM ruby:3.3-bookworm
MAINTAINER SciNote <info@scinote.net>
ARG TIKA_DIST_URL="https://dlcdn.apache.org/tika/2.9.4/tika-app-2.9.4.jar"

View file

@ -1,5 +1,5 @@
# Building stage
FROM ruby:3.2-bookworm AS builder
FROM ruby:3.3-bookworm AS builder
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN \
@ -42,7 +42,7 @@ RUN \
bash -c "rake assets:precompile && rake deface:precompile && rm -rf ./tmp/cache"
# Final stage
FROM ruby:3.2-bookworm AS runner
FROM ruby:3.3-bookworm AS runner
MAINTAINER SciNote <info@scinote.net>
ARG TIKA_DIST_URL="https://dlcdn.apache.org/tika/2.9.4/tika-app-2.9.4.jar"

View file

@ -2,17 +2,17 @@
source 'https://rubygems.org'
ruby '~> 3.2.2'
ruby '~> 3.3.8'
gem 'activerecord-session_store'
gem 'bootsnap', require: false
gem 'devise', '~> 4.8.1'
gem 'devise', '~> 4.9.4'
gem 'devise_invitable'
gem 'figaro'
gem 'pg', '~> 1.5'
gem 'pg_search' # PostgreSQL full text search
gem 'psych', '< 4.0'
gem 'rails', '~> 7.0.8'
gem 'rails', '~> 7.2.2'
gem 'recaptcha'
gem 'sanitize'
gem 'sprockets-rails'
@ -52,7 +52,7 @@ gem 'down', '~> 5.0'
gem 'faker' # Generate fake data
gem 'fastimage' # Light gem to get image resolution
gem 'grover'
gem 'httparty', '~> 0.21.0'
gem 'httparty', '~> 0.23.1'
gem 'i18n-js', '~> 3.6' # Localization in javascript files
gem 'jbuilder' # JSON structures via a Builder-style DSL
gem 'logging', '~> 2.0.0'

View file

@ -43,64 +43,64 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.8.7)
actionpack (= 7.0.8.7)
activesupport (= 7.0.8.7)
actioncable (7.2.2.1)
actionpack (= 7.2.2.1)
activesupport (= 7.2.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.8.7)
actionpack (= 7.0.8.7)
activejob (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.8.7)
actionpack (= 7.0.8.7)
actionview (= 7.0.8.7)
activejob (= 7.0.8.7)
activesupport (= 7.0.8.7)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.8.7)
actionview (= 7.0.8.7)
activesupport (= 7.0.8.7)
rack (~> 2.0, >= 2.2.4)
zeitwerk (~> 2.6)
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.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.1)
actionview (= 7.2.2.1)
activesupport (= 7.2.2.1)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8.7)
actionpack (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
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.0.8.7)
activesupport (= 7.0.8.7)
actionview (7.2.2.1)
activesupport (= 7.2.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
active_model_serializers (0.10.15)
actionpack (>= 4.1)
activemodel (>= 4.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (7.0.8.7)
activesupport (= 7.0.8.7)
activejob (7.2.2.1)
activesupport (= 7.2.2.1)
globalid (>= 0.3.6)
activemodel (7.0.8.7)
activesupport (= 7.0.8.7)
activerecord (7.0.8.7)
activemodel (= 7.0.8.7)
activesupport (= 7.0.8.7)
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)
activerecord-import (1.4.1)
activerecord (>= 4.2)
activerecord-session_store (2.1.0)
@ -110,22 +110,28 @@ GEM
multi_json (~> 1.11, >= 1.11.2)
rack (>= 2.0.8, < 4)
railties (>= 6.1)
activestorage (7.0.8.7)
actionpack (= 7.0.8.7)
activejob (= 7.0.8.7)
activerecord (= 7.0.8.7)
activesupport (= 7.0.8.7)
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)
mini_mime (>= 1.1.0)
activesupport (7.0.8.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
activesupport (7.2.2.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
acts_as_list (1.1.0)
activerecord (>= 4.2)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
aes_key_wrap (1.1.0)
ajax-datatables-rails (0.3.1)
railties (>= 3.1)
@ -189,23 +195,24 @@ GEM
base62 (1.0.0)
base64 (0.2.0)
bcrypt (3.1.18)
benchmark (0.4.0)
better_errors (2.10.1)
erubi (>= 1.0.0)
rack (>= 0.9.0)
rouge (>= 1.0.0)
bigdecimal (3.1.8)
bigdecimal (3.2.0)
bindata (2.5.0)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
bootsnap (1.16.0)
bootsnap (1.18.6)
msgpack (~> 1.2)
brakeman (6.1.2)
racc
builder (3.3.0)
bullet (7.0.7)
bullet (8.0.7)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (11.1.3)
byebug (12.0.0)
capybara (3.39.2)
addressable
matrix
@ -236,15 +243,15 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
combine_pdf (1.0.23)
matrix
ruby-rc4 (>= 0.1.5)
concurrent-ruby (1.3.4)
crack (0.4.5)
concurrent-ruby (1.3.5)
connection_pool (2.5.3)
crack (1.0.0)
bigdecimal
rexml
crass (1.0.6)
cssbundling-rails (1.1.2)
railties (>= 6.0.0)
csv (3.3.4)
cucumber (8.0.0)
builder (~> 3.2, >= 3.2.4)
cucumber-ci-environment (~> 9.0, >= 9.0.4)
@ -277,9 +284,9 @@ GEM
rexml (~> 3.0)
webrick (~> 1.7)
cucumber-tag-expressions (4.1.0)
database_cleaner (2.0.2)
database_cleaner (2.1.0)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.1.0)
database_cleaner-active_record (2.2.1)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
@ -303,7 +310,7 @@ GEM
delayed_job_active_record (4.1.7)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
devise (4.8.1)
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
@ -312,7 +319,7 @@ GEM
devise_invitable (2.0.9)
actionmailer (>= 5.0)
devise (>= 4.6)
diff-lcs (1.5.0)
diff-lcs (1.6.2)
discard (1.2.1)
activerecord (>= 4.2, < 8)
docile (1.4.0)
@ -322,14 +329,15 @@ GEM
railties (>= 5)
down (5.4.1)
addressable (~> 2.8)
erubi (1.13.0)
drb (2.2.3)
erubi (1.13.1)
et-orbi (1.2.11)
tzinfo
execjs (2.8.1)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
factory_bot (6.5.1)
activesupport (>= 6.1.0)
factory_bot_rails (6.4.4)
factory_bot (~> 6.5)
railties (>= 5.0.0)
faker (3.2.0)
i18n (>= 1.8.11, < 2)
@ -353,10 +361,9 @@ GEM
activesupport (>= 6.1)
graphviz (1.2.1)
process-pipeline
grover (1.1.5)
combine_pdf (~> 1.0)
nokogiri (~> 1.0)
hashdiff (1.0.1)
grover (1.2.3)
nokogiri (~> 1)
hashdiff (1.2.0)
hashie (5.0.0)
htmlentities (4.3.4)
http (5.1.1)
@ -367,10 +374,11 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
http-form_data (2.3.0)
httparty (0.21.0)
httparty (0.23.1)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.6)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
i18n-js (3.9.2)
i18n (>= 0.6.6)
@ -378,6 +386,11 @@ GEM
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
iniparse (1.5.0)
io-console (0.8.0)
irb (1.15.2)
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jbuilder (2.13.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
@ -432,7 +445,7 @@ GEM
logging (2.0.0)
little-plugger (~> 1.1)
multi_json (~> 1.10)
loofah (2.23.1)
loofah (2.24.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
@ -442,34 +455,35 @@ GEM
net-smtp
marcel (1.0.4)
matrix (0.4.2)
method_source (1.0.0)
method_source (1.1.0)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0218.1)
mini_magick (4.12.0)
mini_mime (1.1.5)
minitest (5.25.4)
msgpack (1.7.1)
minitest (5.25.5)
msgpack (1.8.0)
multi_json (1.15.0)
multi_test (1.1.0)
multi_xml (0.6.0)
multi_xml (0.7.2)
bigdecimal (~> 3.1)
nested_form_fields (0.8.4)
coffee-rails (>= 3.2.1)
jquery-rails
rails (>= 3.2.0)
net-http (0.4.1)
uri
net-imap (0.4.20)
net-imap (0.5.8)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.0)
net-smtp (0.5.1)
net-protocol
newrelic_rpm (9.14.0)
nio4r (2.7.3)
nio4r (2.7.4)
nokogiri (1.18.8-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.8-x86_64-linux-gnu)
@ -531,32 +545,35 @@ GEM
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.5.3)
pg (1.5.9)
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
polyglot (0.3.5)
pp (0.6.2)
prettyprint
prettyprint (0.2.0)
process-group (1.2.4)
process-terminal (~> 0.2.0)
process-pipeline (1.0.2)
process-group
process-terminal (0.2.0)
ffi
pry (0.14.2)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
pry-rails (0.3.9)
pry (>= 0.10.4)
pry-byebug (3.11.0)
byebug (~> 12.0)
pry (>= 0.13, < 0.16)
pry-rails (0.3.11)
pry (>= 0.13.0)
psych (3.3.4)
public_suffix (5.0.1)
puma (6.4.3)
public_suffix (6.0.2)
puma (6.6.0)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.8.1)
rack (2.2.14)
rack (2.2.16)
rack-attack (6.6.1)
rack (>= 1.0, < 3)
rack-cors (2.0.2)
@ -573,52 +590,58 @@ GEM
rack (~> 2.2, >= 2.2.4)
rack-session (1.0.2)
rack (< 3)
rack-test (2.1.0)
rack-test (2.2.0)
rack (>= 1.3)
rails (7.0.8.7)
actioncable (= 7.0.8.7)
actionmailbox (= 7.0.8.7)
actionmailer (= 7.0.8.7)
actionpack (= 7.0.8.7)
actiontext (= 7.0.8.7)
actionview (= 7.0.8.7)
activejob (= 7.0.8.7)
activemodel (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
rackup (1.0.1)
rack (< 3)
webrick
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.0.8.7)
railties (= 7.2.2.1)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.2.0)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
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_autolink (1.1.8)
actionview (> 3.1)
activesupport (> 3.1)
railties (> 3.1)
railties (7.0.8.7)
actionpack (= 7.0.8.7)
activesupport (= 7.0.8.7)
method_source
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)
thor (~> 1.0)
zeitwerk (~> 2.5)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.1.0)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (6.3.4.1)
recaptcha (5.17.0)
regexp_parser (2.8.1)
reline (0.6.1)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
@ -636,23 +659,23 @@ GEM
chunky_png (~> 1.0)
rqrcode_core (~> 1.0)
rqrcode_core (1.2.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
rspec-core (3.13.4)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-rails (6.0.3)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.12)
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.0)
rspec-support (~> 3.13.0)
rspec-rails (8.0.0)
actionpack (>= 7.2)
activesupport (>= 7.2)
railties (>= 7.2)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.4)
rubocop (1.52.1)
json (~> 2.3)
parallel (~> 1.10)
@ -673,7 +696,6 @@ GEM
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.13.0)
ruby-rc4 (0.1.5)
ruby-saml (1.18.0)
nokogiri (>= 1.13.10)
rexml
@ -690,11 +712,12 @@ GEM
railties (>= 4.0.0)
sdoc (1.1.0)
rdoc (>= 5.0)
securerandom (0.4.1)
selenium-webdriver (4.10.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
shoulda-matchers (5.3.0)
shoulda-matchers (6.5.0)
activesupport (>= 5.2.0)
silencer (2.0.0)
simplecov (0.22.0)
@ -725,7 +748,7 @@ GEM
railties (>= 6.0.0)
tailwindcss-rails (2.4.0-x86_64-linux)
railties (>= 6.0.0)
thor (1.3.1)
thor (1.3.2)
tilt (2.4.0)
timecop (0.9.6)
timeout (0.4.3)
@ -741,8 +764,9 @@ GEM
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.4.2)
uniform_notifier (1.16.0)
uniform_notifier (1.17.0)
uri (0.13.2)
useragent (0.16.11)
validate_email (0.1.6)
activemodel (>= 3.0)
mail (>= 2.2.5)
@ -760,20 +784,21 @@ GEM
activesupport
faraday (~> 2.0)
faraday-follow_redirects
webmock (3.18.1)
webmock (3.25.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.9.1)
websocket (1.2.9)
websocket-driver (0.7.6)
websocket-driver (0.8.0)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
wicked_pdf (2.7.0)
activesupport
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.13)
zeitwerk (2.7.3)
zip-zip (0.3)
rubyzip (>= 1.0.0)
@ -812,7 +837,7 @@ DEPENDENCIES
datadog
deface (~> 1.9)
delayed_job_active_record
devise (~> 4.8.1)
devise (~> 4.9.4)
devise_invitable
discard
doorkeeper (>= 4.6)
@ -823,7 +848,7 @@ DEPENDENCIES
figaro
graphviz
grover
httparty (~> 0.21.0)
httparty (~> 0.23.1)
i18n-js (~> 3.6)
image_processing
img2zpl!
@ -859,7 +884,7 @@ DEPENDENCIES
puma
rack-attack
rack-cors
rails (~> 7.0.8)
rails (~> 7.2.2)
rails-controller-testing
rails_autolink (~> 1.1, >= 1.1.6)
recaptcha
@ -894,7 +919,7 @@ DEPENDENCIES
zip-zip
RUBY VERSION
ruby 3.2.2p53
ruby 3.3.8p144
BUNDLED WITH
2.5.11
2.5.22

View file

@ -13,15 +13,14 @@ class ExperimentsController < ApplicationController
before_action :load_experiment, except: %i(create archive_group restore_group
inventory_assigning_experiment_filter actions_toolbar index move)
before_action :load_experiments, only: :move
before_action :check_read_permissions, except: %i(index edit archive clone move new
create archive_group restore_group
before_action :check_read_permissions, except: %i(index archive clone move create archive_group restore_group
inventory_assigning_experiment_filter actions_toolbar)
before_action :check_canvas_read_permissions, only: %i(canvas)
before_action :check_create_permissions, only: %i(create move)
before_action :check_manage_permissions, only: :batch_clone_my_modules
before_action :check_update_permissions, only: :update
before_action :check_archive_permissions, only: :archive
before_action :check_clone_permissions, only: %i(clone_modal clone)
before_action :check_clone_permissions, only: %i(clone)
before_action :set_inline_name_editing, only: %i(index canvas module_archive)
before_action :set_breadcrumbs_items, only: %i(index canvas module_archive)
before_action :set_navigator, only: %i(index canvas module_archive)

View file

@ -11,7 +11,7 @@ class ProjectFoldersController < ApplicationController
before_action :load_current_folder, only: %i(new)
before_action :load_project_folder, only: %i(edit update)
before_action :check_create_permissions, only: %i(new create)
before_action :check_manage_permissions, only: %i(archive move_to)
before_action :check_manage_permissions, only: %i(move_to)
def tree
render json: folders_tree(current_team, current_user)

View file

@ -24,7 +24,7 @@ class ProjectsController < ApplicationController
favorite unfavorite)
before_action :check_create_permissions, only: :create
before_action :check_manage_permissions, only: :update
before_action :set_folder_inline_name_editing, only: %i(index cards)
before_action :set_folder_inline_name_editing, only: %i(index)
before_action :set_breadcrumbs_items, only: :index
before_action :set_navigator, only: :index
layout 'fluid'

View file

@ -29,7 +29,6 @@ class ProtocolsController < ApplicationController
before_action :check_view_all_permissions, only: %i(
index
protocolsio_index
datatable
)
before_action :check_manage_permissions, only: %i(
update_keywords

View file

@ -21,10 +21,10 @@ class RepositoryItemDateReminderJob < ApplicationJob
repositories: { type: 'Repository', archived: false },
repository_rows: { archived: false }
).where( # date(time) values that are within the reminder range including buffer
"(data > (:comparison_value::timestamp - (INTERVAL ':buffer_days DAY'))) AND data <= " \
"(:comparison_value::timestamp + CAST(((repository_columns.metadata->>'reminder_unit')::int * " \
"(data > :comparison_cutoff) AND " \
"data <= (:comparison_value::timestamp + CAST(((repository_columns.metadata->>'reminder_unit')::int * " \
"(repository_columns.metadata->>'reminder_value')::int) || ' seconds' AS Interval))",
buffer_days: BUFFER_DAYS,
comparison_cutoff: comparison_value - BUFFER_DAYS.days,
comparison_value: comparison_value
)
end

View file

@ -1,19 +0,0 @@
# When WOPI performs calls onto SciNote WOPI subdomain REST endpoints
# Rack::MethodOverride MUST be omitted because it crashes the requests
# due to trying to parse body of the requests
class WopiMethodOverride
def initialize(app)
@app = app
end
def call(env)
app = @app
unless WopiSubdomain.matches?(ActionDispatch::Request.new(env))
# Use the wrapped Rack::MethodOverride middleware
app = Rack::MethodOverride.new(@app)
end
app.call(env)
end
end

View file

@ -17,12 +17,12 @@ class Activity < ApplicationRecord
# invert the children hash to get a hash defining parents
ACTIVITY_SUBJECT_PARENTS = Extends::ACTIVITY_SUBJECT_CHILDREN.invert.map do |k, v|
k&.map { |s| [s.to_s.classify, v.to_s.classify.constantize.reflect_on_association(s)&.inverse_of&.name || v] }
end.compact.sum.to_h.freeze
end.compact.sum([]).to_h.freeze
include ActivityValuesModel
include GenerateNotificationModel
enum type_of: Extends::ACTIVITY_TYPES
enum :type_of, Extends::ACTIVITY_TYPES
belongs_to :owner, inverse_of: :activities, class_name: 'User'
belongs_to :subject, polymorphic: true, optional: true

View file

@ -11,7 +11,7 @@ module SearchableModel
scope :where_attributes_like, lambda { |attributes, query, options = {}|
return unless query
attrs = normalized_attributes(attributes)
attrs = normalized_search_attributes(attributes)
if options[:whole_word].to_s == 'true' ||
options[:whole_phrase].to_s == 'true' ||
@ -103,7 +103,7 @@ module SearchableModel
scope :where_attributes_like_boolean, lambda { |attributes, query, options = {}|
return unless query
normalized_attrs = normalized_attributes(attributes)
normalized_attrs = normalized_search_attributes(attributes)
query_clauses = []
value_hash = {}
@ -131,7 +131,7 @@ module SearchableModel
options[:with_subquery] ? query_clauses : where(query_clauses.join, value_hash)
}
def self.normalized_attributes(attributes)
def self.normalized_search_attributes(attributes)
attrs = []
if attributes.blank?
# Do nothing in this case

View file

@ -4,7 +4,7 @@ module SettingsModel
extend ActiveSupport::Concern
included do
serialize :settings, JsonbHashSerializer
serialize :settings, coder: JsonbHashSerializer
after_initialize :init_default_settings, if: :new_record?
end

View file

@ -6,7 +6,7 @@ module VariablesModel
@@default_variables = HashWithIndifferentAccess.new
included do
serialize :variables, JsonbHashSerializer
serialize :variables, coder: JsonbHashSerializer
after_initialize :init_default_variables, if: :new_record?
end

View file

@ -10,7 +10,7 @@ module VersionedAttachments
define_method :"attach_#{name}_version" do |*args, **options|
ActiveRecord::Base.transaction(requires_new: true) do
__send__(:"previous_#{name.to_s.pluralize}").attach(__send__(name).blob) if __send__(name).attached?
__send__(:"previous_#{name.to_s.pluralize}").attach([__send__(name).blob.signed_id]) if __send__(name).attached?
__send__(name).attach(*args, **options)
new_blob = __send__(name).blob

View file

@ -11,8 +11,8 @@ class Report < ApplicationRecord
include SearchableModel
include SearchableByNameModel
enum pdf_file_status: { pdf_empty: 0, pdf_processing: 1, pdf_ready: 2, pdf_error: 3 }
enum docx_file_status: { docx_empty: 0, docx_processing: 1, docx_ready: 2, docx_error: 3 }
enum :pdf_file_status, { pdf_empty: 0, pdf_processing: 1, pdf_ready: 2, pdf_error: 3 }
enum :docx_file_status, { docx_empty: 0, docx_processing: 1, docx_ready: 2, docx_error: 3 }
# ActiveStorage configuration
has_one_attached :pdf_file
@ -24,16 +24,11 @@ class Report < ApplicationRecord
length: { minimum: Constants::NAME_MIN_LENGTH,
maximum: Constants::NAME_MAX_LENGTH }
validates :description, length: { maximum: Constants::TEXT_MAX_LENGTH }
validates :project, presence: true
validates :user, presence: true
belongs_to :project, inverse_of: :reports
belongs_to :user, inverse_of: :reports
belongs_to :team, inverse_of: :reports
belongs_to :last_modified_by,
foreign_key: 'last_modified_by_id',
class_name: 'User',
optional: true
belongs_to :last_modified_by, class_name: 'User', optional: true
has_many :users, through: :user_assignments
has_many :report_template_values, dependent: :destroy

View file

@ -1,16 +1,15 @@
# frozen_string_literal: true
class ReportElement < ApplicationRecord
enum type_of: Extends::REPORT_ELEMENT_TYPES
enum :type_of, Extends::REPORT_ELEMENT_TYPES
# This is only used by certain elements
enum sort_order: {
enum :sort_order, {
asc: 0,
desc: 1
}
validates :position, presence: true
validates :report, presence: true
validates :type_of, presence: true
belongs_to :report, inverse_of: :report_elements

View file

@ -112,7 +112,7 @@ class RepositoryCell < ApplicationRecord
cell.value = value
value.save!
end
cell
cell.reload
end
def snapshot!(row_snapshot)

View file

@ -2,6 +2,6 @@
class TeamZipExport < ZipExport
def self.exports_limit
(Rails.application.secrets.export_all_limit_24h || 3).to_i
Rails.configuration.x.export_all_limit_24h
end
end

View file

@ -38,38 +38,37 @@ module Activities
def filter_users!
@activity_filters = @activity_filters.where(
"NOT(filter ? 'users') OR filter -> 'users' @> '\":owner_id\"'", owner_id: @activity.owner_id
"NOT(filter ? 'users') OR filter -> 'users' @> :owner_id::jsonb", owner_id: [@activity.owner_id.to_s].to_json
)
end
def filter_types!
@activity_filters = @activity_filters.where(
"NOT(filter ? 'types') OR filter -> 'types' @> '\":type_of\"'", type_of: @activity.type_of_before_type_cast
"NOT(filter ? 'types') OR filter -> 'types' @> :type_of::jsonb", type_of: [@activity.type_of_before_type_cast.to_s].to_json
)
end
def filter_teams!
@activity_filters = @activity_filters.where(
"NOT(filter ? 'teams') OR filter -> 'teams' @> '\":team_id\"'", team_id: @activity.team_id
"NOT(filter ? 'teams') OR filter -> 'teams' @> :team_id::jsonb", team_id: [@activity.team_id.to_s].to_json
)
end
def filter_subjects!
parents = @activity.subject_parents
filtered_by_subject = @activity_filters
filtered_by_subject =
@activity_filters
.where("NOT(filter ? 'subjects')")
.or(@activity_filters.where("filter -> 'subjects' -> 'Project' @> '\":subject_id\"'",
subject_id: @activity.project_id))
.or(@activity_filters.where("filter -> 'subjects' -> :subject_type @> '\":subject_id\"'",
subject_type: @activity.subject_type, subject_id: @activity.subject_id))
.or(@activity_filters.where("filter -> 'subjects' -> 'Project' @> :subject_id::jsonb",
subject_id: [@activity.project_id.to_s].to_json))
.or(@activity_filters.where("filter -> 'subjects' -> :subject_type @> :subject_id::jsonb",
subject_type: @activity.subject_type, subject_id: [@activity.subject_id.to_s].to_json))
parents.each do |parent|
filtered_by_subject =
filtered_by_subject
.or(@activity_filters.where("filter -> 'subjects' -> :subject_type @> '\":subject_id\"'",
subject_type: parent.class, subject_id: parent.id))
.or(@activity_filters.where("filter -> 'subjects' -> :subject_type @> :subject_id::jsonb",
subject_type: parent.class.name, subject_id: [parent.id.to_s].to_json))
end
@activity_filters = filtered_by_subject
end

View file

@ -1,7 +1,7 @@
module Api
class CoreJwt
require 'jwt'
KEY_SECRET = Rails.application.secrets.secret_key_base
KEY_SECRET = Rails.application.secret_key_base
def self.encode(payload, expires_at = nil)
if expires_at

7
bin/brakeman Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
ARGV.unshift("--ensure-latest")
load Gem.bin_path("brakeman", "brakeman")

8
bin/rubocop Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
# explicit rubocop config increases performance slightly while avoiding config confusion.
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
load Gem.bin_path("rubocop", "rubocop")

View file

@ -1,11 +1,11 @@
#!/usr/bin/env ruby
require "fileutils"
# path to your application root.
APP_ROOT = File.expand_path("..", __dir__)
APP_NAME = "scinote"
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
system(*args, exception: true)
end
FileUtils.chdir APP_ROOT do
@ -30,4 +30,8 @@ FileUtils.chdir APP_ROOT do
puts "\n== Restarting application server =="
system! "bin/rails restart"
# puts "\n== Configuring puma-dev =="
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
end

View file

@ -22,7 +22,14 @@ Bundler.require(*Rails.groups)
module Scinote
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
config.load_defaults 7.2
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w[assets generators tasks])
config.add_autoload_paths_to_load_path = true
# Configuration for the application, engines, and railties goes here.
#
@ -36,16 +43,10 @@ module Scinote
config.generators.system_tests = nil
Rails.autoloaders.main.ignore(Rails.root.join('addons/*/app/decorators'))
# Add rack-attack middleware for request rate limiting
config.middleware.use Rack::Attack
# Swap the Rack::MethodOverride with a wrapped middleware for WOPI handling
require_relative '../app/middlewares/wopi_method_override'
config.middleware.swap Rack::MethodOverride, WopiMethodOverride
# Load all model concerns, including subfolders
config.autoload_paths += Dir["#{Rails.root}/app/models/concerns/**/*.rb"]
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
config.encoding = 'utf-8'
@ -67,10 +68,7 @@ module Scinote
config.x.no_external_csp_exceptions = ENV['SCINOTE_NO_EXT_CSP_EXCEPTIONS'] == 'true'
# Logging
config.log_formatter = proc do |severity, datetime, progname, msg|
"[#{datetime}] #{severity}: #{msg}\n"
end
config.x.export_all_limit_24h = (ENV['EXPORT_ALL_LIMIT_24_HOURS'] || 3).to_i
# SciNote Core Application version
VERSION = File.read(Rails.root.join('VERSION')).strip.freeze

View file

@ -1,4 +1,4 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations.

View file

@ -12,7 +12,7 @@ Rails.application.configure do
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = ENV['WORKER'].present?
config.enable_reloading = ENV['WORKER'].blank?
# Do not eager load code on boot.
config.eager_load = ENV['WORKER'].present?
@ -20,7 +20,7 @@ Rails.application.configure do
# Show full error reports.
config.consider_all_requests_local = true
# Enable server timing
# Enable server timing.
config.server_timing = true
# Enable/disable caching. By default caching is disabled.
@ -30,9 +30,7 @@ Rails.application.configure do
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
else
config.action_controller.perform_caching = false
@ -51,6 +49,8 @@ Rails.application.configure do
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
@ -68,6 +68,9 @@ Rails.application.configure do
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true
# Suppress logger output for asset requests.
config.assets.quiet = true
@ -77,6 +80,12 @@ Rails.application.configure do
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
# config.generators.apply_rubocop_autocorrect_after_generate!
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true

View file

@ -4,7 +4,7 @@ Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
config.enable_reloading = false
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
@ -13,7 +13,7 @@ Rails.application.configure do
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
Rails.application.routes.default_url_options = {
@ -22,39 +22,38 @@ Rails.application.configure do
config.action_mailer.default_url_options = { host: Rails.application.routes.default_url_options[:host] }
config.action_mailer.default_options = {
from: Rails.application.secrets.mailer_from,
reply_to: Rails.application.secrets.mailer_reply_to
from: ENV.fetch('MAIL_FROM'),
reply_to: ENV.fetch('MAIL_REPLYTO')
}
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = ENV['SMTP_USE_AWS_SES'] == 'true' ? :ses : :smtp
config.action_mailer.smtp_settings = {
address: Rails.application.secrets.mailer_address,
port: Rails.application.secrets.mailer_port,
domain: Rails.application.secrets.mailer_domain,
authentication: Rails.application.secrets.mailer_authentication,
address: ENV.fetch('SMTP_ADDRESS'),
port: ENV.fetch('SMTP_PORT', '587'),
domain: ENV.fetch('SMTP_DOMAIN'),
authentication: ENV.fetch('SMTP_AUTH_METHOD', 'plain'),
enable_starttls_auto: true,
user_name: Rails.application.secrets.mailer_user_name,
password: Rails.application.secrets.mailer_password,
openssl_verify_mode: Rails.application.secrets.mailer_openssl_verify_mode,
ca_path: Rails.application.secrets.mailer_openssl_ca_path,
ca_file: Rails.application.secrets.mailer_openssl_ca_file
user_name: ENV.fetch('SMTP_USERNAME'),
password: ENV.fetch('SMTP_PASSWORD'),
openssl_verify_mode: ENV.fetch('SMTP_OPENSSL_VERIFY_MODE', 'peer'),
ca_path: ENV.fetch('SMTP_OPENSSL_CA_PATH', '/etc/ssl/certs'),
ca_file: ENV.fetch('SMTP_OPENSSL_CA_FILE', '/etc/ssl/certs/ca-certificates.crt')
}
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Compress CSS using a preprocessor.
# Set to nil to fix builds in production (https://github.com/sass/sassc-rails/issues/93)
config.assets.css_compressor = nil
# Do not fallback to assets pipeline if a precompiled asset is missed.
# Do not fall back to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
@ -67,25 +66,39 @@ Rails.application.configure do
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = ENV['ACTIVESTORAGE_SERVICE'] || :local
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
# config.assume_ssl = true
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = ENV['RAILS_FORCE_SSL'].present?
# Skip http-to-https redirect for the default health check endpoint.
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
config.ssl_options = { redirect: { exclude: ->(request) { request.path =~ %r{api/health|status} } } }
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)
.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 ]
# "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
# want to log everything, set the level to "debug".
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "scinote_production"
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
@ -99,9 +112,6 @@ Rails.application.configure do
# Don't log any deprecations.
config.active_support.report_deprecations = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Enable/disable Deface
config.deface.enabled = ENV['DEFACE_ENABLED'] != 'false'
@ -126,15 +136,21 @@ Rails.application.configure do
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Only use :id for inspections in production.
config.active_record.attributes_for_inspect = [ :id ]
# Enable DNS rebinding protection and other `Host` header attacks.
# config.hosts = [
# "example.com", # Allow requests from example.com
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
# ]
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
# Use a different cache store in production.
config.cache_store = :memory_store, { size: (ENV['RAILS_MEM_CACHE_SIZE_MB'] || 32).to_i.megabytes }

View file

@ -8,27 +8,26 @@ require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Turn false under Spring and add config.action_view.cache_template_loading = true.
config.cache_classes = true
# While tests run files are not watched, reloading is not necessary.
config.enable_reloading = false
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
# Eager loading loads your entire application. When running a single test locally,
# this is usually not necessary, and can slow down your test suite. However, it's
# recommended that you enable it in continuous integration systems to ensure eager
# loading is working properly before deploying your code.
config.eager_load = ENV["CI"].present?
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
}
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Render exception templates for rescuable exceptions and raise for other exceptions.
config.action_dispatch.show_exceptions = :rescuable
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
@ -36,6 +35,10 @@ Rails.application.configure do
# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test
# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
config.action_mailer.perform_caching = false
Rails.application.routes.default_url_options = {
host: ENV['WEB_SERVER_URL'] || ENV['MAIL_SERVER_URL'] || 'localhost'
}
@ -48,6 +51,10 @@ Rails.application.configure do
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Unlike controllers, the mailer instance doesn't have any context about the
# incoming request so you'll need to provide the :host parameter yourself.
config.action_mailer.default_url_options = { host: "www.example.com" }
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
@ -62,4 +69,7 @@ Rails.application.configure do
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true
end

View file

@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header
ActiveSupport::Reloader.to_prepare do
Rails.application.config.content_security_policy do |policy|

View file

@ -8,13 +8,13 @@ Devise.setup do |config|
# by default. You can change it below and use your own secret key.
# config.secret_key = '8d3a7b1acfb05057553abeb1ee4709f9f2d7e2fa1e5e60e7f45ab2e9244c301adcf0d146ae7cf74ba03c39c5bf895f08606a9f98051478ac4c6a695cafb4007a'
Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION.concat(%i(otp otp_recovery_codes otp_secret))
Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION.push(%i(otp otp_recovery_codes otp_secret))
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = Rails.application.secrets.mailer_user_name
# config.mailer_sender = Rails.application.secrets.mailer_user_name
# Configure the class responsible to send e-mails.
config.mailer = 'AppMailer'

View file

@ -2,4 +2,4 @@
require 'i18n/custom_i18n_backend'
I18n.backend = CustomI18nBackend.new
I18n.backend = I18n::CustomI18nBackend.new

View file

@ -0,0 +1,280 @@
# Be sure to restart your server when you modify this file.
#
# This file eases your Rails 7.1 framework defaults upgrade.
#
# Uncomment each configuration one by one to switch to the new default.
# Once your application is ready to run with all new defaults, you can remove
# this file and set the `config.load_defaults` to `7.1`.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
###
# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able
# to manually require files that are managed by the autoloader, which you shouldn't do anyway.
#
# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size
# of the bootsnap cache if you use it.
#
# To set this configuration, add the following line to `config/application.rb` (NOT this file):
# config.add_autoload_paths_to_load_path = false
###
# Remove the default X-Download-Options headers since it is used only by Internet Explorer.
# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`.
#++
# Rails.application.config.action_dispatch.default_headers = {
# "X-Frame-Options" => "SAMEORIGIN",
# "X-XSS-Protection" => "0",
# "X-Content-Type-Options" => "nosniff",
# "X-Permitted-Cross-Domain-Policies" => "none",
# "Referrer-Policy" => "strict-origin-when-cross-origin"
# }
###
# Do not treat an `ActionController::Parameters` instance
# as equal to an equivalent `Hash` by default.
#++
# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false
###
# Active Record Encryption now uses SHA-256 as its hash digest algorithm.
#
# There are 3 scenarios to consider.
#
# 1. If you have data encrypted with previous Rails versions, and you have
# +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default
# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too:
#++
# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1
#
# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default
# in 7.0), then you need to configure SHA-256 for Active Record Encryption:
#++
# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256
#
# 3. If you don't currently have data encrypted with Active Record encryption, you can disable this setting to
# configure the default behavior starting 7.1+:
#++
# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false
###
# No longer run after_commit callbacks on the first of multiple Active Record
# instances to save changes to the same database row within a transaction.
# Instead, run these callbacks on the instance most likely to have internal
# state which matches what was committed to the database, typically the last
# instance to save.
#++
# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false
###
# Configures SQLite with a strict strings mode, which disables double-quoted string literals.
#
# SQLite has some quirks around double-quoted string literals.
# It first tries to consider double-quoted strings as identifier names, but if they don't exist
# it then considers them as string literals. Because of this, typos can silently go unnoticed.
# For example, it is possible to create an index for a non existing column.
# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details.
#++
# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true
###
# Disable deprecated singular associations names.
#++
# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false
###
# Enable the Active Job `BigDecimal` argument serializer, which guarantees
# roundtripping. Without this serializer, some queue adapters may serialize
# `BigDecimal` arguments as simple (non-roundtrippable) strings.
#
# When deploying an application with multiple replicas, old (pre-Rails 7.1)
# replicas will not be able to deserialize `BigDecimal` arguments from this
# serializer. Therefore, this setting should only be enabled after all replicas
# have been successfully upgraded to Rails 7.1.
#++
# Rails.application.config.active_job.use_big_decimal_serializer = true
###
# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or
# `write` are given an invalid `expires_at` or `expires_in` time.
# Options are `true`, and `false`. If `false`, the exception will be reported
# as `handled` and logged instead.
#++
# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true
###
# Specify whether Query Logs will format tags using the SQLCommenter format
# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format.
# Options are `:legacy` and `:sqlcommenter`.
#++
# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter
###
# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier`
# instances.
#
# The legacy default is `:marshal`, which is a potential vector for
# deserialization attacks in cases where a message signing secret has been
# leaked.
#
# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and
# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing
# with `Marshal` so that legacy messages can still be read.
#
# In Rails 7.2, the default will become `:json` which serializes and
# deserializes with `ActiveSupport::JSON` only.
#
# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`,
# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack`
# can roundtrip some Ruby types that are not supported by JSON, and may provide
# improved performance, but it requires the `msgpack` gem.
#
# For more information, see
# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer
#
# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers
# that have not yet been upgraded must be able to read messages from upgraded
# servers, first deploy without changing the serializer, then set the serializer
# in a subsequent deploy.
#++
# Rails.application.config.active_support.message_serializer = :json_allow_marshal
###
# Enable a performance optimization that serializes message data and metadata
# together. This changes the message format, so messages serialized this way
# cannot be read by older versions of Rails. However, messages that use the old
# format can still be read, regardless of whether this optimization is enabled.
#
# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have
# not yet been upgraded must be able to read messages from upgraded servers,
# leave this optimization off on the first deploy, then enable it on a
# subsequent deploy.
#++
# Rails.application.config.active_support.use_message_serializer_for_metadata = true
###
# Set the maximum size for Rails log files.
#
# `config.load_defaults 7.1` does not set this value for environments other than
# development and test.
#++
# if Rails.env.local?
# Rails.application.config.log_file_size = 100 * 1024 * 1024
# end
###
# Enable raising on assignment to attr_readonly attributes. The previous
# behavior would allow assignment but silently not persist changes to the
# database.
#++
# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true
###
# Enable validating only parent-related columns for presence when the parent is mandatory.
# The previous behavior was to validate the presence of the parent record, which performed an extra query
# to get the parent every time the child record was updated, even when parent has not changed.
#++
# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false
###
# Enable precompilation of `config.filter_parameters`. Precompilation can
# improve filtering performance, depending on the quantity and types of filters.
#++
# Rails.application.config.precompile_filter_parameters = true
###
# Enable before_committed! callbacks on all enrolled records in a transaction.
# The previous behavior was to only run the callbacks on the first copy of a record
# if there were multiple copies of the same record enrolled in the transaction.
#++
# Rails.application.config.active_record.before_committed_on_all_records = true
###
# Disable automatic column serialization into YAML.
# To keep the historic behavior, you can set it to `YAML`, however it is
# recommended to explicitly define the serialization method for each column
# rather than to rely on a global default.
#++
# Rails.application.config.active_record.default_column_serializer = nil
###
# Enable a performance optimization that serializes Active Record models
# in a faster and more compact way.
#
# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have
# not yet been upgraded must be able to read caches from upgraded servers,
# leave this optimization off on the first deploy, then enable it on a
# subsequent deploy.
#++
# Rails.application.config.active_record.marshalling_format_version = 7.1
###
# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model.
# This matches the behaviour of all other callbacks.
# In previous versions of Rails, they ran in the inverse order.
#++
# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true
###
# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`.
#++
# Rails.application.config.active_record.commit_transaction_on_non_local_return = true
###
# Controls when to generate a value for <tt>has_secure_token</tt> declarations.
#++
# Rails.application.config.active_record.generate_secure_token_on = :initialize
###
# ** Please read carefully, this must be configured in config/application.rb **
#
# Change the format of the cache entry.
#
# Changing this default means that all new cache entries added to the cache
# will have a different format that is not supported by Rails 7.0
# applications.
#
# Only change this value after your application is fully deployed to Rails 7.1
# and you have no plans to rollback.
# When you're ready to change format, add this to `config/application.rb` (NOT
# this file):
# config.active_support.cache_format_version = 7.1
###
# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your
# platform.
#
# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant
# sanitizers if they are supported, else fall back to HTML4 sanitizers.
#
# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor.
#++
# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
###
# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your
# platform.
#
# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant
# sanitizers if they are supported, else fall back to HTML4 sanitizers.
#
# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor.
#++
# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
###
# Configure the log level used by the DebugExceptions middleware when logging
# uncaught exceptions during requests.
#++
# Rails.application.config.action_dispatch.debug_exception_log_level = :error
###
# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5
# parsers.
#
# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4.
#
# In previous versions of Rails, these test helpers always used an HTML4 parser.
#++
# Rails.application.config.dom_testing_default_html_version = :html5

View file

@ -0,0 +1,70 @@
# Be sure to restart your server when you modify this file.
#
# This file eases your Rails 7.2 framework defaults upgrade.
#
# Uncomment each configuration one by one to switch to the new default.
# Once your application is ready to run with all new defaults, you can remove
# this file and set the `config.load_defaults` to `7.2`.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
###
# Controls whether Active Job's `#perform_later` and similar methods automatically defer
# the job queuing to after the current Active Record transaction is committed.
#
# Example:
# Topic.transaction do
# topic = Topic.create(...)
# NewTopicNotificationJob.perform_later(topic)
# end
#
# In this example, if the configuration is set to `:never`, the job will
# be enqueued immediately, even though the `Topic` hasn't been committed yet.
# Because of this, if the job is picked up almost immediately, or if the
# transaction doesn't succeed for some reason, the job will fail to find this
# topic in the database.
#
# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter
# will define the behaviour.
#
# Note: Active Job backends can disable this feature. This is generally done by
# backends that use the same database as Active Record as a queue, hence they
# don't need this feature.
#++
# Rails.application.config.active_job.enqueue_after_transaction_commit = :default
###
# Adds image/webp to the list of content types Active Storage considers as an image
# Prevents automatic conversion to a fallback PNG, and assumes clients support WebP, as they support gif, jpeg, and png.
# This is possible due to broad browser support for WebP, but older browsers and email clients may still not support
# WebP. Requires imagemagick/libvips built with WebP support.
#++
# Rails.application.config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif image/webp]
###
# Enable validation of migration timestamps. When set, an ActiveRecord::InvalidMigrationTimestampError
# will be raised if the timestamp prefix for a migration is more than a day ahead of the timestamp
# associated with the current time. This is done to prevent forward-dating of migration files, which can
# impact migration generation and other migration commands.
#
# Applications with existing timestamped migrations that do not adhere to the
# expected format can disable validation by setting this config to `false`.
#++
# Rails.application.config.active_record.validate_migration_timestamps = true
###
# Controls whether the PostgresqlAdapter should decode dates automatically with manual queries.
#
# Example:
# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.select_value("select '2024-01-01'::date") #=> Date
#
# This query used to return a `String`.
#++
# Rails.application.config.active_record.postgresql_adapter_decode_dates = true
###
# Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are
# deploying to a memory constrained environment you may want to set this to `false`.
#++
# Rails.application.config.yjit = true

View file

@ -1,11 +1,13 @@
# Be sure to restart your server when you modify this file.
# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
# Rails.application.config.permissions_policy do |f|
# f.camera :none
# f.gyroscope :none
# f.microphone :none
# f.usb :none
# f.fullscreen :self
# f.payment :self, "https://secure.example.com"
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
# Rails.application.config.permissions_policy do |policy|
# policy.camera :none
# policy.gyroscope :none
# policy.microphone :none
# policy.usb :none
# policy.fullscreen :self
# policy.payment :self, "https://secure.example.com"
# end

View file

@ -3358,6 +3358,7 @@ en:
title: 'Change your profile photo'
upload_button: 'Upload a photo'
option_text_html: 'or<br>Select your avatar below'
avatar_total_size: 'Your avatar file cannot be larger than ${size} MB. (Please try again with a smaller file.)'
name_label: "Full name"
name_title: "Change name"
initials_label: "Initials"

View file

@ -1,71 +1,34 @@
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
# 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.
# Puma starts a configurable number of processes (workers) and each process
# serves each request in a thread from an internal thread pool.
#
# The ideal number of threads per worker depends both on how much time the
# application spends waiting for IO operations and on how much you wish to
# to prioritize throughput over latency.
#
# As a rule of thumb, increasing the number of threads will increase how much
# traffic a given process can handle (throughput), but due to CRuby's
# Global VM Lock (GVL) it has diminishing returns and will degrade the
# response time (latency) of the application.
#
# The default is set to 3 threads as it's deemed a decent compromise between
# throughput and latency for the average Rails application.
#
# Any libraries that use a connection pool or another resource pool should
# be configured to provide at least as many connections as the number of
# threads. This includes Active Record's `pool` parameter in `database.yml`.
threads_count = ENV.fetch("MAX_THREADS", 3)
threads threads_count, threads_count
preload_app!
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
# threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
# threads threads_count, threads_count
#
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
# port ENV.fetch("PORT") { 3000 }
#
# Specifies the `environment` that Puma will run in.
#
# environment ENV.fetch("RAILS_ENV") { "development" }
port ENV.fetch("PORT", 3000)
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
# If you are preloading your application and using Active Record, it's
# recommended that you close any connections to the database before workers
# are forked to prevent connection leakage.
#
# before_fork do
# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
# end
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted, this block will be run. If you are using the `preload_app!`
# option, you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, as Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
#
# Allow puma to be restarted by `rails restart` command.
# plugin :tmp_restart
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]

View file

@ -1,70 +0,0 @@
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rails secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
# Shared secrets are available across all environments.
# shared:
# api_key: a1B2c3D4e5F6
# Environmental secrets are only available for that specific environment.
# Be sure to restart your server when you modify this file.
common: &common
# ======================================================================
# Mailer configuration to define from which SMTP server to send
# e-mails.
# ======================================================================
mailer_from: <%= ENV["MAIL_FROM"] %>
mailer_reply_to: <%= ENV["MAIL_REPLYTO"] %>
mailer_address: <%= ENV["SMTP_ADDRESS"] %>
mailer_port: <%= ENV["SMTP_PORT"] || "587" %>
mailer_authentication: <%= ENV["SMTP_AUTH_METHOD"] || "plain" %>
mailer_domain: <%= ENV["SMTP_DOMAIN"] %>
mailer_user_name: <%= ENV["SMTP_USERNAME"] %>
mailer_password: <%= ENV["SMTP_PASSWORD"] %>
mailer_openssl_verify_mode: <%= ENV["SMTP_OPENSSL_VERIFY_MODE"] || "peer" %>
mailer_openssl_ca_path: <%= ENV["SMTP_OPENSSL_CA_PATH"] || "/etc/ssl/certs" %>
mailer_openssl_ca_file: <%= ENV["SMTP_OPENSSL_CA_FILE"] || "/etc/ssl/certs/ca-certificates.crt" %>
# ======================================================================
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# ======================================================================
# secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
# ======================================================================
# Write any potential environment-specific secrets here.
# ======================================================================
development:
secret_key_base: 22f2adf8f5cb73351da28f2292daa840cc2a414ae00ae605b175a8d5c73932f7e5b8ff8ef8f1554a7f1064f9869b15347f7709f0daa6ccb24c50f3cace304f64
export_all_limit_24h: <%= ENV['EXPORT_ALL_LIMIT_24_HOURS'] %>
<<: *common
test:
secret_key_base: f3719934e04fa8871cf5d33d5c60f05e1b8995e0315265aef9f8b878da49bd2d386eb25ce35545b469a94ccf22f91e0052b93a15194b4f57b0c8d6ce8b150e1e
export_all_limit_24h: '3'
<<: *common
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
export_all_limit_24h: <%= ENV['EXPORT_ALL_LIMIT_24_HOURS'] %>
<<: *common

View file

@ -7,26 +7,11 @@ class AddProjectReferenceToActivity < ActiveRecord::Migration[4.2]
add_reference :activities, :project, index: true
add_foreign_key :activities, :projects
# Update existing entries so they all have project reference
Activity.all.each do |activity|
if activity.present? and
activity.my_module.present? and
activity.my_module.project.present? then
activity.project = activity.my_module.project
activity.save
end
end
# Make project reference non-nullable
change_column_null :activities, :project_id, false
end
def down
# Unfortunately, all activities that are bound to project
# need to be deleted since they're not "compatible" in the previous
# version of the DB
Activity.destroy_all(my_module: nil)
remove_foreign_key :activities, :projects
remove_reference :activities, :project, index: true
change_column_null :activities, :my_module_id, false

View file

@ -1,7 +1,6 @@
class AddEmptyFieldToAsset < ActiveRecord::Migration[4.2]
def up
add_column :assets, :file_present, :boolean, default: false
Asset.update_all(file_present: true)
change_column_null :assets, :file_present, false
end

View file

@ -56,19 +56,6 @@ class CreateProtocols < ActiveRecord::Migration[4.2]
add_foreign_key :steps, :protocols, column: :protocol_id
add_index :steps, :protocol_id
MyModule.find_each do |my_module|
protocol = Protocol.new(
my_module_id: my_module.id,
team_id: my_module.project.team.id,
protocol_type: 0
)
protocol.save(validate: false)
Step.where(my_module_id: my_module.id).find_each do |step|
step.update_column(:protocol_id, protocol.id)
end
end
remove_index :steps, column: :my_module_id
remove_foreign_key :steps, :my_modules
remove_column :steps, :my_module_id
@ -80,15 +67,6 @@ class CreateProtocols < ActiveRecord::Migration[4.2]
add_foreign_key :steps, :my_modules
add_index :steps, :my_module_id
MyModule.find_each do |my_module|
protocol = Protocol.where(my_module_id: my_module.id).first
if protocol.present?
Step.where(protocol_id: protocol.id).find_each do |step|
step.update_column(:my_module_id, my_module.id)
end
end
end
remove_index :steps, column: :protocol_id
remove_foreign_key :steps, :protocols
remove_column :steps, :protocol_id

View file

@ -1,12 +1,6 @@
class AddCounterCacheToProtocols < ActiveRecord::Migration[4.2]
def up
add_column :protocols, :nr_of_synced_children, :integer, default: 0
# Okay, now initialize the values of synced children
Protocol.find_each do |protocol|
children_count = select_value("SELECT COUNT(*) FROM protocols WHERE parent_id=#{protocol.id};")
protocol.update(nr_of_synced_children: children_count)
end
end
def down

View file

@ -1,9 +1,4 @@
class RemoveKeywordsFromModuleProtocols < ActiveRecord::Migration[4.2]
def up
Protocol.find_each do |p|
if p.in_module? then
p.protocol_keywords.destroy_all
end
end
end
end

View file

@ -1,11 +1,4 @@
class UpdateMyModuleCoordinate < ActiveRecord::Migration[4.2]
def change
MyModule.find_each do |my_module|
x = my_module.x
y = my_module.y
x *= 32
y *= 16
my_module.update(x: x, y: y)
end
end
end

View file

@ -5,25 +5,5 @@ class AddTeamIdToAssetAndTables < ActiveRecord::Migration[4.2]
add_column :tables, :team_id, :integer
add_index :tables, :team_id
Asset.find_each do |asset|
if asset.result
asset.update_columns(
team_id: asset.result.my_module.experiment.project.team_id
)
elsif asset.step
asset.update_columns(team_id: asset.step.protocol.team_id)
end
end
Table.find_each do |table|
if table.result
table.update_columns(
team_id: table.result.my_module.experiment.project.team_id
)
elsif table.step
table.update_columns(team_id: table.step.protocol.team_id)
end
end
end
end

View file

@ -1,10 +1,6 @@
class AddTeamIdToReports < ActiveRecord::Migration[5.1]
def up
add_reference :reports, :team, index: true
Report.preload(:project).find_each do |report|
team_id = report.project.team_id
report.update_column(:team_id, team_id)
end
end
def down

View file

@ -1,103 +1,10 @@
# frozen_string_literal: true
class ConvertToActiveStorage < ActiveRecord::Migration[5.2]
require 'open-uri'
ID_PARTITION_LIMIT = 1_000_000_000
DIGEST = OpenSSL::Digest.const_get('SHA1').new
MODELS = [Asset, TempFile, TinyMceAsset, User, ZipExport].freeze
def up
ActiveRecord::Base.connection.raw_connection.prepare('active_storage_blob_statement', <<-SQL)
INSERT INTO active_storage_blobs (
key, filename, content_type, metadata, byte_size, checksum, created_at
) VALUES ($1, $2, $3, '{}', $4, $5, $6)
RETURNING id;
SQL
ActiveRecord::Base.connection.raw_connection.prepare('active_storage_attachment_statement', <<-SQL)
INSERT INTO active_storage_attachments (
name, record_type, record_id, blob_id, created_at
) VALUES ($1, $2, $3, $4, $5)
SQL
transaction do
MODELS.each do |model|
next unless ActiveRecord::Base.connection.table_exists?(model.table_name)
attachments = model.column_names.map do |c|
$1 if c =~ /(.+)_file_name$/
end.compact
next if attachments.blank?
model.find_each.each do |instance|
attachments.each do |attachment|
next if instance.__send__("#{attachment}_file_name").blank?
res = ActiveRecord::Base.connection.raw_connection.exec_prepared(
'active_storage_blob_statement', [
key(instance, attachment),
instance.__send__("#{attachment}_file_name"),
instance.__send__("#{attachment}_content_type"),
instance.__send__("#{attachment}_file_size") || 0,
checksum(attachment),
instance.updated_at.iso8601
]
)
ActiveRecord::Base.connection.raw_connection.exec_prepared(
'active_storage_attachment_statement', [
attachment,
model.name,
instance.id,
res[0]['id'],
instance.updated_at.iso8601
]
)
end
end
end
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
private
ID_PARTITION_LIMIT = 1_000_000_000
DIGEST = OpenSSL::Digest.const_get('SHA1').new
def id_partition(id)
if id < ID_PARTITION_LIMIT
format('%09d', id).scan(/\d{3}/).join('/')
else
format('%012d', id).scan(/\d{3}/).join('/')
end
end
def hash_data(instance, attachment)
"#{instance.class.to_s.underscore.pluralize}/#{attachment.pluralize}/#{instance.id}/original"
end
def interpolate(pattern, instance, attachment)
path = pattern
path = path.gsub(':class', instance.class.to_s.underscore.pluralize)
path = path.gsub(':attachment', attachment.pluralize)
path = path.gsub(':id_partition', id_partition(instance.id))
path = path.gsub(':hash', OpenSSL::HMAC.hexdigest(DIGEST,
ENV['PAPERCLIP_HASH_SECRET'],
hash_data(instance, attachment)))
path.gsub(':filename', instance.__send__("#{attachment}_file_name"))
end
def key(instance, attachment)
interpolate(':class/:attachment/:id_partition/:hash/original/:filename', instance, attachment)
end
def checksum(_attachment)
'dummy'
end
end

View file

@ -2,28 +2,5 @@
class FixLabelTemplate < ActiveRecord::Migration[6.1]
def change
# rubocop:disable Rails/SkipsModelValidations
LabelTemplate.last.update_columns(
name: 'SciNote Item',
size: '1" x 0.5" / 25.4mm x 12.7mm',
language_type: :zpl,
default: true,
content:
<<~HEREDOC
^XA
^MTT
^MUD,300,300
^PR2
^MD30
^LH20,20
^PW310
^CF0,23
^FO0,0^FD{{item_id}}^FS
^FO0,20^BQN,2,4^FDMA,{{item_id}}^FS
^FO95,30^FB180,4,0,L^FD{{item_name}}^FS^FS
^XZ
HEREDOC
)
# rubocop:enable Rails/SkipsModelValidations
end
end

View file

@ -10,31 +10,6 @@ class UpdateLabelTemplates < ActiveRecord::Migration[6.1]
t.remove :language_type
t.remove :size
end
LabelTemplate.reset_column_information
# Remove our original default template
LabelTemplate.order(created_at: :asc).find_by(default: true)&.destroy
Team.find_each do |team|
FluicsLabelTemplate.create!(
name: I18n.t('label_templates.default_fluics_name'),
width_mm: 25.4,
height_mm: 12.7,
content: Extends::DEFAULT_LABEL_TEMPLATE[:zpl],
team: team,
default: true
)
ZebraLabelTemplate.create!(
name: I18n.t('label_templates.default_zebra_name'),
width_mm: 25.4,
height_mm: 12.7,
content: Extends::DEFAULT_LABEL_TEMPLATE[:zpl],
team: team,
default: true
)
end
end
def down

View file

@ -1,20 +1,22 @@
# frozen_string_literal: true
class CustomI18nBackend < I18n::Backend::Simple
attr_accessor :date_format
module I18n
class CustomI18nBackend < Backend::Simple
attr_accessor :date_format
# Gets I18n configuration object.
def date_format
Thread.current[:i18n_date_format] ||= Constants::DEFAULT_DATE_FORMAT
end
# Gets I18n configuration object.
def date_format
Thread.current[:i18n_date_format] ||= Constants::DEFAULT_DATE_FORMAT
end
# Sets I18n configuration object.
def date_format=(value)
Thread.current[:i18n_date_format] = value
end
# Sets I18n configuration object.
def date_format=(value)
Thread.current[:i18n_date_format] = value
end
def localize(locale, object, format = :default, options = {})
options[:date_format] ||= date_format
super(locale, object, format, options)
def localize(locale, object, format = :default, options = {})
options[:date_format] ||= date_format
super(locale, object, format, options)
end
end
end

View file

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>Your browser is not supported (406)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
.rails-default-error-page {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
.rails-default-error-page div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
.rails-default-error-page div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
.rails-default-error-page h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
.rails-default-error-page div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body class="rails-default-error-page">
<!-- This file lives in public/406-unsupported-browser.html -->
<div class="dialog">
<div>
<h1>Your browser is not supported.</h1>
<p>Please upgrade your browser to continue.</p>
</div>
</div>
</body>
</html>

View file

@ -134,7 +134,6 @@ describe AccessPermissions::ProjectsController, type: :controller do
end
it 'creates new project user and user assignment' do
Delayed::Worker.delay_jobs = false
dj_worker = Delayed::Worker.new
post :create, params: valid_params, format: :json
Delayed::Job.all.each { |job| dj_worker.run(job) }

View file

@ -53,7 +53,6 @@ describe ReportElement, type: :model do
describe 'Validations' do
it { should validate_presence_of :position }
it { should validate_presence_of :report }
it { should validate_presence_of :type_of }
end
end

View file

@ -33,8 +33,6 @@ describe Report, type: :model do
end
describe 'Validations' do
it { should validate_presence_of :project }
it { should validate_presence_of :user }
it do
should validate_length_of(:description)
.is_at_most(Constants::TEXT_MAX_LENGTH)

View file

@ -8,6 +8,7 @@ ENV['RAILS_ENV'] = 'test'
ENV['CORE_API_V1_ENABLED'] = 'true'
ENV['CORE_API_V2_ENABLED'] = 'true'
ENV['EXPORT_ALL_LIMIT_24_HOURS'] = '3'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
@ -32,15 +33,12 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Checks for pending migration
begin
ActiveRecord::Migration.check_pending!
ActiveRecord::Migration.check_all_pending!
rescue ActiveRecord::PendingMigrationError => e
abort(e.message)
end
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)

View file

@ -65,6 +65,7 @@ RSpec.describe 'Api::V2::ResultElements::AssetsController', type: :request do
context 'when has valid params' do
it 'renders 200' do
hash_body = nil
result_asset.asset.reload
get api_v2_team_project_experiment_task_result_asset_path(
team_id: team.id,
project_id: project.id,

View file

@ -27,7 +27,6 @@ describe Activities::ActivityFilterMatchingService do
)
activity.update_column(:created_at, Date.parse("2021-1-4").to_time)
p activity
matched_activity_filters = Activities::ActivityFilterMatchingService.new(activity).activity_filters
expect(matched_activity_filters).to include(matching_filter)

View file

@ -16,9 +16,9 @@ describe ProtocolImporters::ProtocolIntermediateObject do
end
before do
Delayed::Worker.delay_jobs = true
stub_request(:get, 'https://pbs.twimg.com/media/Cwu3zrZWQAA7axs.jpg').to_return(status: 200, body: '', headers: {})
stub_request(:get, 'http://something.com/wp-content/uploads/2014/11/14506718045_5b3e71dacd_o.jpg')
.to_return(status: 200, body: '', headers: {})
end
describe '.build' do
@ -40,7 +40,7 @@ describe ProtocolImporters::ProtocolIntermediateObject do
context 'when build wihout assets' do
it { expect { pio_without_assets.import }.to change { Protocol.all.count }.by(1) }
it { expect { invalid_pio.import }.not_to(change { Asset.all.count }) }
it { expect { pio_without_assets.import }.not_to(change { Asset.all.count }) }
end
end