diff --git a/.circleci/config.yml b/.circleci/config.yml
index 79198f40dc..7051d643e7 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -8,7 +8,7 @@ defaults: &defaults
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
docker:
# List of image tags: https://circleci.com/developer/images/image/cimg/ruby#image-tags
- - image: cimg/ruby:2.6.10-browsers
+ - image: cimg/ruby:3.1.4-browsers
environment:
PGHOST: 127.0.0.1
PGUSER: circleci
@@ -53,18 +53,26 @@ jobs:
- v1-dep-main-
- v1-dep-
- run:
- name: Update to Node v16.14.2
+ name: Swap node versions
command: |
- curl -sSL "https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-x64.tar.xz" | sudo tar --strip-components=2 -xJ -C /usr/local/bin/ node-v16.14.2-linux-x64/bin/node
- curl https://www.npmjs.com/install.sh | sudo bash
+ set +e
+ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
+ export NVM_DIR="$HOME/.nvm"
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
+ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
+ nvm install v16.14
+ nvm alias default 16.14
+
+ echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
+ echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
- run: gem install bundler
- run: bundle install --path=vendor/bundle --jobs=4 --retry=3
- run: yarn install --cache-folder ~/.cache/yarn
- run:
name: Setup Chrome
command: |
- sudo apt-get update
- sudo apt-get install libu2f-udev
+ wget http://archive.ubuntu.com/ubuntu/pool/main/libu/libu2f-host/libu2f-udev_1.1.4-1_all.deb
+ sudo dpkg -i libu2f-udev_1.1.4-1_all.deb
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i ./google-chrome*.deb
sudo apt-get install
@@ -75,6 +83,11 @@ jobs:
- ./node_modules
- ./vendor/bundle
- run: dockerize -wait tcp://localhost:5432 -timeout 1m
+ - run:
+ name: Download libssl1.1
+ command: |
+ wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.17_amd64.deb
+ sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.17_amd64.deb
- run:
command: bundle exec rake db:create db:schema:load --trace
environment:
@@ -82,20 +95,13 @@ jobs:
RACK_ENV: test
- run: RAILS_ENV=test bundle exec rake db:create db:schema:load
- run: RAILS_ENV=test bundle exec rake react_on_rails:locale
+ - run: RAILS_ENV=test bundle exec rails assets:precompile
- run:
name: Run React Jest Tests
command: |
set -e
(cd client && yarn lint:flow && yarn lint:eslint && yarn test:circleci)
(cd client && ../tmp/cc-test-reporter format-coverage -t lcov -o ../tmp/codeclimate.frontend.json coverage/lcov.info)
- - run:
- name: Run YAML linter
- command: |
- set -e
- curl https://bootstrap.pypa.io/pip/3.5/get-pip.py -o get-pip.py
- python3 get-pip.py --user
- python3 -m pip install --user yamllint
- cd config && yamllint locales/
- persist_to_workspace:
root: tmp
paths:
diff --git a/.ruby-version b/.ruby-version
index a04abec914..0aec50e6ed 100644
--- a/.ruby-version
+++ b/.ruby-version
@@ -1 +1 @@
-2.6.10
+3.1.4
diff --git a/Dockerfile b/Dockerfile
index a0ba5094f0..323a147b27 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM ruby:2.6.10
+FROM ruby:3.1.4
RUN apt-get update -qq && \
apt-get install -y build-essential cmake git tzdata libpq-dev ruby-dev curl
diff --git a/Gemfile b/Gemfile
index ca10fa3474..b7cefd0147 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,11 +1,11 @@
# frozen_string_literal: true
source 'https://rubygems.org'
-ruby '~> 2.6.10'
+ruby '~> 3.1.4'
-gem 'puma'
+gem 'puma', '5.6.4' # Latest capybara doesn't work with puma 6.0 at the moment.
gem 'rack-rewrite'
-gem 'rails', '~> 6.0.4.8'
+gem 'rails', '~> 7.0.4.3'
gem 'activerecord-import'
gem 'bcrypt', '3.1.13'
@@ -28,8 +28,7 @@ gem 'uglifier', '~> 4.1.20'
gem 'carrierwave', '~> 1.3.1'
gem 'certified', '1.0.0'
gem 'chronic', '0.10.2'
-gem 'cloudinary', '~> 1.21.0'
-gem 'figaro', '1.1.1'
+gem 'cloudinary', '~> 1.25.0'
gem 'google-api-client', '~> 0.53.0'
gem 'kaminari', '1.2.1'
gem 'omniauth', '~> 2.0'
@@ -38,7 +37,7 @@ gem 'omniauth-google-oauth2', '~> 1.0.1'
gem 'omniauth-rails_csrf_protection', '~> 1.0.1'
gem 'premailer-rails'
gem 'pusher', '1.3.3'
-gem 'rails-i18n', '~> 6.0.0'
+gem 'rails-i18n', '~> 7.0.5'
gem 'friendly_id', '~> 5.2.5'
gem 'sdoc', '1.0.0', group: :doc
@@ -46,19 +45,21 @@ gem 'sdoc', '1.0.0', group: :doc
gem 'font-awesome-sass'
gem 'inline_svg'
-gem 'groupdate', '4.1.2'
+gem 'groupdate', '~> 6.1'
gem 'react_on_rails', '12.0.1'
-gem 'webpacker', '5.1.1'
+gem 'webpacker'
gem 'selenium-webdriver', '~> 4.1.0'
gem 'rubyzip', '~> 1.3.0'
-gem 'sidekiq', '6.4.0'
+gem 'sidekiq'
gem 'sidekiq-middleware'
gem 'sidekiq-failures'
gem "sidekiq-cron", "~> 1.1"
+gem 'net-smtp', require: false # this is a rails 6 fix and will go away soon.
+gem "sprockets-rails"
group :development, :test do
gem 'bundler-audit'
@@ -66,7 +67,7 @@ group :development, :test do
gem 'spring'
- gem 'annotate', '~> 2.7'
+ gem 'annotate', '~> 3.2.0'
gem 'railroady', '1.5.3'
gem 'rails-erd', '~> 1.6'
@@ -76,7 +77,7 @@ group :development, :test do
gem 'pry-rails'
gem 'rack-mini-profiler'
- gem 'capybara', '~> 3.24.0'
+ gem 'capybara', '~> 3.37.0'
gem 'factory_bot_rails'
gem 'rspec-collection_matchers', '~> 1.1.3'
gem 'rspec-html-matchers', '~> 0.9.0'
@@ -85,7 +86,7 @@ group :development, :test do
gem 'letter_opener'
gem 'rspec_junit_formatter'
- gem 'rubocop', '~> 0.80.1'
+ gem 'rubocop'
gem 'rubocop-performance'
gem 'rubocop-rails'
gem 'rubocop-rspec'
@@ -102,8 +103,8 @@ end
group :test do
gem 'database_cleaner'
gem 'rails-controller-testing'
- gem 'shoulda-matchers'
- gem 'simplecov', '0.16.1'
+ gem 'shoulda-matchers', '~> 5.3.0'
+ gem 'simplecov', '~> 0.17.0'
end
group :production do
diff --git a/Gemfile.lock b/Gemfile.lock
index 33ce0aa55a..97974cb6b5 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,90 +1,101 @@
GEM
remote: https://rubygems.org/
specs:
- actioncable (6.0.4.8)
- actionpack (= 6.0.4.8)
+ actioncable (7.0.4.3)
+ actionpack (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
- actionmailbox (6.0.4.8)
- actionpack (= 6.0.4.8)
- activejob (= 6.0.4.8)
- activerecord (= 6.0.4.8)
- activestorage (= 6.0.4.8)
- activesupport (= 6.0.4.8)
+ actionmailbox (7.0.4.3)
+ actionpack (= 7.0.4.3)
+ activejob (= 7.0.4.3)
+ activerecord (= 7.0.4.3)
+ activestorage (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
mail (>= 2.7.1)
- actionmailer (6.0.4.8)
- actionpack (= 6.0.4.8)
- actionview (= 6.0.4.8)
- activejob (= 6.0.4.8)
+ net-imap
+ net-pop
+ net-smtp
+ actionmailer (7.0.4.3)
+ actionpack (= 7.0.4.3)
+ actionview (= 7.0.4.3)
+ activejob (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
mail (~> 2.5, >= 2.5.4)
+ net-imap
+ net-pop
+ net-smtp
rails-dom-testing (~> 2.0)
- actionpack (6.0.4.8)
- actionview (= 6.0.4.8)
- activesupport (= 6.0.4.8)
- rack (~> 2.0, >= 2.0.8)
+ actionpack (7.0.4.3)
+ actionview (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
+ rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
- actiontext (6.0.4.8)
- actionpack (= 6.0.4.8)
- activerecord (= 6.0.4.8)
- activestorage (= 6.0.4.8)
- activesupport (= 6.0.4.8)
+ actiontext (7.0.4.3)
+ actionpack (= 7.0.4.3)
+ activerecord (= 7.0.4.3)
+ activestorage (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
+ globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
- actionview (6.0.4.8)
- activesupport (= 6.0.4.8)
+ actionview (7.0.4.3)
+ activesupport (= 7.0.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
- activejob (6.0.4.8)
- activesupport (= 6.0.4.8)
+ activejob (7.0.4.3)
+ activesupport (= 7.0.4.3)
globalid (>= 0.3.6)
- activemodel (6.0.4.8)
- activesupport (= 6.0.4.8)
- activerecord (6.0.4.8)
- activemodel (= 6.0.4.8)
- activesupport (= 6.0.4.8)
- activerecord-import (1.0.6)
- activerecord (>= 3.2)
- activestorage (6.0.4.8)
- actionpack (= 6.0.4.8)
- activejob (= 6.0.4.8)
- activerecord (= 6.0.4.8)
- marcel (~> 1.0.0)
- activesupport (6.0.4.8)
+ activemodel (7.0.4.3)
+ activesupport (= 7.0.4.3)
+ activerecord (7.0.4.3)
+ activemodel (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
+ activerecord-import (1.4.1)
+ activerecord (>= 4.2)
+ activestorage (7.0.4.3)
+ actionpack (= 7.0.4.3)
+ activejob (= 7.0.4.3)
+ activerecord (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
+ marcel (~> 1.0)
+ mini_mime (>= 1.1.0)
+ activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
- i18n (>= 0.7, < 2)
- minitest (~> 5.1)
- tzinfo (~> 1.1)
- zeitwerk (~> 2.2, >= 2.2.2)
- addressable (2.8.0)
- public_suffix (>= 2.0.2, < 5.0)
- annotate (2.7.5)
- activerecord (>= 3.2, < 7.0)
- rake (>= 10.4, < 13.0)
- ast (2.4.1)
+ i18n (>= 1.6, < 2)
+ minitest (>= 5.1)
+ tzinfo (~> 2.0)
+ addressable (2.8.1)
+ public_suffix (>= 2.0.2, < 6.0)
+ annotate (3.2.0)
+ activerecord (>= 3.2, < 8.0)
+ rake (>= 10.4, < 14.0)
+ ast (2.4.2)
aws_cf_signer (0.1.3)
bcrypt (3.1.13)
- better_errors (2.8.3)
+ better_errors (2.9.1)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
builder (3.2.4)
- bullet (6.1.0)
+ bullet (7.0.3)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
- bundler-audit (0.7.0.1)
+ bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
- thor (>= 0.18, < 2)
+ thor (~> 1.0)
byebug (11.1.3)
- capybara (3.24.0)
+ capybara (3.37.1)
addressable
+ matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
- regexp_parser (~> 1.5)
+ regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
carrierwave (1.3.2)
activemodel (>= 4.0.0)
@@ -95,16 +106,21 @@ GEM
childprocess (4.1.0)
choice (0.2.0)
chronic (0.10.2)
- cloudinary (1.21.0)
+ cloudinary (1.25.0)
aws_cf_signer
rest-client (>= 2.0.0)
coderay (1.1.3)
concurrent-ruby (1.2.0)
- connection_pool (2.2.5)
+ connection_pool (2.3.0)
crass (1.0.6)
- css_parser (1.7.1)
+ css_parser (1.12.0)
addressable
- database_cleaner (1.8.5)
+ database_cleaner (2.0.2)
+ database_cleaner-active_record (>= 2, < 3)
+ database_cleaner-active_record (2.1.0)
+ activerecord (>= 5.a)
+ database_cleaner-core (~> 2.0.0)
+ database_cleaner-core (2.0.1)
declarative (0.0.20)
devise (4.8.1)
bcrypt (~> 3.0)
@@ -115,14 +131,14 @@ GEM
devise-pwned_password (0.1.9)
devise (~> 4)
pwned (~> 2.0.0)
- devise_invitable (2.0.6)
+ devise_invitable (2.0.7)
actionmailer (>= 5.0)
devise (>= 4.6)
devise_uid (0.1.1)
devise (>= 3.0.0)
railties (>= 3.0)
- diff-lcs (1.4.4)
- docile (1.3.2)
+ diff-lcs (1.5.0)
+ docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
@@ -130,34 +146,34 @@ GEM
dotenv (= 2.7.6)
railties (>= 3.2)
erubi (1.11.0)
- et-orbi (1.2.4)
+ et-orbi (1.2.7)
tzinfo
- execjs (2.7.0)
- factory_bot (6.1.0)
+ execjs (2.8.1)
+ factory_bot (6.2.1)
activesupport (>= 5.0.0)
- factory_bot_rails (6.1.0)
- factory_bot (~> 6.1.0)
+ factory_bot_rails (6.2.0)
+ factory_bot (~> 6.2.0)
railties (>= 5.0.0)
- faraday (0.17.5)
- multipart-post (>= 1.2, < 3)
+ faraday (2.6.0)
+ faraday-net_http (>= 2.0, < 3.1)
+ ruby2_keywords (>= 0.0.4)
+ faraday-net_http (3.0.1)
ffi (1.15.5)
- figaro (1.1.1)
- thor (~> 0.14)
- font-awesome-sass (5.13.0)
- sassc (>= 1.11)
+ font-awesome-sass (6.2.0)
+ sassc (~> 2.0)
foreman (0.87.2)
friendly_id (5.2.5)
activerecord (>= 4.0.0)
- fugit (1.3.9)
- et-orbi (~> 1.1, >= 1.1.8)
- raabro (~> 1.3)
+ fugit (1.7.1)
+ et-orbi (~> 1, >= 1.2.7)
+ raabro (~> 1.4)
gems (1.2.0)
globalid (1.1.0)
activesupport (>= 5.0)
google-api-client (0.53.0)
google-apis-core (~> 0.1)
google-apis-generator (~> 0.1)
- google-apis-core (0.4.2)
+ google-apis-core (0.9.1)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
@@ -166,43 +182,42 @@ GEM
retriable (>= 2.0, < 4.a)
rexml
webrick
- google-apis-discovery_v1 (0.8.0)
- google-apis-core (>= 0.4, < 2.a)
- google-apis-generator (0.4.1)
+ google-apis-discovery_v1 (0.12.0)
+ google-apis-core (>= 0.9.0, < 2.a)
+ google-apis-generator (0.11.1)
activesupport (>= 5.0)
gems (~> 1.2)
- google-apis-core (>= 0.4, < 2.a)
+ google-apis-core (>= 0.9.1, < 2.a)
google-apis-discovery_v1 (~> 0.5)
thor (>= 0.20, < 2.a)
- googleauth (1.1.3)
+ googleauth (1.3.0)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
- groupdate (4.1.2)
- activesupport (>= 4.2)
+ groupdate (6.2.0)
+ activesupport (>= 5.2)
hashie (5.0.0)
htmlentities (4.3.4)
http-accept (1.7.0)
- http-cookie (1.0.4)
+ http-cookie (1.0.5)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
- inline_svg (1.7.2)
+ inline_svg (1.8.0)
activesupport (>= 3.0)
nokogiri (>= 1.6)
- jaro_winkler (1.5.4)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
- json (2.3.1)
- jwt (2.3.0)
+ json (2.6.2)
+ jwt (2.5.0)
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
@@ -217,39 +232,47 @@ GEM
kaminari-core (1.2.1)
launchy (2.5.0)
addressable (~> 2.7)
- letter_opener (1.7.0)
- launchy (~> 2.2)
+ letter_opener (1.8.1)
+ launchy (>= 2.2, < 3)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.2)
+ matrix (0.4.2)
memoist (0.16.2)
method_source (1.0.0)
- mime-types (3.3.1)
+ mime-types (3.4.1)
mime-types-data (~> 3.2015)
- mime-types-data (3.2021.0901)
+ mime-types-data (3.2022.0105)
mini_mime (1.1.2)
- mini_portile2 (2.8.1)
minitest (5.17.0)
mono_logger (1.1.0)
multi_json (1.15.0)
multi_xml (0.6.0)
- multipart-post (2.1.1)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
+ net-imap (0.3.1)
+ net-protocol
+ net-pop (0.1.2)
+ net-protocol
+ net-protocol (0.1.3)
+ timeout
+ net-smtp (0.3.2)
+ net-protocol
netrc (0.11.0)
nio4r (2.5.8)
- nokogiri (1.13.10)
- mini_portile2 (~> 2.8.0)
+ nokogiri (1.14.3-arm64-darwin)
+ racc (~> 1.4)
+ nokogiri (1.14.3-x86_64-darwin)
racc (~> 1.4)
- oauth2 (1.4.9)
+ oauth2 (1.4.11)
faraday (>= 0.17.3, < 3.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
- rack (>= 1.2, < 3)
+ rack (>= 1.2, < 4)
omniauth (2.1.0)
hashie (>= 3.4.6)
rack (>= 2.2.3)
@@ -261,34 +284,36 @@ GEM
oauth2 (~> 1.1)
omniauth (~> 2.0)
omniauth-oauth2 (~> 1.7.1)
- omniauth-oauth2 (1.7.2)
- oauth2 (~> 1.4)
+ omniauth-oauth2 (1.7.3)
+ oauth2 (>= 1.4, < 3)
omniauth (>= 1.9, < 3)
omniauth-rails_csrf_protection (1.0.1)
actionpack (>= 4.2)
omniauth (~> 2.0)
orm_adapter (0.5.0)
os (1.1.4)
- parallel (1.19.2)
- parser (2.7.2.0)
+ parallel (1.22.1)
+ parser (3.1.2.1)
ast (~> 2.4.1)
pg (1.1.4)
- premailer (1.14.2)
+ premailer (1.18.0)
addressable
- css_parser (>= 1.6.0)
+ css_parser (>= 1.12.0)
htmlentities (>= 4.0.0)
premailer-rails (1.11.1)
actionmailer (>= 3)
premailer (~> 1.7, >= 1.7.9)
- pry (0.13.1)
+ pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
- pry-byebug (3.9.0)
+ pry-byebug (3.10.1)
byebug (~> 11.0)
- pry (~> 0.13.0)
+ pry (>= 0.13, < 0.15)
pry-rails (0.3.9)
pry (>= 0.10.4)
- public_suffix (4.0.6)
+ psych (4.0.6)
+ stringio
+ public_suffix (5.0.0)
puma (5.6.4)
nio4r (~> 2.0)
pusher (1.3.3)
@@ -304,28 +329,27 @@ GEM
rack (>= 1.2.0)
rack-protection (3.0.4)
rack
- rack-proxy (0.6.5)
+ rack-proxy (0.7.4)
rack
rack-rewrite (1.5.1)
rack-test (2.0.2)
rack (>= 1.3)
- rack-timeout (0.6.0)
+ rack-timeout (0.6.3)
railroady (1.5.3)
- rails (6.0.4.8)
- actioncable (= 6.0.4.8)
- actionmailbox (= 6.0.4.8)
- actionmailer (= 6.0.4.8)
- actionpack (= 6.0.4.8)
- actiontext (= 6.0.4.8)
- actionview (= 6.0.4.8)
- activejob (= 6.0.4.8)
- activemodel (= 6.0.4.8)
- activerecord (= 6.0.4.8)
- activestorage (= 6.0.4.8)
- activesupport (= 6.0.4.8)
- bundler (>= 1.3.0)
- railties (= 6.0.4.8)
- sprockets-rails (>= 2.0.0)
+ rails (7.0.4.3)
+ actioncable (= 7.0.4.3)
+ actionmailbox (= 7.0.4.3)
+ actionmailer (= 7.0.4.3)
+ actionpack (= 7.0.4.3)
+ actiontext (= 7.0.4.3)
+ actionview (= 7.0.4.3)
+ activejob (= 7.0.4.3)
+ activemodel (= 7.0.4.3)
+ activerecord (= 7.0.4.3)
+ activestorage (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
+ bundler (>= 1.15.0)
+ railties (= 7.0.4.3)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
@@ -333,33 +357,35 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
- rails-erd (1.6.0)
+ rails-erd (1.7.2)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.4.4)
loofah (~> 2.19, >= 2.19.1)
- rails-i18n (6.0.0)
+ rails-i18n (7.0.6)
i18n (>= 0.7, < 2)
- railties (>= 6.0.0, < 7)
+ railties (>= 6.0.0, < 8)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
- railties (6.0.4.8)
- actionpack (= 6.0.4.8)
- activesupport (= 6.0.4.8)
+ railties (7.0.4.3)
+ actionpack (= 7.0.4.3)
+ activesupport (= 7.0.4.3)
method_source
- rake (>= 0.8.7)
- thor (>= 0.20.3, < 2.0)
- rainbow (3.0.0)
- rake (12.3.3)
- rb-fsevent (0.10.4)
+ rake (>= 12.2)
+ thor (~> 1.0)
+ zeitwerk (~> 2.5)
+ rainbow (3.1.1)
+ rake (13.0.6)
+ rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
- rdoc (6.3.1)
+ rdoc (6.4.0)
+ psych (>= 4.0.0)
react_on_rails (12.0.1)
addressable
connection_pool
@@ -367,19 +393,19 @@ GEM
rails (>= 3.2)
rainbow (~> 3.0)
webpacker (>= 4.0)
- recaptcha (5.6.0)
+ recaptcha (5.12.3)
json
- redis (4.5.1)
- redis-namespace (1.8.0)
- redis (>= 3.0.4)
- regexp_parser (1.8.1)
- representable (3.1.1)
+ redis (4.8.0)
+ redis-namespace (1.9.0)
+ redis (>= 4)
+ regexp_parser (2.6.0)
+ representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
- responders (3.0.1)
- actionpack (>= 5.0)
- railties (>= 5.0)
+ responders (3.1.0)
+ actionpack (>= 5.2)
+ railties (>= 5.2)
resque (2.0.0)
mono_logger (~> 1.0)
multi_json (~> 1.0)
@@ -401,56 +427,61 @@ GEM
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.2.5)
- rspec (3.9.0)
- rspec-core (~> 3.9.0)
- rspec-expectations (~> 3.9.0)
- rspec-mocks (~> 3.9.0)
+ rspec (3.11.0)
+ rspec-core (~> 3.11.0)
+ rspec-expectations (~> 3.11.0)
+ rspec-mocks (~> 3.11.0)
rspec-collection_matchers (1.1.3)
rspec-expectations (>= 2.99.0.beta1)
- rspec-core (3.9.3)
- rspec-support (~> 3.9.3)
- rspec-expectations (3.9.2)
+ rspec-core (3.11.0)
+ rspec-support (~> 3.11.0)
+ rspec-expectations (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.9.0)
+ rspec-support (~> 3.11.0)
rspec-html-matchers (0.9.4)
nokogiri (~> 1)
rspec (>= 3.0.0.a, < 4)
- rspec-mocks (3.9.1)
+ rspec-mocks (3.11.2)
diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.9.0)
- rspec-rails (4.0.1)
+ rspec-support (~> 3.11.0)
+ rspec-rails (4.0.2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
- rspec-core (~> 3.9)
- rspec-expectations (~> 3.9)
- rspec-mocks (~> 3.9)
- rspec-support (~> 3.9)
- rspec-support (3.9.3)
- rspec_junit_formatter (0.4.1)
+ rspec-core (~> 3.10)
+ rspec-expectations (~> 3.10)
+ rspec-mocks (~> 3.10)
+ rspec-support (~> 3.10)
+ rspec-support (3.11.1)
+ rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
- rubocop (0.80.1)
- jaro_winkler (~> 1.5.1)
+ rubocop (1.37.1)
+ json (~> 2.3)
parallel (~> 1.10)
- parser (>= 2.7.0.1)
+ parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
- rexml
+ regexp_parser (>= 1.8, < 3.0)
+ rexml (>= 3.2.5, < 4.0)
+ rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
- unicode-display_width (>= 1.4.0, < 1.7)
- rubocop-performance (1.6.1)
- rubocop (>= 0.71.0)
- rubocop-rails (2.5.2)
- activesupport
+ unicode-display_width (>= 1.4.0, < 3.0)
+ rubocop-ast (1.23.0)
+ parser (>= 3.1.1.0)
+ rubocop-performance (1.15.0)
+ rubocop (>= 1.7.0, < 2.0)
+ rubocop-ast (>= 0.4.0)
+ rubocop-rails (2.17.1)
+ activesupport (>= 4.2.0)
rack (>= 1.1)
- rubocop (>= 0.72.0)
- rubocop-rspec (1.41.0)
- rubocop (>= 0.68.1)
+ rubocop (>= 1.33.0, < 2.0)
+ rubocop-rspec (2.14.2)
+ rubocop (~> 1.33)
ruby-graphviz (1.2.5)
rexml
- ruby-progressbar (1.10.1)
+ ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
rubyzip (1.3.0)
- rufus-scheduler (3.6.0)
+ rufus-scheduler (3.8.2)
fugit (~> 1.1, >= 1.1.6)
sass (3.7.4)
sass-listen (~> 4.0.0)
@@ -471,28 +502,28 @@ GEM
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2)
- semantic_range (2.3.0)
- sentry-raven (2.13.0)
- faraday (>= 0.7.6, < 1.0)
- shoulda-matchers (4.4.1)
- activesupport (>= 4.2.0)
- sidekiq (6.4.0)
- connection_pool (>= 2.2.2)
+ semantic_range (3.0.0)
+ sentry-raven (3.1.2)
+ faraday (>= 1.0)
+ shoulda-matchers (5.3.0)
+ activesupport (>= 5.2.0)
+ sidekiq (6.5.7)
+ connection_pool (>= 2.2.5)
rack (~> 2.0)
- redis (>= 4.2.0)
- sidekiq-cron (1.2.0)
- fugit (~> 1.1)
+ redis (>= 4.5.0, < 5)
+ sidekiq-cron (1.8.0)
+ fugit (~> 1)
sidekiq (>= 4.2.1)
- sidekiq-failures (1.0.0)
+ sidekiq-failures (1.0.4)
sidekiq (>= 4.0.0)
sidekiq-middleware (0.3.0)
sidekiq (>= 2.12.4)
- signet (0.16.1)
+ signet (0.17.0)
addressable (~> 2.8)
- faraday (>= 0.17.5, < 3.0)
+ faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
- simplecov (0.16.1)
+ simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
@@ -502,7 +533,7 @@ GEM
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.4)
tilt (~> 2.0)
- spring (2.1.1)
+ spring (4.1.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
@@ -510,33 +541,34 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
- ssrf_filter (1.0.7)
- thor (0.20.3)
- thread_safe (0.3.6)
+ ssrf_filter (1.1.1)
+ stringio (3.0.2)
+ thor (1.2.1)
tilt (2.0.11)
+ timeout (0.3.0)
trailblazer-option (0.1.2)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
- tzinfo (1.2.11)
- thread_safe (~> 0.1)
+ tzinfo (2.0.5)
+ concurrent-ruby (~> 1.0)
uber (0.1.0)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
- unf_ext (0.0.8)
- unicode-display_width (1.6.1)
- uniform_notifier (1.13.0)
+ unf_ext (0.0.8.2)
+ unicode-display_width (2.3.0)
+ uniform_notifier (1.16.0)
vegas (0.1.11)
rack (>= 1.0.0)
warden (1.2.9)
rack (>= 2.0.9)
- webdrivers (5.0.0)
+ webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
- webpacker (5.1.1)
+ webpacker (5.4.3)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
@@ -550,22 +582,24 @@ GEM
zeitwerk (2.6.7)
PLATFORMS
- ruby
+ arm64-darwin-21
+ arm64-darwin-22
+ x86_64-darwin-20
DEPENDENCIES
actionview
activerecord-import
- annotate (~> 2.7)
+ annotate (~> 3.2.0)
bcrypt (= 3.1.13)
better_errors (~> 2.5)
bullet
bundler-audit
byebug
- capybara (~> 3.24.0)
+ capybara (~> 3.37.0)
carrierwave (~> 1.3.1)
certified (= 1.0.0)
chronic (= 0.10.2)
- cloudinary (~> 1.21.0)
+ cloudinary (~> 1.25.0)
database_cleaner
devise (~> 4.8.1)
devise-pwned_password
@@ -573,17 +607,17 @@ DEPENDENCIES
devise_uid
dotenv-rails (~> 2.7.2)
factory_bot_rails
- figaro (= 1.1.1)
font-awesome-sass
foreman
friendly_id (~> 5.2.5)
google-api-client (~> 0.53.0)
- groupdate (= 4.1.2)
+ groupdate (~> 6.1)
inline_svg
jbuilder (~> 2.9.1)
jquery-rails (= 4.4.0)
kaminari (= 1.2.1)
letter_opener
+ net-smtp
omniauth (~> 2.0)
omniauth-facebook
omniauth-google-oauth2 (~> 1.0.1)
@@ -592,16 +626,16 @@ DEPENDENCIES
premailer-rails
pry-byebug
pry-rails
- puma
+ puma (= 5.6.4)
pusher (= 1.3.3)
rack-mini-profiler
rack-rewrite
rack-timeout
railroady (= 1.5.3)
- rails (~> 6.0.4.8)
+ rails (~> 7.0.4.3)
rails-controller-testing
rails-erd (~> 1.6)
- rails-i18n (~> 6.0.0)
+ rails-i18n (~> 7.0.5)
rails_12factor (= 0.0.3)
react_on_rails (= 12.0.1)
recaptcha
@@ -612,7 +646,7 @@ DEPENDENCIES
rspec-html-matchers (~> 0.9.0)
rspec-rails (~> 4.0.0)
rspec_junit_formatter
- rubocop (~> 0.80.1)
+ rubocop
rubocop-performance
rubocop-rails
rubocop-rspec
@@ -621,20 +655,21 @@ DEPENDENCIES
sdoc (= 1.0.0)
selenium-webdriver (~> 4.1.0)
sentry-raven
- shoulda-matchers
- sidekiq (= 6.4.0)
+ shoulda-matchers (~> 5.3.0)
+ sidekiq
sidekiq-cron (~> 1.1)
sidekiq-failures
sidekiq-middleware
- simplecov (= 0.16.1)
+ simplecov (~> 0.17.0)
spring
+ sprockets-rails
turbolinks (~> 5.2.0)
uglifier (~> 4.1.20)
webdrivers (>= 5.0.0)
- webpacker (= 5.1.1)
+ webpacker
RUBY VERSION
- ruby 2.6.10p210
+ ruby 3.1.4p223
BUNDLED WITH
- 2.3.22
+ 2.3.24
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 25387030b1..84b9846860 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -30,7 +30,6 @@
*/
@import "base/*";
-@import "font-awesome-sprockets";
@import "font-awesome";
/* Text */
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 5e992f32a3..e60aa3a4a7 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
- include ActionView::Helpers::UrlHelper
include ActionView::Helpers::DateHelper
include ActionView::Helpers::TextHelper
include PageRedirectConcern
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index dd9480804f..d793cb7325 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -26,7 +26,7 @@ def delete
def remove_meeting_notification!(comment_id)
CommentNotificationsService.remove(
comment_id: comment_id,
- model_name: 'meeting'
+ model_name: 'Meeting'
)
end
@@ -46,7 +46,7 @@ def handle_create(comment_params)
end
def handle_delete(comment)
- if %w[moment strategy].include?(comment.commentable_type)
+ if %w[Moment Strategy].include?(comment.commentable_type)
raise RuntimeError unless CommentViewersService.deletable?(
comment, current_user
)
@@ -55,7 +55,7 @@ def handle_delete(comment)
comment_id: comment.id,
model_name: comment.commentable_type
)
- elsif comment.commentable_type == 'meeting'
+ elsif comment.commentable_type == 'Meeting'
meeting = Meeting.find(comment.commentable_id)
remove_meeting_notification(comment, meeting)
end
diff --git a/app/controllers/groups/memberships_controller.rb b/app/controllers/groups/memberships_controller.rb
index b5a8f8c040..b3c53f0a51 100644
--- a/app/controllers/groups/memberships_controller.rb
+++ b/app/controllers/groups/memberships_controller.rb
@@ -13,7 +13,7 @@ def create
flash[:notice] = t('groups.join.success')
redirect_to_group
- rescue NoMethodError
+ rescue
flash[:alert] = t('groups.join.group_not_exists')
redirect_to groups_path
end
diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb
index 785459bbdc..d743b10d31 100644
--- a/app/controllers/notifications_controller.rb
+++ b/app/controllers/notifications_controller.rb
@@ -10,7 +10,7 @@ def destroy
@notification.destroy if @notification.present?
respond_to do |format|
- format.html { redirect_back(fallback_location: notifications_path) }
+ format.html { redirect_back_or_to notifications_path }
format.json { head :no_content }
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 62f38bc24d..5feb208ee1 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
module ApplicationHelper
include ViewersHelper
+ include AssetsHelper
def html_options
{ class: 'htmlOptions' }
@@ -17,6 +18,34 @@ def sign_in_path?
devise_page?(new_user_session_path, 'sessions', 'new')
end
+ def page_title
+ t('app_name') +
+ if sign_in_path?
+ " | " + t('account.sign_in')
+ elsif join_path?
+ " | " + t('account.sign_up')
+ elsif forgot_password_path?
+ " | " + t('account.forgot_password')
+ elsif update_account_path?
+ " | " + t('account.singular')
+ elsif current_page?(root_path)
+ " | " + t('app_description')
+ elsif send_ally_invitation_path?
+ " | " + t('devise.invitations.new.header')
+ elsif ally_accept_invitation_path?
+ " | " + t('devise.invitations.edit.header')
+ elsif reset_password_path?
+ " | " + t('layouts.title.reset_password')
+ elsif new_user_confirmation_path?
+ " | " + t('devise.confirmations.resend_confirmation')
+ else
+ " | " + title_content
+ end
+ end
+
+ def title_content
+ content_for(:title) || 'a community for mental health experiences'
+ end
def join_path?
path = new_user_registration_path
devise_page?(path, 'registrations', 'create') ||
diff --git a/app/helpers/moments_helper.rb b/app/helpers/moments_helper.rb
index abe3e165ca..255cda9f37 100644
--- a/app/helpers/moments_helper.rb
+++ b/app/helpers/moments_helper.rb
@@ -2,6 +2,7 @@
module MomentsHelper
include ViewersHelper
include VisibleHelper
+ include ActionView::Helpers::UrlHelper
def moments_data_json
{
@@ -14,14 +15,14 @@ def moments_data_html
return unless current_user
# +1 day buffer to ensure we include today as well
- end_date = Date.current + 1.day
- start_date = end_date - 1.week
+ start_date = 1.week.ago.to_date
+ end_date = Date.tomorrow
range = start_date..end_date
@react_moments = current_user.moments
- .group_by_period('day',
- :created_at,
- range: range)
- .count
+ .where(updated_at: range)
+ .group_by_period(:day,
+ :created_at)
+ .count if current_user.moments.exists?
end
def moments_or_strategy_props(elements)
diff --git a/app/models/comment.rb b/app/models/comment.rb
index e7017b076b..1a0e4f7ffd 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -19,7 +19,7 @@ class Comment < ApplicationRecord
belongs_to :commentable, polymorphic: true
validates :comment, length: { minimum: 0, maximum: 1000 }, presence: true
- validates :commentable_type, inclusion: %w[moment strategy meeting]
+ validates :commentable_type, inclusion: %w[Moment Strategy Meeting]
validates :commentable_id, :comment_by, presence: true
validates :visibility, inclusion: %w[all private]
@@ -48,7 +48,7 @@ def create_from!(params)
def comments_from(data)
Comment.where(
commentable_id: data.id,
- commentable_type: data.class.name.downcase
+ commentable_type: data.class.name
)
end
end
@@ -56,7 +56,7 @@ def comments_from(data)
# Notify commentable_id user that they have a new comment
def notify_of_creation!(creator)
association = associated_record
- return handle_meeting(association, creator) if commentable_type == 'meeting'
+ return handle_meeting(association, creator) if commentable_type == 'Meeting'
return unless notify_of_creation?(association)
send_notification!(creator, association, user_to_notify(association))
diff --git a/app/models/meeting_member.rb b/app/models/meeting_member.rb
index 069c88dcf9..d71ca4cd0e 100644
--- a/app/models/meeting_member.rb
+++ b/app/models/meeting_member.rb
@@ -27,5 +27,5 @@ class MeetingMember < ApplicationRecord
belongs_to :meeting, foreign_key: :meeting_id
belongs_to :user, foreign_key: :user_id
- belongs_to :group_member, foreign_key: :user_id
+ belongs_to :group_member, foreign_key: :user_id, optional: true
end
diff --git a/app/models/report.rb b/app/models/report.rb
index 932345e72a..de8e60a050 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -15,7 +15,7 @@
class Report < ApplicationRecord
belongs_to :reporter, class_name: 'User'
belongs_to :reportee, class_name: 'User'
- belongs_to :comment, class_name: 'Comment'
+ belongs_to :comment, class_name: 'Comment', optional: true
validates :reportee_id, presence: true
validates :reporter_id, presence: true
validates :reasons, presence: true
diff --git a/app/models/user.rb b/app/models/user.rb
index 846c31ada2..cf252e6bf3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -111,7 +111,7 @@ class User < ApplicationRecord
# rubocop:disable Layout/LineLength
has_many :data_requests, class_name: 'Users::DataRequest', foreign_key: :user_id
# rubocop:enable Layout/LineLength
- belongs_to :invited_by, class_name: 'User'
+ belongs_to :invited_by, class_name: 'User', optional: true
after_initialize :set_defaults, unless: :persisted?
before_save :remove_leading_trailing_whitespace
@@ -207,11 +207,13 @@ def generate_data_request
data_request = data_requests
.where(status_id: Users::DataRequest::STATUS[:enqueued])
.first_or_initialize
- return data_request.request_id if data_request.request_id.present?
-
- data_request.request_id = SecureRandom.uuid
- data_request.save!
- return data_request.request_id
+ if data_request.request_id.present?
+ data_request.request_id
+ else
+ data_request.request_id = SecureRandom.uuid
+ data_request.save!
+ end
+ data_request.request_id
end
end
diff --git a/app/services/comment_notifications_service.rb b/app/services/comment_notifications_service.rb
index 80e7801e43..8e615d2c72 100644
--- a/app/services/comment_notifications_service.rb
+++ b/app/services/comment_notifications_service.rb
@@ -8,8 +8,8 @@ def initialize(comment_id:, model_name:)
@model_name = model_name
end
- def self.remove(args = {})
- new(args).remove
+ def self.remove(**args)
+ new(**args).remove
end
def remove
diff --git a/app/services/medium.rb b/app/services/medium.rb
index ca2e984fd4..9d41e96898 100644
--- a/app/services/medium.rb
+++ b/app/services/medium.rb
@@ -16,7 +16,7 @@ def content_hash
def content
content = ''
- open('https://medium.com/ifme?format=json') do |file|
+ URI.open('https://medium.com/ifme?format=json') do |file|
file.each_line { |line| content += line }
end
content
diff --git a/app/services/meeting_notifications_service.rb b/app/services/meeting_notifications_service.rb
index 844d3337cd..d296736ccb 100644
--- a/app/services/meeting_notifications_service.rb
+++ b/app/services/meeting_notifications_service.rb
@@ -10,8 +10,8 @@ def initialize(current_user:, meeting:, type:, members:)
@uniqueid = "#{type}_#{current_user.id}"
end
- def self.handle_members(args = {})
- new(args).handle_members
+ def self.handle_members(**args)
+ new(**args).handle_members
end
def handle_members
diff --git a/app/views/groups/index.html.erb b/app/views/groups/index.html.erb
index 78ca0cf5a9..07cdb682c7 100644
--- a/app/views/groups/index.html.erb
+++ b/app/views/groups/index.html.erb
@@ -41,9 +41,9 @@
<%= t('pages.faq.group_question') %>
- <%= raw t('pages.faq.group_answer', {
+ <%= raw t('pages.faq.group_answer',
group: t('groups.singular')
- }) %>
+ ) %>
<% end %>
diff --git a/app/views/layouts/_title.html.erb b/app/views/layouts/_title.html.erb
deleted file mode 100644
index 6cbddb7943..0000000000
--- a/app/views/layouts/_title.html.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-<%= t('app_name') %>
-<% if sign_in_path? %>
- | <%= t('account.sign_in') %>
-<% elsif join_path? %>
- | <%= t('account.sign_up') %>
-<% elsif forgot_password_path? %>
- | <%= t('account.forgot_password') %>
-<% elsif update_account_path? %>
- | <%= t('account.singular') %>
-<% elsif current_page?(root_path) %>
- | <%= t('app_description') %>
-<% elsif send_ally_invitation_path? %>
- | <%= t('devise.invitations.new.header') %>
-<% elsif ally_accept_invitation_path? %>
- | <%= t('devise.invitations.edit.header') %>
-<% elsif reset_password_path? %>
- | <%= t('layouts.title.reset_password') %>
-<% elsif new_user_confirmation_path? %>
- | <%= t('devise.confirmations.resend_confirmation') %>
-<% else %>
- | <%= yield(:title) %>
-<% end %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 3cb3f70de5..9ef6923d8c 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
- <%= render 'layouts/title' %>
+ <%= page_title %>
diff --git a/app/views/pages/_contributor_blurb.html.erb b/app/views/pages/_contributor_blurb.html.erb
index 25ab058e59..6dd4ab768d 100644
--- a/app/views/pages/_contributor_blurb.html.erb
+++ b/app/views/pages/_contributor_blurb.html.erb
@@ -4,9 +4,9 @@
component: 'Avatar',
props: {
src: ProfilePicture.normalize_url(contributor_blurb["image"]),
- alt: t('pages.contribute.contributor_avatar_alt', {
+ alt: t('pages.contribute.contributor_avatar_alt',
name: contributor_blurb['name']
- })
+ )
}
},
body: <<~HEREDOC
diff --git a/app/views/pages/_not_signed_in.html.erb b/app/views/pages/_not_signed_in.html.erb
index 1115d0b9e6..2684f50d0b 100644
--- a/app/views/pages/_not_signed_in.html.erb
+++ b/app/views/pages/_not_signed_in.html.erb
@@ -61,10 +61,10 @@
<%= t('pages.home.not_signed_in.main_message_two') %>
- <%= raw t('pages.home.not_signed_in.message_text_two', {
+ <%= raw t('pages.home.not_signed_in.message_text_two',
help: link_to(t('pages.home.not_signed_in.help'), about_path),
feedback: link_to(t('navigation.feedback'), 'http://goo.gl/forms/8EqoJDDiXY', target: 'blank')
- }) %>
+ ) %>
<%= render partial: 'contributor_blurb', collection: @blurbs %>
diff --git a/app/views/pages/_signed_in_empty.html.erb b/app/views/pages/_signed_in_empty.html.erb
index 1c536574b0..9d6426e452 100644
--- a/app/views/pages/_signed_in_empty.html.erb
+++ b/app/views/pages/_signed_in_empty.html.erb
@@ -10,11 +10,11 @@
<%= t('pages.home.signed_in_empty.main_message_two') %>
- <%= raw t('pages.home.signed_in_empty.cell_one', {
+ <%= raw t('pages.home.signed_in_empty.cell_one',
profile: link_to(t('profile.index.title'), edit_user_registration_path),
moods: link_to(t('moods.plural'), moods_path),
allies: link_to(t('allies.index.title'), allies_path)
- }) %>
+ ) %>
@@ -26,10 +26,10 @@
<%= t('pages.home.signed_in_empty.main_message_three') %>
- <%= raw t('pages.home.signed_in_empty.cell_two', {
+ <%= raw t('pages.home.signed_in_empty.cell_two',
categories: link_to(t('categories.plural'), categories_path),
moments: link_to(t('moments.plural'), moments_path)
- }) %>
+ ) %>
@@ -41,18 +41,18 @@
<%= t('pages.home.signed_in_empty.main_message_four') %>
- <%= raw t('pages.home.signed_in_empty.cell_three', {
+ <%= raw t('pages.home.signed_in_empty.cell_three',
strategize: link_to(t('pages.home.signed_in_empty.strategize'), strategies_path),
medications: link_to(t('medications.index.title'), medications_path),
group: link_to(t('groups.singular'), groups_path)
- }) %>
+ ) %>
<%= t('pages.home.signed_in_empty.main_message_five') %>
- <%= raw t('pages.home.signed_in_empty.message_text_three', {
+ <%= raw t('pages.home.signed_in_empty.message_text_three',
faq: link_to(t('navigation.faq'), faq_path),
email_link: link_to(t('common.write_to_us'), "mailto:#{t('email')}")
- }) %>
+ ) %>
diff --git a/app/views/pages/about.html.erb b/app/views/pages/about.html.erb
index f3ded427cb..5e537d7eef 100644
--- a/app/views/pages/about.html.erb
+++ b/app/views/pages/about.html.erb
@@ -7,9 +7,9 @@
- <%= raw t('pages.about.main_message_one', {
+ <%= raw t('pages.about.main_message_one',
app_name: t('app_name')
- }) %>
+ ) %>
<%= t('pages.about.message_text_one') %>
@@ -32,17 +32,17 @@
- <%= raw t('pages.contribute.message_text_one', {
+ <%= raw t('pages.contribute.message_text_one',
email_link: link_to(t('common.write_to_us'), "https://github.com/ifmeorg/ifme/wiki/Join-Our-Slack"),
slack_link: link_to(t('pages.contribute.slack'), 'https://ifme.slack.com', target: 'blank'),
github_link: link_to(t('navigation.github'), 'https://github.com/ifmeorg/ifme', target: 'blank')
- })
+ )
%>
- <%= raw t('pages.about.message_text_three', {
+ <%= raw t('pages.about.message_text_three',
fund_club_link: link_to(t('pages.about.fund_club'), 'http://joinfundclub.com', target: 'blank'),
open_collective_link: link_to(t('navigation.open_collective'), 'https://opencollective.com/ifme', target: 'blank')
- }) %>
+ ) %>
diff --git a/app/views/pages/faq.html.erb b/app/views/pages/faq.html.erb
index a295684674..f319592fc6 100644
--- a/app/views/pages/faq.html.erb
+++ b/app/views/pages/faq.html.erb
@@ -14,10 +14,10 @@
<%= t('pages.faq.moment_question') %>
- <%= raw t('pages.faq.moment_answer', {
+ <%= raw t('pages.faq.moment_answer',
moment: link_to(t('moments.singular'), moments_path),
moment_templates: link_to(t('moment_templates.index.title'), moment_templates_path)
- }) %>
+ ) %>
@@ -87,8 +87,8 @@
<%= t('pages.faq.email_notifications_question') %>
- <%= raw t('pages.faq.email_notifications_answer', {
+ <%= raw t('pages.faq.email_notifications_answer',
accounts: link_to(t('account.singular'), edit_user_registration_path )
- }) %>
+ ) %>
diff --git a/app/views/pages/home.html.erb b/app/views/pages/home.html.erb
index 33d3d974f6..c76692675e 100644
--- a/app/views/pages/home.html.erb
+++ b/app/views/pages/home.html.erb
@@ -3,7 +3,7 @@
<% @page_new = "New Moment" %>
<% page_new new_moment_path %>
<% elsif user_signed_in? %>
- <% title t('pages.home.signed_in_empty.main_message_one', { name: current_user.name }) %>
+ <% title t('pages.home.signed_in_empty.main_message_one', name: current_user.name) %>
<% end %>
<% if !user_signed_in? %>
diff --git a/app/views/pages/partners.html.erb b/app/views/pages/partners.html.erb
index b429e1f96c..cf93cbf8cb 100644
--- a/app/views/pages/partners.html.erb
+++ b/app/views/pages/partners.html.erb
@@ -1,7 +1,7 @@
<% title t('navigation.partners') %>
- <%= raw t('pages.partners.description', {
+ <%= raw t('pages.partners.description',
email: link_to(t('email'), "mailto:#{t('email')}")
- }) %>
+ ) %>
<%= print_partners(@organizations) %>
diff --git a/app/views/pages/privacy.html.erb b/app/views/pages/privacy.html.erb
index 0d190582cb..dc19850a4d 100644
--- a/app/views/pages/privacy.html.erb
+++ b/app/views/pages/privacy.html.erb
@@ -13,9 +13,9 @@
<%= raw t('pages.faq.data_access_answer') %>
- <%= raw t('pages.privacy.user_data_description', {
+ <%= raw t('pages.privacy.user_data_description',
faq_link: link_to(t('pages.faq.title'), faq_path)
- }) %>
+ ) %>
@@ -36,8 +36,8 @@
<%= t('pages.privacy.contact') %>
- <%= raw t('pages.privacy.contact_description', {
+ <%= raw t('pages.privacy.contact_description',
email_link: link_to(t('common.write_to_us'), "mailto:#{t('email')}")
- }) %>
+ ) %>
diff --git a/app/views/shared/_comments.html.erb b/app/views/shared/_comments.html.erb
index 60740a5fed..c0df616273 100644
--- a/app/views/shared/_comments.html.erb
+++ b/app/views/shared/_comments.html.erb
@@ -2,6 +2,6 @@
comments: @comments,
formProps: comment_form_props(
local_assigns[:commentable],
- local_assigns[:commentable].class.name.downcase
+ local_assigns[:commentable].class.name
)
}) %>
diff --git a/bin/rails b/bin/rails
index 0739660237..efc0377492 100755
--- a/bin/rails
+++ b/bin/rails
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-APP_PATH = File.expand_path('../config/application', __dir__)
-require_relative '../config/boot'
-require 'rails/commands'
+APP_PATH = File.expand_path("../config/application", __dir__)
+require_relative "../config/boot"
+require "rails/commands"
diff --git a/bin/rake b/bin/rake
index 17240489f6..4fbf10b960 100755
--- a/bin/rake
+++ b/bin/rake
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-require_relative '../config/boot'
-require 'rake'
+require_relative "../config/boot"
+require "rake"
Rake.application.run
diff --git a/bin/setup b/bin/setup
index d9b4d2bce6..ec47b79b3b 100755
--- a/bin/setup
+++ b/bin/setup
@@ -1,34 +1,33 @@
#!/usr/bin/env ruby
-require 'pathname'
-require 'fileutils'
+require "fileutils"
# path to your application root.
-APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
+APP_ROOT = File.expand_path("..", __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
FileUtils.chdir APP_ROOT do
- # This script is a way to setup or update your development environment automatically.
- # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
+ # 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.
- puts '== Installing dependencies =='
- system! 'gem install bundler --conservative'
- system('bundle check') || system!('bundle install')
+ puts "== Installing dependencies =="
+ system! "gem install bundler --conservative"
+ system("bundle check") || system!("bundle install")
# puts "\n== Copying sample files =="
- # unless File.exist?('config/database.yml')
- # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
+ # unless File.exist?("config/database.yml")
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
# end
puts "\n== Preparing database =="
- system! 'bin/rails db:prepare'
+ system! "bin/rails db:prepare"
puts "\n== Removing old logs and tempfiles =="
- system! 'bin/rails log:clear tmp:clear'
+ system! "bin/rails log:clear tmp:clear"
puts "\n== Restarting application server =="
- system! 'bin/rails restart'
+ system! "bin/rails restart"
end
diff --git a/config/application.rb b/config/application.rb
index 92401e968e..fbfdf27036 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require_relative 'boot'
-require_relative 'locale'
-require 'rails/all'
+require_relative "boot"
+require_relative "locale"
+require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
@@ -11,23 +11,15 @@
module Ifme
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
- config.load_defaults 6.0
-
- # Settings in config/environments/* take precedence over those specified here.
- # Application configuration can go into files in config/initializers
- # -- all .rb files in that directory are automatically loaded after loading
- # the framework and any gems in your application.
- # Set Time.zone default to the specified zone and make Active Record
- # auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names.
- # Default is UTC.
- # config.time_zone = 'Central Time (US & Canada)'
-
- # The default locale is :en and all translations from
- # config/locales/*.rb,yml are auto loaded.
- # config.i18n.load_path += Dir[
- # Rails.root.join('my', 'locales', '*.{rb,yml}').to_s
- # ]
+ config.load_defaults 7.0
+
+ # Configuration for the application, engines, and railties goes here.
+ #
+ # These settings can be overridden in specific environments using the files
+ # in config/environments, which are processed later.
+ #
+ # config.time_zone = "Central Time (US & Canada)"
+ # config.eager_load_paths << Rails.root.join("extras")
config.exceptions_app = routes
diff --git a/config/boot.rb b/config/boot.rb
index 488e1c0955..de9693cf0d 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-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 "bundler/setup" # Set up gems listed in the Gemfile.
-if Gem::Specification.find_all_by_name('dotenv').any?
- require 'dotenv'
- environment = ENV['RAILS_ENV'] || :development
- dotenv_path = File.join('config', 'env', "#{environment}.env")
+if Gem::Specification.find_all_by_name("dotenv").any?
+ require "dotenv"
+ environment = ENV["RAILS_ENV"] || :development
+ dotenv_path = File.join("config", "env", "#{environment}.env")
Dotenv.load(dotenv_path)
end
diff --git a/config/database.yml b/config/database.yml
index 6a6265cce1..f2d3d18a15 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -1,22 +1,21 @@
-development: &default
+default: &default
adapter: postgresql
+ allow_concurrency: true
encoding: unicode
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+development:
+ <<: *default
host: <%= ENV['PSQL_HOST'] || 'localhost' %>
database: ifme_development
username: <%= ENV['PSQL_USERNAME'] %>
password: <%= ENV['PSQL_PASSWORD'] %>
- allow_concurrency: true
- pool: 5
min_messages: warning
test:
<<: *default
database: ifme_test
min_messages: error
production:
- adapter: postgresql
- encoding: unicode
+ <<: *default
database: ifme_production
username: <%= ENV['PSQL_USERNAME'] %>
password: <%= ENV['PSQL_PASSWORD'] %>
- allow_concurrency: true
- pool: 5
diff --git a/config/environment.rb b/config/environment.rb
index d5abe55806..7df99e89c6 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# Load the Rails application.
-require_relative 'application'
+require_relative "application"
# Initialize the Rails application.
Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index a7c4e64b82..f47957d395 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,12 +1,13 @@
# frozen_string_literal: true
+require "active_support/core_ext/integer/time"
primary_domain = 'localhost:3000'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
- # In the development environment your application's code is reloaded on
- # every request. This slows down response time but is perfect for development
+ # 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 = false
@@ -16,16 +17,19 @@
# reroute all requests with errors to the views/layouts/errors.html.erb page
config.consider_all_requests_local = false
+ # Enable server timing
+ config.server_timing = true
+
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
- if Rails.root.join('tmp', 'caching-dev.txt').exist?
- config.action_controller.perform_caching = false
+ if Rails.root.join("tmp", "caching-dev.txt").exist?
+ config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store
config.public_file_server.headers = {
- 'Cache-Control' => 'public, max-age=172800'
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
@@ -33,9 +37,18 @@
config.cache_store = :null_store
end
+ # Store uploaded files on the local file system (see config/storage.yml for options).
+ config.active_storage.service = :local
+
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
+ # Raise exceptions for disallowed deprecations.
+ config.active_support.disallowed_deprecation = :raise
+
+ # Tell Active Support which deprecation messages to disallow.
+ config.active_support.disallowed_deprecation_warnings = []
+
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
@@ -48,14 +61,11 @@
config.assets.debug = true
# Suppress logger output for asset requests.
- # Suppress writing of asset requests to the log file
config.assets.quiet = true
# Raises error for missing translations.
- config.action_view.raise_on_missing_translations = true
+ config.i18n.raise_on_missing_translations = true
- # Store uploaded files on the local file system (see config/storage.yml for options).
- config.active_storage.service = :local
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
@@ -63,9 +73,13 @@
config.action_mailer.default_url_options = { host: primary_domain }
config.action_mailer.perform_deliveries = ENV['SEND_EMAIL']
config.action_mailer.raise_delivery_errors = ENV['RAISE_DELIVERY_ERRORS']
+ config.action_view.annotate_rendered_view_with_filenames = true
# To preview email in browser rather than to send a mail to actual user during development
config.action_mailer.delivery_method = :letter_opener
+
+ # Uncomment if you wish to allow Action Cable access from any origin.
+ # config.action_cable.disable_request_forgery_protection = true
# If you want to actually test emails, you will have to configure SMTP settings in smtp.yml
config.action_mailer.smtp_settings = {
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 9394bd426d..ebce60fbeb 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
+require "active_support/core_ext/integer/time"
primary_domain = 'www.if-me.org'
Rails.application.configure do
@@ -24,17 +25,15 @@
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
- # config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+ config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Compress JavaScript and CSS using a preprocessor.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
- # Do not fallback to assets pipeline if a precompiled asset is missed.
- config.assets.compile = false
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
- # config.action_controller.asset_host = 'http://assets.example.com'
+ # config.asset_host = "http://assets.example.com"
# Generate digests for assets URLs.
config.assets.digest = true
@@ -44,7 +43,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
@@ -66,7 +65,7 @@
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
- # config.active_job.queue_name_prefix = "ifme_#{Rails.env}"
+ # config.active_job.queue_name_prefix = "ifme_production"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
@@ -78,7 +77,7 @@
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
- config.active_support.deprecation = :notify
+ config.active_support.report_deprecations = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 381ab7fb7f..c2495aa54a 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require "active_support/core_ext/integer/time"
+
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
@@ -8,18 +10,18 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
- config.cache_classes = false
+ # Turn false under Spring and add config.action_view.cache_template_loading = true.
config.action_view.cache_template_loading = true
- # Do not eager load code on boot. This avoids loading your whole application
- # just for the purpose of running a single test. If you are using a tool that
- # preloads Rails for running tests, you may have to set it to true.
- config.eager_load = 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.
+ 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=3600'
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching.
@@ -28,7 +30,7 @@
config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates.
- config.action_dispatch.show_exceptions = true
+ config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
@@ -48,6 +50,15 @@
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
+ # Raise exceptions for disallowed deprecations.
+ config.active_support.disallowed_deprecation = :raise
+
+ # Tell Active Support which deprecation messages to disallow.
+ config.active_support.disallowed_deprecation_warnings = []
+
# Raises error for missing translations.
- config.action_view.raise_on_missing_translations = true
+ config.i18n.raise_on_missing_translations = true
+
+ # Annotate rendered view with file names.
+ # config.action_view.annotate_rendered_view_with_filenames = true
end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 16dfce4516..9ab91c905d 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -3,7 +3,7 @@
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
-Rails.application.config.assets.version = '1.0'
+Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
index 41c43016f1..54f47cf15f 100644
--- a/config/initializers/content_security_policy.rb
+++ b/config/initializers/content_security_policy.rb
@@ -1,28 +1,25 @@
# 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
-# Rails.application.config.content_security_policy do |policy|
-# policy.default_src :self, :https
-# policy.font_src :self, :https, :data
-# policy.img_src :self, :https, :data
-# policy.object_src :none
-# policy.script_src :self, :https
-# policy.style_src :self, :https
-
-# # Specify URI for violation reports
-# # policy.report_uri "/csp-violation-report-endpoint"
+# Rails.application.configure do
+# config.content_security_policy do |policy|
+# policy.default_src :self, :https
+# policy.font_src :self, :https, :data
+# policy.img_src :self, :https, :data
+# policy.object_src :none
+# policy.script_src :self, :https
+# policy.style_src :self, :https
+# # Specify URI for violation reports
+# # policy.report_uri "/csp-violation-report-endpoint"
+# end
+#
+# # Generate session nonces for permitted importmap and inline scripts
+# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
+# config.content_security_policy_nonce_directives = %w(script-src)
+#
+# # Report violations without enforcing the policy.
+# # config.content_security_policy_report_only = true
# end
-
-# If you are using UJS then enable automatic nonce generation
-# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
-
-# Set the nonce only to specific directives
-# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
-
-# Report CSP violations to a specified URI
-# For further information see the following documentation:
-# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
-# Rails.application.config.content_security_policy_report_only = true
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
index 7a4f47b4c2..adc6568ce8 100644
--- a/config/initializers/filter_parameter_logging.rb
+++ b/config/initializers/filter_parameter_logging.rb
@@ -1,6 +1,8 @@
-# frozen_string_literal: true
-
# Be sure to restart your server when you modify this file.
-# Configure sensitive parameters which will be filtered from the log file.
-Rails.application.config.filter_parameters += [:password]
+# Configure parameters to be 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, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
+]
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index dc84742212..3860f659ea 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -1,18 +1,16 @@
-# frozen_string_literal: true
-
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
-# inflect.plural /^(ox)$/i, '\1en'
-# inflect.singular /^(ox)en/i, '\1'
-# inflect.irregular 'person', 'people'
+# inflect.plural /^(ox)$/i, "\\1en"
+# inflect.singular /^(ox)en/i, "\\1"
+# inflect.irregular "person", "people"
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
-# inflect.acronym 'RESTful'
+# inflect.acronym "RESTful"
# end
diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb
new file mode 100644
index 0000000000..4d580245a5
--- /dev/null
+++ b/config/initializers/new_framework_defaults_7_0.rb
@@ -0,0 +1,135 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file eases your Rails 7.0 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.0`.
+#
+# Read the Guide for Upgrading Ruby on Rails for more info on each option.
+# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
+
+# `button_to` view helper will render `` element, regardless of whether
+# or not the content is passed as the first argument or as a block.
+# Rails.application.config.action_view.button_to_generates_button_tag = true
+
+# `stylesheet_link_tag` view helper will not render the media attribute by default.
+# Rails.application.config.action_view.apply_stylesheet_media_default = false
+
+# Change the digest class for the key generators to `OpenSSL::Digest::SHA256`.
+# Changing this default means invalidate all encrypted messages generated by
+# your application and, all the encrypted cookies. Only change this after you
+# rotated all the messages using the key rotator.
+#
+# See upgrading guide for more information on how to build a rotator.
+# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html
+# Rails.application.config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
+
+# Change the digest class for ActiveSupport::Digest.
+# Changing this default means that for example Etags change and
+# various cache keys leading to cache invalidation.
+# Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
+
+# Don't override ActiveSupport::TimeWithZone.name and use the default Ruby
+# implementation.
+# Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
+
+# Calls `Rails.application.executor.wrap` around test cases.
+# This makes test cases behave closer to an actual request or job.
+# Several features that are normally disabled in test, such as Active Record query cache
+# and asynchronous queries will then be enabled.
+# Rails.application.config.active_support.executor_around_test_case = true
+
+# Define the isolation level of most of Rails internal state.
+# If you use a fiber based server or job processor, you should set it to `:fiber`.
+# Otherwise the default of `:thread` if preferable.
+# Rails.application.config.active_support.isolation_level = :thread
+
+# Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.
+# Rails.application.config.action_mailer.smtp_timeout = 5
+
+# The ActiveStorage video previewer will now use scene change detection to generate
+# better preview images (rather than the previous default of using the first frame
+# of the video).
+# Rails.application.config.active_storage.video_preview_arguments =
+# "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
+
+# Automatically infer `inverse_of` for associations with a scope.
+# Rails.application.config.active_record.automatic_scope_inversing = true
+
+# Raise when running tests if fixtures contained foreign key violations
+# Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
+
+# Disable partial inserts.
+# This default means that all columns will be referenced in INSERT queries
+# regardless of whether they have a default or not.
+# Rails.application.config.active_record.partial_inserts = false
+
+# Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
+# Rails.application.config.action_controller.raise_on_open_redirects = true
+
+# Change the variant processor for Active Storage.
+# Changing this default means updating all places in your code that
+# generate variants to use image processing macros and ruby-vips
+# operations. See the upgrading guide for detail on the changes required.
+# The `:mini_magick` option is not deprecated; it's fine to keep using it.
+# Rails.application.config.active_storage.variant_processor = :vips
+
+# Enable parameter wrapping for JSON.
+# Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
+# To disable parameter wrapping entirely, set this config to `false`.
+# Rails.application.config.action_controller.wrap_parameters_by_default = true
+
+# Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a
+# `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls.
+#
+# See https://guides.rubyonrails.org/configuring.html#config-active-support-use-rfc4122-namespaced-uuids for
+# more information.
+# Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
+
+# Change the default headers to disable browsers' flawed legacy XSS protection.
+# Rails.application.config.action_dispatch.default_headers = {
+# "X-Frame-Options" => "SAMEORIGIN",
+# "X-XSS-Protection" => "0",
+# "X-Content-Type-Options" => "nosniff",
+# "X-Download-Options" => "noopen",
+# "X-Permitted-Cross-Domain-Policies" => "none",
+# "Referrer-Policy" => "strict-origin-when-cross-origin"
+# }
+
+
+# ** 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 6.1 applications.
+# Only change this value after your application is fully deployed to Rails 7.0
+# 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.0
+
+
+# Cookie serializer: 2 options
+#
+# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
+# is `:marshal`. The default for new apps is `:json`.
+#
+# Rails.application.config.action_dispatch.cookies_serializer = :json
+#
+#
+# To migrate an existing application to the `:json` serializer, use the `:hybrid` option.
+#
+# Rails transparently deserializes existing (Marshal-serialized) cookies on read and
+# re-writes them in the JSON format.
+#
+# It is fine to use `:hybrid` long term; you should do that until you're confident *all* your cookies
+# have been converted to JSON. To keep using `:hybrid` long term, move this config to its own
+# initializer or to `config/application.rb`.
+#
+# Rails.application.config.action_dispatch.cookies_serializer = :hybrid
+#
+#
+# If your cookies can't yet be serialized to JSON, keep using `:marshal` for backward-compatibility.
+#
+# If you have configured the serializer elsewhere, you can remove this section of the file.
+#
+# See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb
new file mode 100644
index 0000000000..00f64d71b0
--- /dev/null
+++ b/config/initializers/permissions_policy.rb
@@ -0,0 +1,11 @@
+# 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"
+# end
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index f557bbb0b0..b5a7a1ae27 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -11,4 +11,4 @@
end
end
-Sidekiq.default_worker_options = { :backtrace => true, :unique => :all, :failures => true }
+Sidekiq.default_job_options = { :backtrace => true, :unique => :all, :failures => true }
diff --git a/db/migrate/20221025214531_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20221025214531_add_service_name_to_active_storage_blobs.active_storage.rb
new file mode 100644
index 0000000000..a15c6ce8e5
--- /dev/null
+++ b/db/migrate/20221025214531_add_service_name_to_active_storage_blobs.active_storage.rb
@@ -0,0 +1,22 @@
+# This migration comes from active_storage (originally 20190112182829)
+class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
+ def up
+ return unless table_exists?(:active_storage_blobs)
+
+ unless column_exists?(:active_storage_blobs, :service_name)
+ add_column :active_storage_blobs, :service_name, :string
+
+ if configured_service = ActiveStorage::Blob.service.name
+ ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
+ end
+
+ change_column :active_storage_blobs, :service_name, :string, null: false
+ end
+ end
+
+ def down
+ return unless table_exists?(:active_storage_blobs)
+
+ remove_column :active_storage_blobs, :service_name
+ end
+end
diff --git a/db/migrate/20221025214532_create_active_storage_variant_records.active_storage.rb b/db/migrate/20221025214532_create_active_storage_variant_records.active_storage.rb
new file mode 100644
index 0000000000..94ac83af0b
--- /dev/null
+++ b/db/migrate/20221025214532_create_active_storage_variant_records.active_storage.rb
@@ -0,0 +1,27 @@
+# This migration comes from active_storage (originally 20191206030411)
+class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
+ def change
+ return unless table_exists?(:active_storage_blobs)
+
+ # Use Active Record's configured type for primary key
+ create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t|
+ t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
+ t.string :variation_digest, null: false
+
+ t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
+ t.foreign_key :active_storage_blobs, column: :blob_id
+ end
+ end
+
+ private
+ def primary_key_type
+ config = Rails.configuration.generators
+ config.options[config.orm][:primary_key_type] || :primary_key
+ end
+
+ def blobs_primary_key_type
+ pkey_name = connection.primary_key(:active_storage_blobs)
+ pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
+ pkey_column.bigint? ? :bigint : pkey_column.type
+ end
+end
diff --git a/db/migrate/20221025214533_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20221025214533_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb
new file mode 100644
index 0000000000..93c8b85ade
--- /dev/null
+++ b/db/migrate/20221025214533_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb
@@ -0,0 +1,8 @@
+# This migration comes from active_storage (originally 20211119233751)
+class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
+ def change
+ return unless table_exists?(:active_storage_blobs)
+
+ change_column_null(:active_storage_blobs, :checksum, true)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e1e6e11a9a..1de1621107 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2,23 +2,22 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
-# This file is the source Rails uses to define your schema when running `rails
-# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
+# This file is the source Rails uses to define your schema when running `bin/rails
+# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2022_02_04_015546) do
-
+ActiveRecord::Schema[7.0].define(version: 2022_10_25_214533) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "allyships", force: :cascade do |t|
t.integer "user_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.integer "ally_id"
t.integer "status"
end
@@ -26,30 +25,30 @@
create_table "bootsy_image_galleries", force: :cascade do |t|
t.integer "bootsy_resource_id"
t.string "bootsy_resource_type"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
end
create_table "bootsy_images", force: :cascade do |t|
t.string "image_file"
t.integer "image_gallery_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
end
create_table "care_plan_contacts", force: :cascade do |t|
t.string "name"
t.string "phone"
t.integer "user_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
end
create_table "categories", force: :cascade do |t|
t.string "name"
t.text "description"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.integer "user_id"
t.string "slug"
t.boolean "visible", default: true
@@ -61,8 +60,8 @@
t.integer "commentable_id"
t.integer "comment_by"
t.text "comment"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.string "visibility"
t.text "viewers"
t.index ["commentable_type", "commentable_id"], name: "index_comments_on_commentable_type_and_commentable_id"
@@ -73,7 +72,7 @@
t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50
t.string "scope"
- t.datetime "created_at"
+ t.datetime "created_at", precision: nil
t.index ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
t.index ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
t.index ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id"
@@ -84,14 +83,14 @@
t.integer "group_id"
t.integer "user_id"
t.boolean "leader"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
end
create_table "groups", force: :cascade do |t|
t.string "name"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.text "description"
t.string "slug"
t.index ["slug"], name: "index_groups_on_slug", unique: true
@@ -100,9 +99,9 @@
create_table "medications", force: :cascade do |t|
t.string "name"
t.integer "dosage"
- t.datetime "refill"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "refill", precision: nil
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.integer "user_id"
t.integer "total"
t.integer "strength"
@@ -120,8 +119,8 @@
t.integer "meeting_id"
t.integer "user_id"
t.boolean "leader"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.string "google_cal_event_id"
end
@@ -132,8 +131,8 @@
t.string "time"
t.integer "maxmembers"
t.integer "group_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.string "date"
t.string "slug"
t.index ["slug"], name: "index_meetings_on_slug", unique: true
@@ -144,8 +143,8 @@
t.text "description"
t.string "slug"
t.bigint "user_id"
- t.datetime "created_at", precision: 6, null: false
- t.datetime "updated_at", precision: 6, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.index ["slug"], name: "index_moment_templates_on_slug", unique: true
t.index ["user_id"], name: "index_moment_templates_on_user_id"
end
@@ -154,15 +153,15 @@
t.string "name"
t.text "why"
t.text "fix"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.integer "user_id"
t.text "viewers"
t.boolean "comment"
t.string "slug"
t.uuid "secret_share_identifier"
- t.datetime "secret_share_expires_at"
- t.datetime "published_at"
+ t.datetime "secret_share_expires_at", precision: nil
+ t.datetime "published_at", precision: nil
t.boolean "bookmarked", default: false
t.boolean "resource_recommendations", default: true
t.index ["secret_share_identifier"], name: "index_moments_on_secret_share_identifier", unique: true
@@ -190,8 +189,8 @@
create_table "moods", force: :cascade do |t|
t.string "name"
t.text "description"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.integer "user_id"
t.string "slug"
t.boolean "visible", default: true
@@ -202,30 +201,30 @@
t.integer "user_id"
t.string "uniqueid"
t.text "data"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", precision: nil, null: false
+ t.datetime "updated_at", precision: nil, null: false
end
create_table "perform_strategy_reminders", id: :serial, force: :cascade do |t|
t.integer "strategy_id", null: false
t.boolean "active", null: false
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
end
create_table "refill_reminders", id: :serial, force: :cascade do |t|
t.integer "medication_id", null: false
t.boolean "active", null: false
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
end
create_table "reports", force: :cascade do |t|
t.integer "reporter_id"
t.integer "reportee_id"
t.text "reasons"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", precision: nil, null: false
+ t.datetime "updated_at", precision: nil, null: false
t.integer "comment_id"
end
@@ -234,11 +233,11 @@
t.text "description"
t.text "viewers"
t.boolean "comment"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.string "name"
t.string "slug"
- t.datetime "published_at"
+ t.datetime "published_at", precision: nil
t.boolean "visible", default: true
t.boolean "bookmarked", default: false
t.index ["slug"], name: "index_strategies_on_slug", unique: true
@@ -254,30 +253,30 @@
t.integer "user_id"
t.string "support_type"
t.text "support_ids"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
end
create_table "take_medication_reminders", id: :serial, force: :cascade do |t|
t.integer "medication_id", null: false
t.boolean "active", null: false
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
- t.datetime "reset_password_sent_at"
- t.datetime "remember_created_at"
+ t.datetime "reset_password_sent_at", precision: nil
+ t.datetime "remember_created_at", precision: nil
t.integer "sign_in_count", default: 0, null: false
- t.datetime "current_sign_in_at"
- t.datetime "last_sign_in_at"
+ t.datetime "current_sign_in_at", precision: nil
+ t.datetime "last_sign_in_at", precision: nil
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", precision: nil
+ t.datetime "updated_at", precision: nil
t.string "name"
t.string "location"
t.string "timezone"
@@ -288,9 +287,9 @@
t.string "uid"
t.string "provider"
t.string "invitation_token"
- t.datetime "invitation_created_at"
- t.datetime "invitation_sent_at"
- t.datetime "invitation_accepted_at"
+ t.datetime "invitation_created_at", precision: nil
+ t.datetime "invitation_sent_at", precision: nil
+ t.datetime "invitation_accepted_at", precision: nil
t.integer "invitation_limit"
t.string "invited_by_type"
t.integer "invited_by_id"
@@ -300,16 +299,16 @@
t.boolean "group_notify"
t.boolean "meeting_notify"
t.string "locale"
- t.datetime "access_expires_at"
+ t.datetime "access_expires_at", precision: nil
t.string "refresh_token"
t.boolean "banned", default: false
t.boolean "admin", default: false
t.text "third_party_avatar"
t.integer "failed_attempts", default: 0, null: false
- t.datetime "locked_at"
+ t.datetime "locked_at", precision: nil
t.string "confirmation_token"
- t.datetime "confirmed_at"
- t.datetime "confirmation_sent_at"
+ t.datetime "confirmed_at", precision: nil
+ t.datetime "confirmation_sent_at", precision: nil
t.string "unconfirmed_email"
t.string "session_token"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
@@ -325,8 +324,8 @@
t.string "request_id", null: false
t.integer "status_id", null: false
t.bigint "user_id", null: false
- t.datetime "created_at", precision: 6, null: false
- t.datetime "updated_at", precision: 6, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.index ["request_id"], name: "index_users_data_requests_on_request_id", unique: true
t.index ["user_id", "status_id"], name: "index_users_data_requests_on_users_id_and_status_uniq", unique: true, where: "(status_id = 1)"
t.index ["user_id"], name: "index_users_data_requests_on_user_id"
diff --git a/db/seeds.rb b/db/seeds.rb
index e056bab8e4..4180d7c682 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -24,7 +24,7 @@
user1_mood1 = Mood.create(user_id: user1.id, name: 'Anxious', description: 'Sweaty palms, increased heart rate')
user1_mood2 = Mood.create(user_id: user1.id, name: 'Shy', description: 'I swallow my words and start speaking fast')
user1_moment1 = Moment.create(user_id: user1.id, category: Array.new(1, user1_category1.id), mood: [user1_mood1.id, user1_mood2.id], name: 'Presentation for ENGL 101', why: 'I am presenting in front of my classmates and I am worried I will make a fool out of myself', viewers: [user2.id, user3.id], comment: true, resource_recommendations: true)
-user1_moment1_comment = Comment.create(commentable_type: 'moment', commentable_id: user1_moment1.id, comment_by: user2.id, comment: "Good luck on the presentation! Just pretend everyone is in underpants :)", visibility: 'private')
+user1_moment1_comment = Comment.create(commentable_type: 'Moment', commentable_id: user1_moment1.id, comment_by: user2.id, comment: "Good luck on the presentation! Just pretend everyone is in underpants :)", visibility: 'private')
user1_group1 = Group.create(name: 'Students with Anxiety', description: 'A support group for students to discuss anxiety weekly')
user1_group1_member1 = GroupMember.create(group_id: user1_group1.id, user_id: user1.id, leader: true)
user1_meeting1 = Meeting.create(name: 'Meeting #1: Self-care', description: 'This week we will be talking about what we can do to adequately self-care during exams', location: 'http://SomeGoogleHangoutURL', time: '6:00 pm EST', maxmembers: 5, group_id: user1_group1.id)
@@ -39,5 +39,5 @@
user2_mood1 = Mood.create(user_id: user2.id, name: 'Angry', description: 'I become violent and act irrationally')
user2_mood2 = Mood.create(user_id: user2.id, name: 'Exhausted', description: 'No motivation to do anything')
user2_moment1 = Moment.create(user_id: user2.id, category: Array.new(1, user2_category1.id), mood: Array.new(1, user2_mood1.id), name: 'Thanksgiving Dinner', why: 'He kept asserting to everyone that I was immature and he always did everything for me.', viewers: Array.new(1, user1.id), comment: false, resource_recommendations: true)
-user2_moment1_comment = Comment.create(commentable_type: 'moment', commentable_id: user2_moment1.id, comment_by: user1.id, comment: "You should talk to him one-on-one and tell him how you feel!", visibility: 'all')
+user2_moment1_comment = Comment.create(commentable_type: 'Moment', commentable_id: user2_moment1.id, comment_by: user1.id, comment: "You should talk to him one-on-one and tell him how you feel!", visibility: 'all')
user1_group1_member2 = GroupMember.create(group_id: user1_group1.id, user_id: user2.id, leader: true)
diff --git a/spec/factories/factories.rb b/spec/factories/factories.rb
index f098a347a0..e52d718649 100644
--- a/spec/factories/factories.rb
+++ b/spec/factories/factories.rb
@@ -100,7 +100,7 @@
end
factory :comment do
- commentable_type { 'moment' }
+ commentable_type { 'Moment' }
comment { 'Test Comment' }
visibility { 'all' }
end
diff --git a/spec/features/user_creates_a_draft_moment_spec.rb b/spec/features/user_creates_a_draft_moment_spec.rb
index fa68f20b51..f1b136f638 100644
--- a/spec/features/user_creates_a_draft_moment_spec.rb
+++ b/spec/features/user_creates_a_draft_moment_spec.rb
@@ -108,6 +108,7 @@
# TRYING TO VIEW AS ALLY
login_as ally
visit back
+
expect(find('.pageTitle')).not_to have_content 'My New Moment'
login_as user
visit back
diff --git a/spec/helpers/comments_helper_spec.rb b/spec/helpers/comments_helper_spec.rb
index 1b147f5ed5..d9d5dc47e6 100644
--- a/spec/helpers/comments_helper_spec.rb
+++ b/spec/helpers/comments_helper_spec.rb
@@ -25,7 +25,7 @@
end
it 'generates a valid comment object when visibility is all' do
- new_comment = create(:comment, comment: comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user1.id, visibility: 'all')
+ new_comment = create(:comment, comment: comment, commentable_type: 'Moment', commentable_id: new_moment.id, comment_by: user1.id, visibility: 'all')
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user1.uid,
@@ -41,7 +41,7 @@
end
it 'generates a valid comment object when visbility is private' do
- new_comment = create(:comment, comment: comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user1.id, visibility: 'private', viewers: [user2.id])
+ new_comment = create(:comment, comment: comment, commentable_type: 'Moment', commentable_id: new_moment.id, comment_by: user1.id, visibility: 'private', viewers: [user2.id])
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user1.uid,
@@ -63,7 +63,7 @@
end
it 'generates a valid comment object when visibility is all' do
- new_comment = create(:comment, comment: comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user2.id, visibility: 'all')
+ new_comment = create(:comment, comment: comment, commentable_type: 'Moment', commentable_id: new_moment.id, comment_by: user2.id, visibility: 'all')
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user2.uid,
@@ -79,7 +79,7 @@
end
it 'generates a valid comment object when visibility is private' do
- new_comment = create(:comment, comment: comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user2.id, visibility: 'private', viewers: [user1.id])
+ new_comment = create(:comment, comment: comment, commentable_type: 'Moment', commentable_id: new_moment.id, comment_by: user2.id, visibility: 'private', viewers: [user1.id])
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user2.uid,
@@ -105,7 +105,7 @@
end
it 'generates a valid comment object when visibility is all' do
- new_comment = create(:comment, comment: comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user1.id, visibility: 'all')
+ new_comment = create(:comment, comment: comment, commentable_type: 'Strategy', commentable_id: new_strategy.id, comment_by: user1.id, visibility: 'all')
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user1.uid,
@@ -121,7 +121,7 @@
end
it 'generates a valid comment object when visibility is private' do
- new_comment = create(:comment, comment: comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user1.id, visibility: 'private', viewers: [user2.id])
+ new_comment = create(:comment, comment: comment, commentable_type: 'Strategy', commentable_id: new_strategy.id, comment_by: user1.id, visibility: 'private', viewers: [user2.id])
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user1.uid,
@@ -143,7 +143,7 @@
end
it 'generates a valid comment object when visibility is all' do
- new_comment = create(:comment, comment: comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'all')
+ new_comment = create(:comment, comment: comment, commentable_type: 'Strategy', commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'all')
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user2.uid,
@@ -159,7 +159,7 @@
end
it 'generates a valid comment object when visibility is private' do
- new_comment = create(:comment, comment: comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'private', viewers: [user1.id])
+ new_comment = create(:comment, comment: comment, commentable_type: 'Strategy', commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'private', viewers: [user1.id])
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user2.uid,
@@ -187,7 +187,7 @@
context 'Comment posted by Meeting creator who is logged in' do
it 'generates a valid comment object' do
sign_in user1
- new_comment = create(:comment, comment: comment, commentable_type: 'meeting', commentable_id: new_meeting.id, comment_by: user1.id, visibility: 'all')
+ new_comment = create(:comment, comment: comment, commentable_type: 'Meeting', commentable_id: new_meeting.id, comment_by: user1.id, visibility: 'all')
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user1.uid,
@@ -206,7 +206,7 @@
context 'Comment posted by Meeting member who is logged in' do
it 'generates a valid comment object' do
sign_in user2
- new_comment = create(:comment, comment: comment, commentable_type: 'meeting', commentable_id: new_meeting.id, comment_by: user2.id, visibility: 'all')
+ new_comment = create(:comment, comment: comment, commentable_type: 'Meeting', commentable_id: new_meeting.id, comment_by: user2.id, visibility: 'all')
expect(controller.generate_comments(Comment.where(id: new_comment.id))).to eq([{
id: new_comment.id,
currentUserUid: user2.uid,
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index 2db1546ce1..2b8071ec01 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -27,7 +27,7 @@
is_expected.to validate_length_of(:comment).is_at_least(0).is_at_most(1000)
end
it do
- is_expected.to validate_inclusion_of(:commentable_type).in_array(%w[moment strategy meeting])
+ is_expected.to validate_inclusion_of(:commentable_type).in_array(%w[Moment Strategy Meeting])
end
it do
is_expected.to validate_inclusion_of(:visibility).in_array(%w[all private])
@@ -42,14 +42,16 @@
let(:user2) { create(:user2) }
let(:user3) { create(:user3) }
let(:short_comment) { 'Hello from the outside' }
- let(:long_comment) { 'Pretty as a picture, Sweeter than a swisher. Mad cause I\'m cuter than the girl that\'s witchya. I can talk about it cause I know that I\'m pretty' }
+ let(:long_comment) do
+ 'Pretty as a picture, Sweeter than a swisher. Mad cause I\'m cuter than the girl that\'s witchya. I can talk about it cause I know that I\'m pretty'
+ end
it 'posts a valid comment' do
expect(Comment.count).to eq(0)
new_moment = create(:moment, user_id: user1.id)
new_comment = create(:comment, commentable_id: new_moment.id, comment_by: user1.id, visibility: 'all')
expect(new_comment.comment).to eq('Test Comment')
- expect(new_comment.commentable_type).to eq('moment')
+ expect(new_comment.commentable_type).to eq('Moment')
expect(new_comment.commentable_id).to eq(new_moment.id)
expect(new_comment.comment_by).to eq(user1.id)
expect(new_comment.visibility).to eq('all')
@@ -68,14 +70,16 @@
it 'posts a comment by the same user who created the Moment' do
expect(Comment.count).to eq(0)
new_moment = create(:moment, user_id: user1.id)
- new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user1.id, visibility: 'all')
+ Comment.create_from!(comment: short_comment, commentable_type: 'Moment',
+ commentable_id: new_moment.id, comment_by: user1.id, visibility: 'all')
expect(Comment.count).to eq(1)
end
it 'posts a comment by a viewer of the Moment' do
expect(Comment.count).to eq(0)
new_moment = create(:moment, user_id: user1.id, viewers: [user2.id])
- new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user2.id, visibility: 'all')
+ Comment.create_from!(comment: short_comment, commentable_type: 'Moment',
+ commentable_id: new_moment.id, comment_by: user2.id, visibility: 'all')
expect(Comment.count).to eq(1)
end
end
@@ -84,14 +88,16 @@
it 'posts a comment by the same user who created the Strategy' do
expect(Comment.count).to eq(0)
new_strategy = create(:strategy, user_id: user1.id)
- new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user1.id, visibility: 'all')
+ Comment.create_from!(comment: short_comment, commentable_type: 'Strategy',
+ commentable_id: new_strategy.id, comment_by: user1.id, visibility: 'all')
expect(Comment.count).to eq(1)
end
it 'posts a comment by a viewer of the Strategy' do
expect(Comment.count).to eq(0)
new_strategy = create(:strategy, user_id: user1.id, viewers: [user2.id])
- new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'all')
+ Comment.create_from!(comment: short_comment, commentable_type: 'Strategy',
+ commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'all')
expect(Comment.count).to eq(1)
end
end
@@ -101,7 +107,8 @@
expect(Comment.count).to eq(0)
new_meeting = create :meeting
create :meeting_member, user_id: user1.id, leader: true, meeting_id: new_meeting.id
- new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'meeting', commentable_id: new_meeting.id, comment_by: user1.id, visibility: 'all')
+ Comment.create_from!(comment: short_comment, commentable_type: 'Meeting',
+ commentable_id: new_meeting.id, comment_by: user1.id, visibility: 'all')
expect(Comment.count).to eq(1)
end
end
@@ -109,18 +116,21 @@
describe 'comments' do
before do
+ another_commentable = if %w[Strategy Moment].include?(commentable.class.name)
+ create(commentable.class.name.downcase.to_sym, user: user1)
+ else
+ create(:meeting)
+ end
create(
:comment,
- commentable_id: 0,
- commentable_type: commentable_type,
+ commentable: another_commentable,
comment_by: user2.id,
comment: short_comment,
visibility: 'all'
)
create(
:comment,
- commentable_id: commentable.id,
- commentable_type: commentable_type,
+ commentable: commentable,
comment_by: user2.id,
comment: short_comment,
visibility: 'all'
@@ -128,18 +138,20 @@
end
context 'when commentable type is a moment' do
- let(:commentable) { create(:moment, comment: true, user_id: user1.id, viewers: [user2.id]) }
- let(:commentable_type) { 'moment' }
+ let(:commentable) { create(:moment, comment: true, user: user1, viewers: [user2.id]) }
+ let(:commentable_type) { 'Moment' }
it 'returns correct number of comments' do
+ # binding.pry
+
expect(Comment.comments_from(commentable).count).to eq(1)
expect(Comment.count).to eq(2)
end
end
context 'when commentable type is a strategy' do
- let(:commentable) { create(:strategy, comment: true, user_id: user1.id, viewers: [user2.id]) }
- let(:commentable_type) { 'strategy' }
+ let(:commentable) { create(:strategy, comment: true, user: user1, viewers: [user2.id]) }
+ let(:commentable_type) { 'Strategy' }
it 'returns correct number of comments' do
expect(Comment.comments_from(commentable).count).to eq(1)
@@ -149,10 +161,10 @@
context 'when commentable type is a meeting' do
let(:commentable) { create(:meeting) }
- let(:commentable_type) { 'meeting' }
+ let(:commentable_type) { 'Meeting' }
it 'returns correct number of comments' do
- create :meeting_member, user_id: user1.id, leader: true, meeting_id: commentable.id
+ create :meeting_member, user: user1, leader: true, meeting_id: commentable.id
expect(Comment.comments_from(commentable).count).to eq(1)
expect(Comment.count).to eq(2)
end
@@ -163,16 +175,18 @@
context 'Moments' do
it 'does not send a notification when the user created both the Moment and comment' do
new_moment = create(:moment, user_id: user1.id)
- new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user1.id, visibility: 'all')
+ new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'Moment',
+ commentable_id: new_moment.id, comment_by: user1.id, visibility: 'all')
new_comment.notify_of_creation!(user1)
expect(Notification.count).to eq(0)
end
it 'sends a notification when a viewer comments on a Moment and visibility is all' do
new_moment = create(:moment, user_id: user1.id, viewers: [user2.id])
- new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user2.id, visibility: 'all')
+ new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'Moment',
+ commentable_id: new_moment.id, comment_by: user2.id, visibility: 'all')
new_comment.notify_of_creation!(user2)
- uniqueid = "comment_on_moment_#{new_comment.id}"
+ uniqueid = "comment_on_Moment_#{new_comment.id}"
expect(Notification.count).to eq(1)
expect(Notification.last.user_id).to eq(user1.id)
expect(Notification.last.uniqueid).to eq(uniqueid)
@@ -182,7 +196,7 @@
'commentid' => new_comment.id,
'comment' => long_comment[0..80],
'cutoff' => true,
- 'type' => 'comment_on_moment',
+ 'type' => 'comment_on_Moment',
'uniqueid' => uniqueid,
'typeid' => new_moment.id,
'typename' => new_moment.name
@@ -191,9 +205,10 @@
it 'sends a notification when a viewer comments on a Moment and visibility is private' do
new_moment = create(:moment, user_id: user1.id, viewers: [user2.id])
- new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'moment', commentable_id: new_moment.id, comment_by: user2.id, visibility: 'private')
+ new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'Moment',
+ commentable_id: new_moment.id, comment_by: user2.id, visibility: 'private')
new_comment.notify_of_creation!(user2)
- uniqueid = "comment_on_moment_private_#{new_comment.id}"
+ uniqueid = "comment_on_Moment_private_#{new_comment.id}"
expect(Notification.count).to eq(1)
expect(Notification.last.user_id).to eq(user1.id)
expect(Notification.last.uniqueid).to eq(uniqueid)
@@ -203,7 +218,7 @@
'commentid' => new_comment.id,
'comment' => long_comment[0..80],
'cutoff' => true,
- 'type' => 'comment_on_moment_private',
+ 'type' => 'comment_on_Moment_private',
'uniqueid' => uniqueid,
'typeid' => new_moment.id,
'typename' => new_moment.name
@@ -214,16 +229,18 @@
context 'Strategies' do
it 'does not send a notification when the user created both the Strategy and comment' do
new_strategy = create(:strategy, user_id: user1.id)
- new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user1.id, visibility: 'all')
+ new_comment = Comment.create_from!(comment: short_comment, commentable_type: 'Strategy',
+ commentable_id: new_strategy.id, comment_by: user1.id, visibility: 'all')
new_comment.notify_of_creation!(user1)
expect(Notification.count).to eq(0)
end
it 'sends a notification when a viewer comments on a Strategy and visibility is all' do
new_strategy = create(:strategy, user_id: user1.id, viewers: [user2.id])
- new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'all')
+ new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'Strategy',
+ commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'all')
new_comment.notify_of_creation!(user2)
- uniqueid = "comment_on_strategy_#{new_comment.id}"
+ uniqueid = "comment_on_Strategy_#{new_comment.id}"
expect(Notification.count).to eq(1)
expect(Notification.last.user_id).to eq(user1.id)
expect(Notification.last.uniqueid).to eq(uniqueid)
@@ -233,7 +250,7 @@
'commentid' => new_comment.id,
'comment' => long_comment[0..80],
'cutoff' => true,
- 'type' => 'comment_on_strategy',
+ 'type' => 'comment_on_Strategy',
'uniqueid' => uniqueid,
'typeid' => new_strategy.id,
'typename' => new_strategy.name
@@ -242,9 +259,10 @@
it 'sends a notification when a viewer comments on a Strategy and visibility is private' do
new_strategy = create(:strategy, user_id: user1.id, viewers: [user2.id])
- new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'strategy', commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'private')
+ new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'Strategy',
+ commentable_id: new_strategy.id, comment_by: user2.id, visibility: 'private')
new_comment.notify_of_creation!(user2)
- uniqueid = "comment_on_strategy_private_#{new_comment.id}"
+ uniqueid = "comment_on_Strategy_private_#{new_comment.id}"
expect(Notification.count).to eq(1)
expect(Notification.last.user_id).to eq(user1.id)
expect(Notification.last.uniqueid).to eq(uniqueid)
@@ -254,7 +272,7 @@
'commentid' => new_comment.id,
'comment' => long_comment[0..80],
'cutoff' => true,
- 'type' => 'comment_on_strategy_private',
+ 'type' => 'comment_on_Strategy_private',
'uniqueid' => uniqueid,
'typeid' => new_strategy.id,
'typename' => new_strategy.name
@@ -269,7 +287,8 @@
create :meeting_member, user_id: user1.id, leader: true, meeting_id: new_meeting.id
create :meeting_member, user_id: user2.id, leader: false, meeting_id: new_meeting.id
create :meeting_member, user_id: user3.id, leader: false, meeting_id: new_meeting.id
- new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'meeting', commentable_id: new_meeting.id, comment_by: user3.id, visibility: 'all')
+ new_comment = Comment.create_from!(comment: long_comment, commentable_type: 'Meeting',
+ commentable_id: new_meeting.id, comment_by: user3.id, visibility: 'all')
new_comment.notify_of_creation!(user3)
expect(Notification.count).to eq(2)
@@ -280,8 +299,8 @@
'commentid' => new_comment.id,
'comment' => long_comment[0..80],
'cutoff' => true,
- 'type' => 'comment_on_meeting',
- 'uniqueid' => "comment_on_meeting_#{new_comment.id}",
+ 'type' => 'comment_on_Meeting',
+ 'uniqueid' => "comment_on_Meeting_#{new_comment.id}",
'typeid' => new_meeting.id,
'typename' => new_meeting.name
}
diff --git a/spec/models/meeting_member_spec.rb b/spec/models/meeting_member_spec.rb
index dbbe621b72..78fdfb5798 100644
--- a/spec/models/meeting_member_spec.rb
+++ b/spec/models/meeting_member_spec.rb
@@ -21,7 +21,7 @@
context 'with relations' do
it { is_expected.to belong_to :meeting }
it { is_expected.to belong_to :user }
- it { is_expected.to belong_to :group_member }
+ it { is_expected.to belong_to(:group_member).optional }
end
it 'has a valid factory' do
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 151b15a900..b3f1494861 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -16,7 +16,7 @@
context 'with relations' do
it { is_expected.to belong_to :reporter }
it { is_expected.to belong_to :reportee }
- it { is_expected.to belong_to :comment }
+ it { is_expected.to belong_to(:comment).optional }
end
context 'with validations' do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 2d693ca2f3..e8215b0aed 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -75,7 +75,7 @@
it { is_expected.to have_many :moods }
it { is_expected.to have_many :moments }
it { is_expected.to have_many :categories }
- it { is_expected.to belong_to :invited_by }
+ it { is_expected.to belong_to(:invited_by).optional }
end
context 'with validations' do
diff --git a/spec/requests/categories_spec.rb b/spec/requests/categories_spec.rb
index 29316903e4..f6ac271c89 100644
--- a/spec/requests/categories_spec.rb
+++ b/spec/requests/categories_spec.rb
@@ -2,6 +2,7 @@
describe 'Categories', type: :request do
let(:user) { create(:user) }
+ let(:user1) { create(:user1) }
let(:category) { create(:category, user_id: user.id) }
describe '#index' do
@@ -89,7 +90,7 @@
end
context 'user is trying to edit a category another user created' do
- let(:other_category) { create(:category, user_id: user.id + 1) }
+ let(:other_category) { create(:category, user_id: user1.id) }
before { get edit_category_path(other_category.id) }
it 'redirects to the category path' do
diff --git a/spec/requests/comments_spec.rb b/spec/requests/comments_spec.rb
index 6e482ce6cd..33d17418e9 100644
--- a/spec/requests/comments_spec.rb
+++ b/spec/requests/comments_spec.rb
@@ -41,7 +41,7 @@
let(:comment_params) do
attributes_for(
:comment,
- commentable_type: 'moment',
+ commentable_type: 'Moment',
comment_by: user.id
).merge(relational_args)
end
@@ -63,7 +63,7 @@
let(:comment_params) do
attributes_for(
:comment,
- commentable_type: 'strategy',
+ commentable_type: 'Strategy',
comment_by: user.id
).merge(relational_args)
end
@@ -86,7 +86,7 @@
attributes_for(
:comment,
commentable_type:
- 'meeting',
+ 'Meeting',
comment_by: user.id
).merge(relational_args)
end
@@ -150,7 +150,7 @@
create(
:comment,
commentable_id: moment.id,
- commentable_type: 'moment',
+ commentable_type: 'Moment',
comment_by: current_user.id
).id
end
@@ -202,7 +202,7 @@
create(
:comment,
commentable_id: strategy.id,
- commentable_type: 'strategy',
+ commentable_type: 'Strategy',
comment_by: current_user.id
).id
end
@@ -263,7 +263,7 @@
create(
:comment,
commentable_id: meeting.id,
- commentable_type: 'meeting',
+ commentable_type: 'Meeting',
comment_by: current_user.id
).id
end
diff --git a/spec/requests/groups_spec.rb b/spec/requests/groups_spec.rb
index 8ca72c35fc..9b5f229291 100644
--- a/spec/requests/groups_spec.rb
+++ b/spec/requests/groups_spec.rb
@@ -9,7 +9,7 @@
it 'renders page with groups that the user belongs to' do
group = create :group_with_member, user_id: user.id, name: 'group one'
- other_user = build_stubbed(:user2)
+ other_user = create(:user2)
other_group = create :group_with_member,
user_id: other_user.id,
name: 'group two'
diff --git a/spec/requests/moods_spec.rb b/spec/requests/moods_spec.rb
index 9c79151100..15f635d4b3 100644
--- a/spec/requests/moods_spec.rb
+++ b/spec/requests/moods_spec.rb
@@ -2,8 +2,9 @@
describe 'Moods', type: :request do
let(:user) { create(:user1) }
+ let(:another_user) { create(:user) }
let(:user_mood) { create(:mood, user_id: user.id) }
- let(:other_mood) { create(:mood, user_id: user.id + 1) }
+ let(:other_mood) { create(:mood, user_id: another_user.id) }
let(:valid_mood_params) { attributes_for(:mood) }
let(:invalid_mood_params) { { name: nil, description: nil } }
let(:json_header) { { "ACCEPT" => "application/json" } }
diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb
index 6ba752ba11..70594b10bf 100644
--- a/spec/requests/notifications_spec.rb
+++ b/spec/requests/notifications_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
describe 'Notification', type: :request do
- let(:previous_page) { 'http://example.com/previous' }
+ let(:previous_page) { 'http://www.example.com/notifications' }
let(:format) { 'text/html' }
let(:headers) do
{
diff --git a/spec/services/comment_notifications_service_spec.rb b/spec/services/comment_notifications_service_spec.rb
index 066e46f642..c685468b27 100644
--- a/spec/services/comment_notifications_service_spec.rb
+++ b/spec/services/comment_notifications_service_spec.rb
@@ -5,7 +5,6 @@
let(:ally) { user.allies.first }
context '#remove' do
- subject { described_class.remove(params) }
let!(:params) do
{
comment_id: comment.id,
@@ -14,9 +13,12 @@
end
context 'when model_name is moment' do
- let!(:model_name) { 'moment' }
+ let!(:model_name) { 'Moment' }
let!(:moment) { create(:moment, user_id: user.id, viewers: [ally.id]) }
- let!(:comment) { Comment.create_from!(comment: 'Hello', commentable_type: model_name, commentable_id: moment.id, comment_by: ally.id, visibility: visibility) }
+ let!(:comment) do
+ Comment.create_from!(comment: 'Hello', commentable_type: model_name, commentable_id: moment.id, comment_by: ally.id,
+ visibility: visibility)
+ end
context 'when comment visibility is all' do
let!(:visibility) { 'all' }
@@ -25,7 +27,8 @@
comment.notify_of_creation!(ally)
expect(Comment.count).to eq(1)
expect(Notification.count).to eq(1)
- subject
+ described_class
+ .new(comment_id: comment.id, model_name: 'Moment').remove
expect(Comment.count).to eq(0)
expect(Notification.count).to eq(0)
end
@@ -38,7 +41,8 @@
comment.notify_of_creation!(ally)
expect(Comment.count).to eq(1)
expect(Notification.count).to eq(1)
- subject
+ described_class
+ .new(comment_id: comment.id, model_name: 'Moment').remove
expect(Comment.count).to eq(0)
expect(Notification.count).to eq(0)
end
@@ -46,9 +50,12 @@
end
context 'when model_name is strategy' do
- let!(:model_name) { 'strategy' }
+ let!(:model_name) { 'Strategy' }
let!(:strategy) { create(:strategy, user_id: user.id, viewers: [ally.id]) }
- let!(:comment) { Comment.create_from!(comment: 'Hello', commentable_type: model_name, commentable_id: strategy.id, comment_by: ally.id, visibility: visibility) }
+ let!(:comment) do
+ Comment.create_from!(comment: 'Hello', commentable_type: model_name, commentable_id: strategy.id, comment_by: ally.id,
+ visibility: visibility)
+ end
context 'when comment visibility is all' do
let!(:visibility) { 'all' }
@@ -57,7 +64,8 @@
comment.notify_of_creation!(ally)
expect(Comment.count).to eq(1)
expect(Notification.count).to eq(1)
- subject
+ described_class
+ .new(comment_id: comment.id, model_name: 'Strategy').remove
expect(Comment.count).to eq(0)
expect(Notification.count).to eq(0)
end
@@ -70,7 +78,8 @@
comment.notify_of_creation!(ally)
expect(Comment.count).to eq(1)
expect(Notification.count).to eq(1)
- subject
+ described_class
+ .new(comment_id: comment.id, model_name: 'Strategy').remove
expect(Comment.count).to eq(0)
expect(Notification.count).to eq(0)
end
@@ -78,18 +87,22 @@
end
context 'when model_name is meeting' do
- let!(:model_name) { 'meeting' }
+ let!(:model_name) { 'Meeting' }
let!(:group) { create :group }
let!(:meeting) { create :meeting, group_id: group.id }
let!(:member1) { create :meeting_member, user_id: user.id, leader: true, meeting_id: meeting.id }
let!(:member2) { create :meeting_member, user_id: ally.id, leader: false, meeting_id: meeting.id }
- let!(:comment) { Comment.create_from!(comment: 'Hello', commentable_type: model_name, commentable_id: meeting.id, comment_by: ally.id, visibility: 'all') }
+ let!(:comment) do
+ Comment.create_from!(comment: 'Hello', commentable_type: model_name, commentable_id: meeting.id, comment_by: ally.id,
+ visibility: 'all')
+ end
it 'remove comments and notifications related to that meeting' do
comment.notify_of_creation!(ally)
expect(Comment.count).to eq(1)
expect(Notification.count).to eq(1)
- subject
+ described_class
+ .new(comment_id: comment.id, model_name: 'Meeting').remove
expect(Comment.count).to eq(0)
expect(Notification.count).to eq(0)
end
diff --git a/spec/services/comment_viewers_service_spec.rb b/spec/services/comment_viewers_service_spec.rb
index d129490eb7..8c9f1c69ea 100644
--- a/spec/services/comment_viewers_service_spec.rb
+++ b/spec/services/comment_viewers_service_spec.rb
@@ -8,11 +8,11 @@
let(:moment) { create(:moment, user_id: owner.id) }
let(:commentable) do
{
- strategy: strategy,
- moment: moment
+ Strategy: strategy,
+ Moment: moment
}
end
- %i[strategy moment].each do |commentable_name|
+ %i[Strategy Moment].each do |commentable_name|
let(:my_commentable) { commentable[commentable_name] }
let(:comment) do
Comment.create!(commentable_type: commentable_name,
diff --git a/spec/services/meeting_notifications_service_spec.rb b/spec/services/meeting_notifications_service_spec.rb
index f78100545b..a59830ad8d 100644
--- a/spec/services/meeting_notifications_service_spec.rb
+++ b/spec/services/meeting_notifications_service_spec.rb
@@ -5,21 +5,18 @@
let(:ally) { user.allies.first }
context '#handle_members' do
- subject { described_class.handle_members(params) }
+ subject do
+ described_class.new(current_user: user,
+ meeting: meeting,
+ type: type,
+ members: members).handle_members
+ end
let!(:group) { create :group }
let!(:meeting) { create :meeting, group_id: group.id }
let!(:member1) { create :meeting_member, user_id: user.id, leader: true, meeting_id: meeting.id }
let!(:member2) { create :meeting_member, user_id: ally.id, leader: false, meeting_id: meeting.id }
let!(:members) { meeting.members }
let!(:uniqueid) { "#{type}_#{user.id}" }
- let!(:params) do
- {
- current_user: user,
- meeting: meeting,
- type: type,
- members: members
- }
- end
context 'when type is remove_meeting' do
let!(:type) { 'remove_meeting' }