Compare commits

..

2 Commits

Author SHA1 Message Date
Brenda Wallace
f5377662cf Merge remote-tracking branch 'upstream/dev' into feature/dotenv 2020-08-01 20:17:33 +12:00
Brenda Wallace
efc2e70bf8 Remove figaro gem and use rails-dotenv 2020-08-01 20:16:33 +12:00
87 changed files with 564 additions and 942 deletions

View File

@@ -1,37 +1,28 @@
plugins:
brakeman:
enabled: false # codeclimate's brakeman is stuck in rails 5 rules
bundler-audit:
engines:
rubocop:
enabled: true
channel: "rubocop-0-88"
scss-lint:
enabled: true
shellcheck:
enabled: true
eslint:
enabled: true
coffeelint:
enabled: true
brakeman:
enabled: true
bundler-audit:
enabled: true
duplication:
enabled: true
config:
languages:
- ruby
- javascript
editorconfig:
enabled: true
eslint:
enabled: true
fixme:
enabled: true
haml-lint:
enabled: true
nodesecurity:
enabled: true
rubocop:
enabled: true
channel: "rubocop-1-11"
scss-lint:
enabled: true
shellcheck:
enabled: true
ratings:
paths:
- "**.rb"
- "**.ru"
- "**.js"
- "**.coffee"
- "**.scss"

View File

@@ -1,59 +0,0 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
time: "07:00"
open-pull-requests-limit: 10
versioning-strategy: lockfile-only
ignore:
- dependency-name: active_median
versions:
- "< 0.2.2, >= 0.2.1.a"
- dependency-name: rubocop
versions:
- "< 0.63, >= 0.62.a"
- dependency-name: rubocop
versions:
- "< 0.64, >= 0.63.a"
- dependency-name: sidekiq
versions:
- 5.2.4
- dependency-name: oj
versions:
- 3.11.4
- dependency-name: listen
versions:
- 3.5.0
- dependency-name: rspec-rails
versions:
- 4.1.0
- 5.0.0
- dependency-name: searchkick
versions:
- 4.4.3
- dependency-name: rswag-api
versions:
- 2.3.3
- dependency-name: rswag-specs
versions:
- 2.3.3
- dependency-name: rswag-ui
versions:
- 2.3.3
- dependency-name: timecop
versions:
- 0.9.3
- dependency-name: puma
versions:
- 5.2.0
- dependency-name: capybara
versions:
- 3.35.1
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "07:00"
open-pull-requests-limit: 10

View File

@@ -1,44 +0,0 @@
# This workflow integrates Brakeman with GitHub's Code Scanning feature
# Brakeman is a static analysis security vulnerability scanner for Ruby on Rails applications
name: Brakeman Scan
# This section configures the trigger for the workflow. Feel free to customize depending on your convention
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
jobs:
brakeman-scan:
name: Brakeman Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2.3.4
# Customize the ruby version depending on your needs
- name: Setup Ruby
uses: actions/setup-ruby@v1.1.3
with:
ruby-version: '2.7'
- name: Setup Brakeman
env:
BRAKEMAN_VERSION: '4.10' # SARIF support is provided in Brakeman version 4.10+
run: |
gem install brakeman --version $BRAKEMAN_VERSION
# Execute Brakeman CLI and generate a SARIF output with the security issues identified during the analysis
- name: Scan
continue-on-error: true
run: |
brakeman -f sarif -o output.sarif.json .
# Upload the SARIF file generated in the previous step
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: output.sarif.json

View File

@@ -1,122 +0,0 @@
name: CI
on: [pull_request]
jobs:
contributors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- name: Install ruby version specified in .ruby-version
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install gem bundle
run: |
gem install bundler
bundle install
- name: Check contributors
run: |
bundle exec script/check_contributors_md.rb
rspec:
runs-on: ubuntu-latest
services:
db:
image: postgres
env:
##
# The Postgres service fails its docker health check unless you
# specify these environment variables
#
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: growstuff_test
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
APP_DOMAIN_NAME: localhost:3000
APP_PROTOCOL: http
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
DATABASE_URL: postgres://postgres:postgres@localhost:5432/growstuff_test
DEVISE_SECRET_KEY: secret
ELASTIC_SEARCH_VERSION: "7.5.1-amd64"
GROWSTUFF_EMAIL: "noreply@test.growstuff.org"
GROWSTUFF_FLICKR_KEY: secretkey"
GROWSTUFF_FLICKR_SECRET: secretsecret
GROWSTUFF_SITE_NAME: "Growstuff (travis)"
RAILS_ENV: test
RAILS_SECRET_TOKEN: supersecret
steps:
- name: Checkout this repo
uses: actions/checkout@v2.3.4
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Start Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.5.1
##
# Cache Yarn modules
#
# See https://github.com/actions/cache/blob/master/examples.md#node---yarn for details
#
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Setup yarn cache
uses: actions/cache@v2.1.5
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install required OS packages
run: |
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v2.4.0
with:
node-version: '12'
- name: Install Ruby (version given by .ruby-version) and Bundler
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install required JS packages
run: yarn install
- name: install chrome
run: sudo apt-get install google-chrome-stable
- name: Prepare database for testing
run: bundle exec rails db:prepare
- name: precompile assets
run: bundle exec rails assets:precompile
- name: index into elastic search
run: bundle exec rails search:reindex
- name: Run rspec (report results to Percy.io and CodeClimate)
run: bundle exec rspec spec -fd
- name: Report to code climate
run: |
gem install codeclimate-test-reporter
codeclimate-test-reporter

1
.gitignore vendored
View File

@@ -1,6 +1,5 @@
.byebug_history
.bundle
.env
# Folders to ignore
/log

View File

@@ -1,11 +1,10 @@
inherit_from: .rubocop_todo.yml
require: rubocop-rails
AllCops:
NewCops: enable
Exclude:
- 'db/schema.rb'
- 'vendor/**/*'
TargetRailsVersion: 6.0
TargetRailsVersion: 5.2
Rails:
Enabled: true

View File

@@ -1 +1 @@
2.7.2
2.6.5

View File

@@ -1,18 +1,52 @@
sudo: required
language: ruby
dist: bionic
branches:
only:
- mainline
- dev
services:
- postgresql
- xvfb
cache:
bundler: true
yarn: true
directories:
- tmp/cache/assets/test/sprockets
addons:
postgresql: "9.4"
code_climate:
repo_token:
secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk="
env:
matrix:
- ELASTIC_SEARCH_VERSION="7.5.1-amd64" COVERAGE=true RAILS_ENV=test # Future target (production needs upgrading)
- STATIC_CHECKS=true
global:
- secure: "Z5TpM2jEX4UCvNePnk/LwltQX48U2u9BRc+Iypr1x9QW2o228QJhPIOH39a8RMUrepGnkQIq9q3ZRUn98RfrJz1yThtlNFL3NmzdQ57gKgjGwfpa0e4Dwj/ZJqV2D84tDGjvdVYLP7zzaYZxQcwk/cgNpzKf/jq97HLNP7CYuf4="
- GROWSTUFF_EMAIL="noreply@test.growstuff.org"g
- GROWSTUFF_SITE_NAME="Growstuff (travis)"
- RAILS_SECRET_TOKEN='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
before_install:
- sudo apt clean
- sudo apt update
- sudo apt install dpkg
- ./script/install_elasticsearch.sh
- sudo apt install google-chrome-stable
- ./script/install_linters.sh
- ./script/check_elasticsearch.sh
script:
- >
if [ "${STATIC_CHECKS}" = "true" ]; then
./script/check_static.rb
else
bundle exec rails db:create db:migrate;
bundle exec rails assets:precompile;
bundle exec rails search:reindex;
bundle exec rspec spec;
# npx percy exec -- bundle exec rspec spec # <- run this to send screen shots to percy
fi;
after_script:
- >
if [ "${COVERAGE}" = "true" ]; then
gem install codeclimate-test-reporter
codeclimate-test-reporter
fi
before_deploy:
- bundle exec script/heroku_maintenance.rb on
deploy:
@@ -25,6 +59,7 @@ deploy:
dev: growstuff-staging
mainline: growstuff-prod
run:
- "rake db:migrate"
- "script/deploy-tasks.sh"
- restart
after_deploy:

View File

@@ -91,11 +91,9 @@ submit the change with your pull request.
- Taylor William / [bestest-mensch](https://github.com/bestest-mensch)
- André Aubin / [lambda2](https://github.com/lambda2)
- Martina Simicic / [simicic](https://github.com/simicic)
- Rowan Crawford / [wombleton](https://github.com/wombleton)
- Le-jun - [lejun](https://github.com/le-jun)
## Bots
### Security and Dependency Updates
- DeppBot / [deppbot](https://github.com/deppbot)
- `dependabot[bot]` [dependabot](https://github.com/dependabot-bot) / [dependabot-preview](https://github.com/apps/dependabot-preview)
- dependabot-preview[bot] [dependabot](https://github.com/dependabot-bot) / [dependabot-preview](https://github.com/apps/dependabot-preview)

12
Gemfile
View File

@@ -2,10 +2,9 @@
source 'https://rubygems.org'
# Match ruby version in .ruby-version
ruby File.read('.ruby-version')
ruby '2.6.5'
gem 'rails', '6.0.3.2'
gem 'rails', '5.2.4.3'
# Keeping old sprockets
# https://github.com/rails/sprockets-rails/issues/444#issuecomment-637817050
@@ -39,7 +38,7 @@ gem 'oj' # Speeds up json
# planting and harvest predictions
# based on median values for the crop
gem 'active_median', '0.2.0'
gem 'active_median', '0.1.4' # needs postgresql update https://github.com/Growstuff/growstuff/issues/1757
gem 'active_record_union'
gem 'flickraw'
@@ -113,7 +112,7 @@ gem 'rake', '>= 10.0.0'
gem "responders"
# allows soft delete. Used for members.
gem 'discard', '>= 1.2'
gem 'discard', '~> 1.0'
gem 'xmlrpc' # fixes rake error - can be removed if not needed later
@@ -166,6 +165,7 @@ group :development, :test do
gem 'dotenv-rails'
# cli utils
gem 'coveralls', require: false # coverage analysis
gem 'haml-i18n-extractor', require: false
gem 'haml_lint', '>= 0.25.1', require: false # Checks haml files for goodness
gem 'i18n-tasks', require: false # adds tests for finding missing and unused translations
@@ -175,7 +175,7 @@ end
group :test do
gem 'codeclimate-test-reporter', require: false
gem 'percy-capybara'
gem 'percy-capybara', '~> 4.0.0'
gem 'rails-controller-testing'
gem 'selenium-webdriver'
gem 'timecop'

View File

@@ -3,85 +3,72 @@ GEM
remote: https://rails-assets.org/
specs:
abstract_type (0.0.7)
actioncable (6.0.3.2)
actionpack (= 6.0.3.2)
actioncable (5.2.4.3)
actionpack (= 5.2.4.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
mail (>= 2.7.1)
actionmailer (6.0.3.2)
actionpack (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
actionmailer (5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.2)
actionview (= 6.0.3.2)
activesupport (= 6.0.3.2)
actionpack (5.2.4.3)
actionview (= 5.2.4.3)
activesupport (= 5.2.4.3)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.2)
actionpack (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
nokogiri (>= 1.8.5)
actionview (6.0.3.2)
activesupport (= 6.0.3.2)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.4.3)
activesupport (= 5.2.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_link_to (1.0.5)
actionpack
addressable
active_median (0.2.0)
activerecord (>= 4.2)
active_median (0.1.4)
activerecord
active_record_union (1.3.0)
activerecord (>= 4.0)
active_utils (3.3.17)
activesupport (>= 4.2)
i18n
activejob (6.0.3.2)
activesupport (= 6.0.3.2)
activejob (5.2.4.3)
activesupport (= 5.2.4.3)
globalid (>= 0.3.6)
activemodel (6.0.3.2)
activesupport (= 6.0.3.2)
activerecord (6.0.3.2)
activemodel (= 6.0.3.2)
activesupport (= 6.0.3.2)
activestorage (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
activemodel (5.2.4.3)
activesupport (= 5.2.4.3)
activerecord (5.2.4.3)
activemodel (= 5.2.4.3)
activesupport (= 5.2.4.3)
arel (>= 9.0)
activestorage (5.2.4.3)
actionpack (= 5.2.4.3)
activerecord (= 5.2.4.3)
marcel (~> 0.3.1)
activesupport (6.0.3.2)
activesupport (5.2.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)
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
addressable (2.8.0)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
anima (0.3.1)
abstract_type (~> 0.0.7)
adamantium (~> 0.2)
equalizer (~> 0.0.11)
ast (2.4.2)
autoprefixer-rails (10.2.4.0)
arel (9.0.0)
ast (2.4.1)
autoprefixer-rails (9.7.6)
execjs
bcrypt (3.1.16)
better_errors (2.9.1)
bcrypt (3.1.13)
better_errors (2.7.1)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
@@ -89,7 +76,7 @@ GEM
bonsai-elasticsearch-rails (7.0.1)
elasticsearch-model (< 8)
elasticsearch-rails (< 8)
bootstrap (4.6.0)
bootstrap (4.5.0)
autoprefixer-rails (>= 9.1.0)
popper_js (>= 1.14.3, < 2)
sassc-rails (>= 2.0.0)
@@ -99,34 +86,33 @@ GEM
actionpack (>= 5.2)
activemodel (>= 5.2)
builder (3.2.4)
bullet (6.1.4)
bullet (6.1.0)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (11.1.3)
cancancan (3.2.1)
capybara (3.35.3)
cancancan (3.1.0)
capybara (3.33.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
regexp_parser (~> 1.5)
xpath (~> 3.2)
capybara-email (3.0.2)
capybara (>= 2.4, < 4.0)
mail
capybara-screenshot (1.0.25)
capybara-screenshot (1.0.24)
capybara (>= 1.0, < 4)
launchy
carrierwave (2.1.1)
carrierwave (2.1.0)
activemodel (>= 5.0.0)
activesupport (>= 5.0.0)
addressable (~> 2.6)
image_processing (~> 1.1)
mimemagic (>= 0.3.0)
mini_mime (>= 0.1.3)
ssrf_filter (~> 1.0)
chartkick (4.0.4)
chartkick (3.3.2)
childprocess (3.0.0)
codeclimate-test-reporter (1.0.9)
simplecov (<= 0.13)
@@ -154,25 +140,26 @@ GEM
concord (0.1.5)
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
concurrent-ruby (1.1.8)
concurrent-ruby (1.1.6)
connection_pool (2.2.3)
coveralls (0.8.19)
json (>= 1.8, < 3)
simplecov (~> 0.12.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
tins (~> 1.6)
crass (1.0.6)
csv_shaper (1.3.2)
csv_shaper (1.3.1)
activesupport (>= 3.0.0)
dalli (2.7.11)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
devise (4.8.0)
dalli (2.7.10)
database_cleaner (1.8.5)
devise (4.7.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.4.4)
diff-lcs (1.3)
discard (1.2.0)
activerecord (>= 4.2, < 7)
docile (1.1.5)
@@ -180,57 +167,42 @@ GEM
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
elasticsearch (6.8.3)
elasticsearch-api (= 6.8.3)
elasticsearch-transport (= 6.8.3)
elasticsearch-api (6.8.3)
elasticsearch (6.8.2)
elasticsearch-api (= 6.8.2)
elasticsearch-transport (= 6.8.2)
elasticsearch-api (6.8.2)
multi_json
elasticsearch-model (7.1.1)
elasticsearch-model (7.1.0)
activesupport (> 3)
elasticsearch (> 1)
hashie
elasticsearch-rails (7.1.0)
elasticsearch-transport (6.8.3)
elasticsearch-transport (6.8.2)
faraday (~> 1)
multi_json
equalizer (0.0.11)
erubi (1.10.0)
erubi (1.9.0)
erubis (2.7.0)
excon (0.78.1)
excon (0.73.0)
execjs (2.7.0)
factory_bot (6.2.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
factory_bot_rails (6.1.0)
factory_bot (~> 6.1.0)
railties (>= 5.0.0)
faker (2.18.0)
faker (2.13.0)
i18n (>= 1.6, < 2)
faraday (1.5.1)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
faraday-patron (1.0.0)
faraday_middleware (1.0.0)
faraday (~> 1.0)
ffi (1.15.0)
ffi (1.13.0)
flickraw (0.9.10)
font-awesome-sass (5.15.1)
font-awesome-sass (5.13.0)
sassc (>= 1.11)
friendly_id (5.4.2)
friendly_id (5.3.0)
activerecord (>= 4.0.0)
geocoder (1.6.7)
geocoder (1.6.3)
gibbon (1.2.1)
httparty
multi_json (>= 1.9.0)
@@ -239,7 +211,7 @@ GEM
gravatar-ultimate (2.0.0)
activesupport (>= 2.3.14)
rack
haml (5.2.1)
haml (5.1.2)
temple (>= 0.8.0)
tilt
haml-i18n-extractor (0.5.9)
@@ -254,9 +226,8 @@ GEM
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 5.1)
haml_lint (0.37.1)
haml (>= 4.0, < 5.3)
parallel (~> 1.10)
haml_lint (0.35.0)
haml (>= 4.0, < 5.2)
rainbow
rubocop (>= 0.50.0)
sysexits (~> 1.1)
@@ -272,12 +243,12 @@ GEM
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
httparty (0.18.1)
httparty (0.18.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.10)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
i18n-tasks (0.9.34)
i18n-tasks (0.9.31)
activesupport (>= 4.0.2)
ast (>= 2.1.0)
erubi
@@ -288,7 +259,7 @@ GEM
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
ice_nine (0.11.2)
image_processing (1.12.1)
image_processing (1.11.0)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
jquery-rails (4.4.0)
@@ -297,30 +268,31 @@ GEM
thor (>= 0.14, < 2.0)
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
js-routes (1.4.14)
js-routes (1.4.9)
railties (>= 4)
json (2.3.1)
sprockets-rails
json (2.3.0)
json-schema (2.8.1)
addressable (>= 2.4)
jsonapi-resources (0.10.4)
jsonapi-resources (0.10.2)
activerecord (>= 4.1)
concurrent-ruby
railties (>= 4.1)
jsonapi-swagger (0.8.1)
jwt (2.2.2)
jsonapi-swagger (0.8.0)
jwt (2.2.1)
kgio (2.11.3)
kramdown (2.3.1)
kramdown (2.2.1)
rexml
launchy (2.5.0)
addressable (~> 2.7)
leaflet-rails (1.7.0)
leaflet-rails (1.6.0)
rails (>= 4.2.0)
letter_opener (1.7.0)
launchy (~> 2.2)
listen (3.5.1)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.9.1)
loofah (2.6.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
@@ -342,33 +314,30 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_magick (4.11.0)
mimemagic (0.3.5)
mini_magick (4.10.1)
mini_mime (1.0.2)
mini_portile2 (2.5.1)
minitest (5.14.4)
mini_portile2 (2.4.0)
minitest (5.14.1)
moneta (1.0.0)
multi_json (1.15.0)
multi_json (1.14.1)
multi_xml (0.6.0)
multipart-post (2.1.1)
nio4r (2.5.7)
nokogiri (1.11.4)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
oauth (0.5.6)
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oauth (0.5.4)
oauth2 (1.4.4)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (3.12.1)
oj (3.10.8)
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
omniauth-facebook (8.0.0)
omniauth-facebook (6.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-flickr (0.0.20)
multi_json (~> 1.12)
@@ -376,49 +345,47 @@ GEM
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.7.0)
oauth2 (~> 1.4)
omniauth-oauth2 (1.6.0)
oauth2 (~> 1.1)
omniauth (~> 1.9)
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
orm_adapter (0.5.0)
parallel (1.20.1)
parser (2.7.2.0)
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
percy-capybara (4.3.3)
percy-capybara (4.0.2)
pg (0.21.0)
platform-api (3.3.0)
platform-api (3.0.0)
heroics (~> 0.1.1)
moneta (~> 1.0.0)
rate_throttle_client (~> 0.1.0)
popper_js (1.16.0)
public_suffix (4.0.6)
puma (5.3.2)
procto (0.0.3)
public_suffix (4.0.5)
puma (4.3.5)
nio4r (~> 2.0)
query_diet (0.7.0)
racc (1.5.2)
query_diet (0.6.2)
rack (2.2.3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-protection (2.1.0)
rack-protection (2.0.8.1)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.2)
actioncable (= 6.0.3.2)
actionmailbox (= 6.0.3.2)
actionmailer (= 6.0.3.2)
actionpack (= 6.0.3.2)
actiontext (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
activemodel (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
rails (5.2.4.3)
actioncable (= 5.2.4.3)
actionmailer (= 5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
activemodel (= 5.2.4.3)
activerecord (= 5.2.4.3)
activestorage (= 5.2.4.3)
activesupport (= 5.2.4.3)
bundler (>= 1.3.0)
railties (= 6.0.3.2)
railties (= 5.2.4.3)
sprockets-rails (>= 2.0.0)
rails-assets-leaflet (1.5.1)
rails-assets-leaflet.markercluster (1.4.1)
@@ -432,95 +399,94 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-i18n (6.0.0)
rails-i18n (5.1.3)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 7)
railties (>= 5.0, < 6)
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.3.2)
actionpack (= 6.0.3.2)
activesupport (= 6.0.3.2)
railties (5.2.4.3)
actionpack (= 5.2.4.3)
activesupport (= 5.2.4.3)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
raindrops (0.19.1)
rake (13.0.3)
rake (13.0.1)
rate_throttle_client (0.1.2)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.2.5)
regexp_parser (2.1.1)
redis (4.2.1)
regexp_parser (1.7.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-activemodel-mocks (1.1.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
rspec-mocks (>= 2.99, < 4.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (5.0.1)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
rspectre (0.0.3)
rspec-support (~> 3.9.0)
rspec-rails (4.0.1)
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)
rspectre (0.0.1)
anima (~> 0.3)
concord (~> 0.1)
parser (~> 2.3)
rspec (~> 3.0)
rswag-api (2.4.0)
unparser (~> 0.2)
rswag-api (2.3.1)
railties (>= 3.1, < 7.0)
rswag-specs (2.4.0)
rswag-specs (2.3.1)
activesupport (>= 3.1, < 7.0)
json-schema (~> 2.2)
railties (>= 3.1, < 7.0)
rswag-ui (2.4.0)
rswag-ui (2.3.1)
actionpack (>= 3.1, < 7.0)
railties (>= 3.1, < 7.0)
rubocop (0.93.1)
rubocop (0.88.0)
parallel (~> 1.10)
parser (>= 2.7.1.5)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.6.0)
rubocop-ast (>= 0.1.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.4.1)
parser (>= 2.7.1.5)
rubocop-rails (2.9.1)
rubocop-ast (0.2.0)
parser (>= 2.7.0.1)
rubocop-rails (2.7.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.90.0, < 2.0)
rubocop-rspec (1.44.1)
rubocop (~> 0.87)
rubocop-ast (>= 0.7.1)
ruby-progressbar (1.11.0)
ruby-units (2.3.2)
rubocop (>= 0.87.0)
rubocop-rspec (1.41.0)
rubocop (>= 0.68.1)
ruby-progressbar (1.10.1)
ruby-units (2.3.1)
ruby-vips (2.0.17)
ffi (~> 1.9)
ruby2_keywords (0.0.4)
ruby_parser (3.14.2)
sexp_processor (~> 4.9)
rubyzip (2.3.0)
@@ -539,21 +505,21 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
scout_apm (4.0.4)
scout_apm (2.6.8)
parser
searchkick (4.4.4)
searchkick (4.4.1)
activemodel (>= 5)
elasticsearch (>= 6)
hashie
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sexp_processor (4.15.0)
sidekiq (6.2.1)
sexp_processor (4.14.1)
sidekiq (6.1.0)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
simplecov (0.13.0)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
@@ -561,35 +527,47 @@ GEM
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
ssrf_filter (1.0.7)
sync (0.5.0)
sysexits (1.2.0)
temple (0.8.2)
terminal-table (3.0.0)
term-ansicolor (1.7.1)
tins (~> 1.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (1.1.0)
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.4)
timecop (0.9.1)
tins (1.25.0)
sync
trollop (1.16.2)
tzinfo (1.2.9)
tzinfo (1.2.7)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.7.0)
unicorn (6.0.0)
unicorn (5.6.0)
kgio (~> 2.6)
raindrops (~> 0.7)
uniform_notifier (1.14.0)
validate_url (1.0.13)
uniform_notifier (1.13.0)
unparser (0.4.7)
abstract_type (~> 0.0.7)
adamantium (~> 0.2.0)
concord (~> 0.1.5)
diff-lcs (~> 1.3)
equalizer (~> 0.0.9)
parser (>= 2.6.5)
procto (~> 0.0.2)
validate_url (1.0.11)
activemodel (>= 3.0.0)
public_suffix
warden (1.2.9)
rack (>= 2.0.9)
webdrivers (4.6.0)
warden (1.2.8)
rack (>= 2.0.6)
webdrivers (4.4.1)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
@@ -597,24 +575,21 @@ GEM
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
webrick (1.7.0)
websocket-driver (0.7.3)
websocket-driver (0.7.2)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
will_paginate (3.3.0)
will_paginate-bootstrap4 (0.2.2)
will_paginate (~> 3.0, >= 3.0.0)
xmlrpc (0.3.2)
webrick
xmlrpc (0.3.0)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.2)
PLATFORMS
ruby
DEPENDENCIES
active_median (= 0.2.0)
active_median (= 0.1.4)
active_record_union
active_utils
better_errors
@@ -634,11 +609,12 @@ DEPENDENCIES
codeclimate-test-reporter
coffee-rails
comfortable_mexican_sofa (~> 2.0.0)
coveralls
csv_shaper
dalli
database_cleaner
devise
discard (>= 1.2)
discard (~> 1.0)
dotenv-rails
elasticsearch (< 7.0.0)
factory_bot_rails
@@ -675,14 +651,14 @@ DEPENDENCIES
omniauth-facebook
omniauth-flickr (>= 0.0.15)
omniauth-twitter
percy-capybara
percy-capybara (~> 4.0.0)
pg (< 1.0.0)
platform-api
puma
query_diet
rack-cors
rack-protection (>= 2.0.1)
rails (= 6.0.3.2)
rails (= 5.2.4.3)
rails-assets-leaflet.markercluster!
rails-controller-testing
rails_12factor
@@ -715,7 +691,7 @@ DEPENDENCIES
xmlrpc
RUBY VERSION
ruby 2.7.2p137
ruby 2.6.5p114
BUNDLED WITH
1.17.3

View File

@@ -1,6 +1,7 @@
# 🌱 Growstuff
![Build status](https://github.com/Growstuff/growstuff/workflows/CI/badge.svg)
[![Build Status](https://travis-ci.org/Growstuff/growstuff.svg?branch=dev)](https://travis-ci.org/Growstuff/growstuff)
[![Coverage Status](https://coveralls.io/repos/github/Growstuff/growstuff/badge.svg?branch=dev)](https://coveralls.io/github/Growstuff/growstuff?branch=dev)
[![Code Climate](https://codeclimate.com/github/Growstuff/growstuff/badges/gpa.svg)](https://codeclimate.com/github/Growstuff/growstuff)
Welcome to the Growstuff project.

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 155 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 156 KiB

View File

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 221 KiB

View File

@@ -7,7 +7,7 @@
bottom: 0;
color: $white;
margin: 0;
opacity: 0.8;
opacity: .8;
position: absolute;
text-align: center;
width: 100%;
@@ -22,7 +22,7 @@
h5.crop-sci-name {
background-color: $beige;
color: $black;
font-size: 0.7em;
font-size: .7em;
margin-top: 0;
padding-top: 0;
}
@@ -45,7 +45,7 @@
.planting {
.crop-card {
height: 100%;
margin: 0.1em;
margin: .1em;
min-height: 300px;
}
@@ -85,7 +85,7 @@
@include media-breakpoint-down(xs) {
.index-cards {
.crop-thumbnail {
margin: 0.2em;
margin: .2em;
width: 30%;
}
}

View File

@@ -2,7 +2,7 @@
.text {
color: $white;
margin: 0;
opacity: 0.8;
opacity: .8;
position: absolute;
text-align: center;
top: 30%;
@@ -12,7 +12,7 @@
h3,
h4,
h5 {
margin: 0;
margin: 0
}
h3 {

View File

@@ -2,7 +2,7 @@
border-radius: 12px;
height: 200px;
margin: 1em;
padding: 0.25em;
padding: .25em;
div {
display: inline-block;
@@ -11,11 +11,12 @@
}
}
.member-thumbnail div ~ div {
.member-thumbnail div~div {
padding-left: 1em;
width: 15em;
}
.member-chip {
background-color: lighten($green, 30%);
@@ -34,7 +35,7 @@
}
.location-not-set {
background-image: image-url("location-not-set.en.png");
background-image: image-url('location-not-set.en.png');
background-position: center;
background-repeat: no-repeat;
height: 250px;

View File

@@ -15,36 +15,30 @@ $body-bg: $beige;
$text-color: $brown;
$link-color: $green;
$default-font: "Raleway", "Fira Sans", Helvetica, Arial, sans-serif;
$default-font: 'Raleway',
"Fira Sans",
Helvetica,
Arial,
sans-serif;
$primary: (
color: $green,
$primary: (color: $green,
dark: darken($green, 20%),
light: lighten($green, 20%),
);
$secondary: (
color: $blue,
light: lighten($green, 20%));
$secondary: (color: $blue,
dark: darken($blue, 20%),
light: lighten($blue, 20%),
);
$success: (
color: $green,
light: lighten($blue, 20%));
$success: (color: $green,
dark: darken($green, 20%),
light: lighten($green, 20%),
);
$danger: (
color: $red,
light: lighten($green, 20%));
$danger: (color: $red,
dark: darken($red, 20%),
light: lighten($red, 20%),
);
$dark: (
color: $brown,
light: lighten($red, 20%));
$dark: (color: $brown,
dark: darken($brown, 20%),
light: lighten($brown, 20%),
);
light: lighten($brown, 20%));
$grid-breakpoints: (
// Extra small screen / phone
$grid-breakpoints: ( // Extra small screen / phone
xs: 0,
// Small screen / phone
sm: 576px,
@@ -53,8 +47,7 @@ $grid-breakpoints: (
// Large screen / desktop
lg: 1200px,
// Extra large screen / wide desktop
xl: 1800px
);
xl: 1800px);
// Nav bar
$navbar-default-bg: $brown;

View File

@@ -1,32 +1,33 @@
// Import original variables so they can be used in overrides
@import "variables";
@import "material";
@import 'variables';
@import 'material';
@import 'jquery-ui/autocomplete';
@import 'bootstrap-datepicker';
@import 'leaflet';
@import 'leaflet.markercluster';
@import "jquery-ui/autocomplete";
@import "bootstrap-datepicker";
@import "leaflet";
@import "leaflet.markercluster";
// Font Awesome
@import "font-awesome-sprockets";
@import "font-awesome";
@import "material_icons";
@import "rails_bootstrap_forms";
@import 'font-awesome-sprockets';
@import 'font-awesome';
@import 'material_icons';
@import 'rails_bootstrap_forms';
@import "overrides";
@import "mobile";
@import 'overrides';
@import 'mobile';
@import "crops";
@import "harvests";
@import "likes";
@import "members";
@import "notifications";
@import "plantings";
@import "photos";
@import "posts";
@import "seeds";
@import 'crops';
@import 'harvests';
@import 'likes';
@import 'members';
@import 'notifications';
@import 'plantings';
@import 'photos';
@import 'posts';
@import 'seeds';
@import "predictions";
@import "homepage";
@import "maps";
@import 'predictions';
@import 'homepage';
@import 'maps';

View File

@@ -1,6 +1,7 @@
// Overrides applying only to mobile view. This must be at the end of the overrides file.
// Extra small devices (portrait phones, less than 576px)
@include media-breakpoint-down(md) {
.container {
margin: 2px;
padding: 0;
@@ -10,7 +11,7 @@
width: 100%;
}
.navbar .nav > li {
.navbar .nav>li {
display: block;
}
@@ -32,10 +33,11 @@
}
.site-name:after {
content: "";
content: '';
display: inline-block;
width: 100%;
}
}
h1 {
@@ -64,13 +66,14 @@
height: 300px;
}
section .btn {
width: 100%;
}
.index-cards {
.card {
margin: 0.2em;
margin: .2em;
width: 48%;
// Shrink title to fit more on page
@@ -84,6 +87,7 @@
object-fit: cover;
width: 100%;
}
}
}
}

View File

@@ -10,9 +10,9 @@ body {
.navbar-brand {
.site-name {
font-family: "Modak", cursive;
font-family: 'Modak', cursive;
font-size: 3em;
margin: 0.3em;
margin: .3em;
}
img {
@@ -46,6 +46,7 @@ body {
font-size: 5em;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
@@ -81,8 +82,9 @@ h3 {
font-size: 120%;
}
section {
margin: 0.5em 0 0;
margin: .5em 0 0;
padding: 0 0 1em;
h2 {
@@ -90,7 +92,7 @@ section {
box-shadow: 1px 1px 1px 1px darken($beige, 20%);
color: $white;
font-weight: normal;
padding: 0.2em;
padding: .2em;
a {
color: $white;
@@ -98,16 +100,7 @@ section {
}
.card {
background: $white;
box-shadow: 1px 3px 3px 1px darken($beige, 20%);
cursor: pointer;
transition: 0.3s transform cubic-bezier(0.155, 1.105, 0.295, 1.12), 0.3s box-shadow,
0.3s -webkit-transform cubic-bezier(0.155, 1.105, 0.295, 1.12);
}
.card:hover {
box-shadow: 0 10px 20px darken($beige, 30%), 0 4px 8px darken($beige, 40%);
transform: scale(1.1);
}
}
@@ -124,7 +117,7 @@ section {
.card {
background: $white;
border-radius: 5%;
margin: 0.5em 0.5em 0.5em 0;
margin: .5em .5em .5em 0;
width: 200px;
.img-card {
@@ -239,6 +232,7 @@ ul.associations {
// footer
footer {
#footer1,
#footer2,
#footer3 {
@@ -376,7 +370,7 @@ ul.thumbnail-buttons {
}
.info {
padding: 0.5em;
padding: .5em;
text-align: center;
}
}
@@ -392,7 +386,7 @@ ul.thumbnail-buttons {
display: inline-block;
height: 30px;
line-height: 30px;
margin: 0.2em;
margin: .2em;
padding: 0 25px;
a {
@@ -417,14 +411,14 @@ ul.thumbnail-buttons {
.progress-fade::before {
background: $beige;
bottom: 0;
content: "";
content: '';
display: block;
left: 0;
opacity: 0.7;
opacity: .7;
position: absolute;
right: 0;
top: 0;
transition: background 0.3s linear;
transition: background .3s linear;
}
.progress-fade:hover::before {

View File

@@ -7,10 +7,9 @@ class ConversationsController < ApplicationController
before_action :check_current_subject_in_conversation, only: %i(show update destroy)
def index
@conversations = case @box
when "inbox"
@conversations = if @box.eql? "inbox"
mailbox.inbox
when "sent"
elsif @box.eql? "sent"
mailbox.sentbox
else
mailbox.trash
@@ -60,7 +59,7 @@ class ConversationsController < ApplicationController
'sent' => { 'total' => mailbox.sentbox.size, 'unread' => 0 },
'trash' => { 'total' => mailbox.trash.size, 'unread' => 0 }
}
@box = if params[:box].blank? || @boxes.keys.exclude?(params[:box])
@box = if params[:box].blank? || !@boxes.keys.include?(params[:box])
'inbox'
else
params[:box]

View File

@@ -62,6 +62,9 @@ class CropsController < ApplicationController
end
def show
@crop = Crop.includes(
:scientific_names, :alternate_names, :parent, :varieties
).find_by!(slug: params[:slug])
respond_to do |format|
format.html do
@posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page])
@@ -86,6 +89,7 @@ class CropsController < ApplicationController
end
def edit
@crop = Crop.find_by!(slug: params[:slug])
@crop.alternate_names.build if @crop.alternate_names.blank?
@crop.scientific_names.build if @crop.scientific_names.blank?
end
@@ -106,13 +110,14 @@ class CropsController < ApplicationController
end
def update
@crop = Crop.find_by!(slug: params[:slug])
if can?(:wrangle, @crop)
@crop.approval_status = 'rejected' if params.fetch("reject", false)
@crop.approval_status = 'approved' if params.fetch("approve", false)
end
@crop.creator = current_member if @crop.approval_status == "pending"
if @crop.update(crop_params)
recreate_names('alt_name', 'alternate')
recreate_names('sci_name', 'scientific')
@@ -140,22 +145,26 @@ class CropsController < ApplicationController
def notifier
case @crop.approval_status
when "approved"
NotifierMailer.crop_request_approved(@crop.requester, @crop)
Notifier.crop_request_approved(@crop.requester, @crop)
when "rejected"
NotifierMailer.crop_request_rejected(@crop.requester, @crop)
Notifier.crop_request_rejected(@crop.requester, @crop)
end
end
def save_crop_names
AlternateName.create!(names_params(:alt_name).map { |n| { name: n, creator_id: current_member.id, crop_id: @crop.id } })
ScientificName.create!(names_params(:sci_name).map { |n| { name: n, creator_id: current_member.id, crop_id: @crop.id } })
params[:alt_name]&.values&.each do |value|
create_name!('alternate', value) unless value.empty?
end
params[:sci_name]&.values&.each do |value|
create_name!('scientific', value) unless value.empty?
end
end
def notify_wranglers
return if current_member.role? :crop_wrangler
Role.crop_wranglers&.each do |w|
NotifierMailer.new_crop_request(w, @crop).deliver_now!
Notifier.new_crop_request(w, @crop).deliver_now!
end
end
@@ -178,18 +187,19 @@ class CropsController < ApplicationController
def crop_params
params.require(:crop).permit(
:name, :en_wikipedia_url,
:parent_id, :perennial,
:request_notes, :reason_for_rejection,
:en_wikipedia_url,
:name,
:parent_id,
:perennial,
:request_notes,
:reason_for_rejection,
:rejection_notes,
scientific_names_attributes: %i(scientific_name _destroy id)
scientific_names_attributes: %i(scientific_name
_destroy
id)
)
end
def names_params(name_type)
params.require(name_type).values&.reject { |n| n.empty? }
end
def filename
"Growstuff-Crops-#{Time.zone.now.to_s(:number)}.csv"
end
@@ -202,7 +212,8 @@ class CropsController < ApplicationController
owner: { only: %i(id login_name location latitude longitude) }
}
},
scientific_names: { only: [:name] }, alternate_names: { only: [:name] }
scientific_names: { only: [:name] },
alternate_names: { only: [:name] }
}
}
end

View File

@@ -2,7 +2,6 @@
class PhotosController < ApplicationController
before_action :authenticate_member!, except: %i(index show)
before_action :set_crop_and_planting, only: :index
after_action :expire_homepage, only: %i(create destroy)
load_and_authorize_resource
respond_to :html, :json
@@ -14,10 +13,19 @@ class PhotosController < ApplicationController
end
def index
where = {}
if params[:crop_slug]
@crop = Crop.find params[:crop_slug]
where = { crops: @crop.id }
elsif params[:planting_id]
@planting = Planting.find params[:planting_id]
where = { planting_id: @planting.id }
end
@photos = Photo.search(
load: false,
boost_by: [:created_at],
where: index_where_clause,
where: where,
page: params[:page],
limit: Photo.per_page
)
@@ -92,15 +100,8 @@ class PhotosController < ApplicationController
def retrieve_from_flickr
@flickr_auth = current_member.auth('flickr')
return if @flickr_auth.nil?
unless current_member.flickr_auth_valid?
current_member.remove_stale_flickr_auth
@please_reconnect_flickr = true
return
end
@current_set = params[:set]
return unless @flickr_auth
page = params[:page] || 1
@@ -111,19 +112,4 @@ class PhotosController < ApplicationController
pager.replace photos
end
end
def index_where_clause
if params[:crop_slug]
{ crops: @crop.id }
elsif params[:planting_id]
{ planting_id: @planting.id }
else
{}
end
end
def set_crop_and_planting
@crop = Crop.find params[:crop_slug] if params[:crop_slug]
@planting = Planting.find params[:planting_id] if params[:planting_id]
end
end

View File

@@ -17,7 +17,7 @@ class PlantingsController < DataController
if params[:crop_slug]
@crop = Crop.find_by(slug: params[:crop_slug])
where['crop_id'] = @crop.id unless @crop.nil?
where['crop_id'] = @crop.id
end
@plantings = Planting.search(

View File

@@ -29,9 +29,9 @@ module ApplicationHelper
end
def required_field_help_text
asterisk = tag.span('*', class: ['red'])
text = tag.em('denotes a required field')
tag.div(asterisk + ' '.html_safe + text, class: ['margin-bottom'])
asterisk = content_tag :span, '*', class: ['red']
text = content_tag :em, 'denotes a required field'
content_tag :div, asterisk + ' '.html_safe + text, class: ['margin-bottom']
end
#
@@ -69,13 +69,14 @@ module ApplicationHelper
def show_inactive_tickbox_path(type, owner: nil, crop: nil, show_all: false)
all = show_all ? '' : 1
if owner.present?
public_send("member_#{type}_path", owner, all: all)
elsif crop.present?
public_send("crop_#{type}_path", crop, all: all)
else
public_send("#{type}_path", all: all)
end
path = if owner.present?
public_send("member_#{type}_path", owner, all: all)
elsif crop.present?
public_send("crop_#{type}_path", crop, all: all)
else
public_send("#{type}_path", all: all)
end
path
end
def title(type, owner, crop, planting)

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class NotifierMailer < ApplicationMailer
class Notifier < ApplicationMailer
# include NotificationsHelper
default from: "Growstuff <#{ENV['GROWSTUFF_EMAIL']}>"

View File

@@ -4,7 +4,7 @@ class Comment < ApplicationRecord
belongs_to :author, class_name: 'Member', inverse_of: :comments
belongs_to :post, counter_cache: true
scope :post_order, -> { order(created_at: :asc) } # for display on post page
scope :post_order, -> { reorder("created_at ASC") } # for display on post page
after_create do
recipient = post.author.id

View File

@@ -19,24 +19,6 @@ module MemberFlickr
@flickr
end
def flickr_auth_valid?
# no flickr token saved for this member
return false if flickr.nil?
# test the token/secret we have
flickr.test.login # This throws exception if fails
# success!
true
rescue FlickRaw::FailedResponse, FlickRaw::OAuthClient::FailedResponse
# token for this user doesn't work
false
end
def remove_stale_flickr_auth
authentications.find_by(provider: "flickr")&.delete
end
# Fetches a collection of photos from Flickr
# Returns a [[page of photos], total] pair.
# Total is needed for pagination.

View File

@@ -4,7 +4,8 @@ module Ownable
extend ActiveSupport::Concern
included do
belongs_to :owner, class_name: 'Member', counter_cache: true
belongs_to :owner, class_name: 'Member',
foreign_key: 'owner_id', counter_cache: true
default_scope { joins(:owner).merge(Member.kept) } # Ensures the owner still exists
end

View File

@@ -50,7 +50,7 @@ class Crop < ApplicationRecord
## Wikipedia urls are only necessary when approving a crop
validates :en_wikipedia_url,
format: {
with: %r{\Ahttps?://en\.wikipedia\.org/wiki/[[:alnum:]%_.()-]+\z},
with: %r{\Ahttps?:\/\/en\.wikipedia\.org\/wiki\/[[:alnum:]%_\.()-]+\z},
message: 'is not a valid English Wikipedia URL'
},
if: :approved?

View File

@@ -14,8 +14,6 @@ class Garden < ApplicationRecord
# set up geocoding
geocoded_by :location
before_validation :strip_blanks
after_validation :cleanup_area
after_validation :geocode
after_validation :empty_unwanted_geocodes
after_save :mark_inactive_garden_plantings_as_finished
@@ -27,6 +25,7 @@ class Garden < ApplicationRecord
validates :location, length: { maximum: 255 }
validates :slug, uniqueness: true
before_validation :strip_blanks
validates :name, uniqueness: { scope: :owner_id }
validates :name,
format: { without: /\n/, message: "must contain no newlines" },
@@ -52,6 +51,8 @@ class Garden < ApplicationRecord
message: "%<value>s is not a valid area unit" },
allow_blank: true
after_validation :cleanup_area
def cleanup_area
self.area = nil if area&.zero?
self.area_unit = nil if area.blank?

View File

@@ -7,7 +7,7 @@ class Photo < ApplicationRecord
PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post Crop).freeze
has_many :photo_associations, dependent: :delete_all, inverse_of: :photo
has_many :photo_associations, foreign_key: :photo_id, dependent: :delete_all, inverse_of: :photo
# This doesn't work, ActiveRecord tries to use the polymoriphinc photographable
# relationship instead.

View File

@@ -25,9 +25,10 @@ class Planting < ApplicationRecord
#
# Ancestry of food
belongs_to :parent_seed, class_name: 'Seed', # parent,
optional: true,
inverse_of: :child_plantings
belongs_to :parent_seed, class_name: 'Seed', # parent
foreign_key: 'parent_seed_id',
optional: true,
inverse_of: :child_plantings
has_many :child_seeds, class_name: 'Seed', # children
foreign_key: 'parent_planting_id',
inverse_of: :parent_planting,

View File

@@ -14,10 +14,10 @@ class Post < ApplicationRecord
has_many :crop_posts, dependent: :delete_all
has_many :crops, through: :crop_posts
after_create :send_notification
#
# Triggers
after_save :update_crop_posts_association
after_create :send_notification
default_scope { joins(:author).merge(Member.kept) } # Ensures the owner still exists
@@ -68,7 +68,7 @@ class Post < ApplicationRecord
crop_name = Regexp.last_match(1)
crop = Crop.case_insensitive_name(crop_name).first
# create association
crops << crop if crop && crops.exclude?(crop)
crops << crop if crop && !crops.include?(crop)
end
end
@@ -78,12 +78,12 @@ class Post < ApplicationRecord
body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_REGEX) do |_m|
# find member case-insensitively and add to list of recipients
member = Member.case_insensitive_login_name(Regexp.last_match(1)).first
recipients << member if member && recipients.exclude?(member)
recipients << member if member && !recipients.include?(member)
end
body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_AT_REGEX) do |_m|
# find member case-insensitively and add to list of recipients
member = Member.case_insensitive_login_name(Regexp.last_match(1)[1..]).first
recipients << member if member && recipients.exclude?(member)
member = Member.case_insensitive_login_name(Regexp.last_match(1)[1..-1]).first
recipients << member if member && !recipients.include?(member)
end
# don't send notifications to yourself
recipients.map(&:id).each do |recipient_id|

View File

@@ -16,7 +16,7 @@ class Seed < ApplicationRecord
#
# Relationships
belongs_to :crop
belongs_to :parent_planting, class_name: 'Planting',
belongs_to :parent_planting, class_name: 'Planting', foreign_key: 'parent_planting_id',
optional: true, inverse_of: :child_seeds # parent
has_many :child_plantings, class_name: 'Planting',
foreign_key: 'parent_seed_id', dependent: :nullify,

View File

@@ -22,7 +22,7 @@
- else
Nobody is growing this yet. You could be the first!
- if @crop.description.present?
%p= simple_format @crop.description
%p= @crop.description
.col-md-3
= image_tag crop_image_path(@crop),
class: 'img-responsive shadow rounded crop-hero-photo', alt: 'photo of crop'

View File

@@ -34,21 +34,18 @@
= cute_icon
= render 'crops/photos', crop: @crop
- if @crop.plantings.any? or @crop.harvests.any?
- if @crop.plantings.any?
%section.charts
.row
- if @crop.sunniness.any?
.col-lg-4.col-12
%h2 Sunniness
= pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom"
- if @crop.planted_from.any?
.col-lg-4.col-12
%h2 Planted from
= pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom"
- if @crop.harvests.any?
.col-lg-4.col-12
%h2 Harvested for
= pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom"
.col-lg-4.col-12
%h2 Sunniness
= pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom"
.col-lg-4.col-12
%h2 Planted from
= pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom"
.col-lg-4.col-12
%h2 Harvested for
= pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom"
- if @crop.varieties.any?
%section.varieties

View File

@@ -3,13 +3,13 @@
- if signed_in?
%li.nav-item
= link_to timeline_index_path, method: :get, class: 'nav-link text-white' do
= image_tag 'icons/notification.svg', alt: 'Timeline', class: 'img img-icon'
= image_tag 'icons/notification.svg', class: 'img img-icon'
%li.nav-item
= link_to member_gardens_path(current_member), class: 'nav-link text-white' do
= image_icon 'gardens', alt: 'My gardens'
= image_icon 'gardens'
%li.nav-item.dropdown
%a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"}
= image_tag "icons/gardener.svg", alt: 'New record', class: 'img img-icon'
= image_tag "icons/gardener.svg", class: 'img img-icon'
= t('.record')
.dropdown-menu
= link_to new_planting_path, class: 'dropdown-item' do

View File

@@ -3,17 +3,7 @@
%h1 New Photo
%h2 Choose photo for #{link_to @item, @item}
- if @please_reconnect_flickr
%h2.alert Please reconnect your flickr account
%p the token has expired or been revoked.
= link_to '/members/auth/flickr', class: "btn btn-lg" do
= icon 'fab', 'flickr'
Reconnect Flickr
- elsif @flickr_auth
- if @flickr_auth
%p
Connected to Flickr as
= succeed "." do
@@ -47,9 +37,7 @@
.row.pagination
.col-md-12= will_paginate @photos
- else
%h2.alert You must connect your account to Flickr to add photos.
%p
= link_to '/members/auth/flickr', class: :btn do
= icon 'fab', 'flickr'
connect to Flickr
.alert
You must
= link_to "connect your account to Flickr", '/members/auth/flickr'
to add photos.

View File

@@ -2,3 +2,5 @@ Map data &copy;
= link_to "OpenStreetMap", "https://openstreetmap.org"
contributors under
= link_to "ODbL", "https://www.openstreetmap.org/copyright"
| Imagery &copy;
= link_to "CloudMade", "https://cloudmade.com"

View File

@@ -2,6 +2,7 @@
# frozen_string_literal: true
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
@@ -10,31 +11,24 @@ 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.
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "Install JavaScript dependencies"
system('bin/yarn')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts "\n== Copying sample files =="
unless File.exist?('config/database.yml')
FileUtils.cp 'config/database.yml.example', 'config/database.yml'
end
unless File.exist?('.env')
FileUtils.cp 'env-example', '.env'
end
puts "\n== Checking for elastic search =="
system! 'script/check_elasticsearch.sh'
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:prepare'
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

View File

@@ -2,5 +2,5 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('config/environment', __dir__)
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

View File

@@ -12,7 +12,21 @@ Bundler.require(*Rails.groups)
module Growstuff
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
config.load_defaults 5.1
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
I18n.config.enforce_available_locales = true
@@ -38,6 +52,17 @@ module Growstuff
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
# config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
@@ -68,6 +93,17 @@ module Growstuff
Gibbon::API.throws_exceptions = false
config.newsletter_list_id = ENV['GROWSTUFF_MAILCHIMP_NEWSLETTER_ID']
# This is Growstuff's global Cloudmade key. If you fork Growstuff for
# another project/website not run by the folks at http://growstuff.org/,
# then please change this key. (You can get one of your own at
# http://account.cloudmade.com/ and it's free/gratis for up to 500k tiles.)
# We'd much prefer to set this as an environment variable (as we do
# with most other things) but it turns out those aren't available at
# asset compile time on Heroku, when we need this to insert into our
# Javascript. Sigh. And yes, we know about user-env-compile but it
# didn't work for us.
config.cloudmade_key = '29a2d9e3cb3d429490a8f338b2388b1d'
# config.active_record.raise_in_transactional_callbacks = true
config.middleware.insert_before 0, Rack::Cors do
allow do

View File

@@ -61,7 +61,7 @@ Geocoder.configure(lookup: :test)
Geocoder::Lookup::Test.add_stub(
"Amundsen-Scott Base, Antarctica", [
{
'coordinates' => [-90.0, 0.0]
'coordinates' => [-90.0, 0.0]
}
]
)
@@ -69,7 +69,7 @@ Geocoder::Lookup::Test.add_stub(
Geocoder::Lookup::Test.add_stub(
"Philippines", [
{
'coordinates' => [12.7503486, 122.7312101],
'coordinates' => [12.7503486, 122.7312101],
'address' => 'Manila, Mnl, Philippines',
'state' => 'Manila',
'state_code' => 'Mnl',

View File

@@ -12,8 +12,6 @@
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
@@ -22,9 +20,6 @@
# 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

View File

@@ -237,3 +237,4 @@ Devise.setup do |config|
# Later we may wish to ask for user_photos,user_location, however this means we need to be reviewed by facebook
config.omniauth :facebook, ENV['GROWSTUFF_FACEBOOK_KEY'], ENV['GROWSTUFF_FACEBOOK_SECRET'], scope: 'email,public_profile', display: 'page', info_fields: 'email,name,first_name,last_name,id'
end

View File

@@ -1,45 +0,0 @@
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 6.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Don't force requests from old versions of IE to be UTF-8 encoded.
# Rails.application.config.action_view.default_enforce_utf8 = false
# Embed purpose and expiry metadata inside signed and encrypted
# cookies for increased security.
#
# This option is not backwards compatible with earlier Rails versions.
# It's best enabled when your entire app is migrated and stable on 6.0.
# Rails.application.config.action_dispatch.use_cookies_with_metadata = true
# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
# Return false instead of self when enqueuing is aborted from a callback.
# Rails.application.config.active_job.return_false_on_aborted_enqueue = true
# Send Active Storage analysis and purge jobs to dedicated queues.
# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
# Rails.application.config.active_storage.queues.purge = :active_storage_purge
# When assigning to a collection of attachments declared via `has_many_attached`, replace existing
# attachments instead of appending. Use #attach to add new attachments without replacing existing ones.
# Rails.application.config.active_storage.replace_on_assign_to_many = true
# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail.
#
# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob),
# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions.
# If you send mail in the background, job workers need to have a copy of
# MailDeliveryJob to ensure all delivery jobs are processed properly.
# Make sure your entire app is migrated and stable on 6.0 before using this setting.
# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
# Enable the same cache key to be reused when the object being cached of type
# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count)
# of the relation's cache key into the cache version to support recycling cache key.
# Rails.application.config.active_record.collection_cache_versioning = true

View File

@@ -2,5 +2,5 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, ENV['GROWSTUFF_TWITTER_KEY'], ENV['GROWSTUFF_TWITTER_SECRET']
provider :flickr, ENV['GROWSTUFF_FLICKR_KEY'], ENV['GROWSTUFF_FLICKR_SECRET'], scope: 'read'
provider :flickr, ENV['GROWSTUFF_FLICKR_KEY'], ENV['GROWSTUFF_FLICKR_SECRET']
end

View File

@@ -1,40 +1,45 @@
# frozen_string_literal: true
# Overview of config:
# https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
port ENV.fetch('PORT') { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
workers ENV.fetch('WEB_CONCURRENCY') { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
preload_app!
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

View File

@@ -2,11 +2,10 @@
class CreateMedianFunction < ActiveRecord::Migration[4.2]
def up
# commented out, because we upgraded the gem later and this function was removed
# ActiveMedian.create_function
ActiveMedian.create_function
end
def down
# ActiveMedian.drop_function
ActiveMedian.drop_function
end
end

View File

@@ -6,16 +6,16 @@ class CmsTags < ActiveRecord::Migration[5.2]
layout.content = layout.content.gsub(%r{\{\{ ?cms:page:([\w/]+) ?\}\}}, '{{ cms:text \1 }}') if layout.content.is_a? String
# {{cms:page:page_header:string}} -> {{ cms:text page_header }}
layout.content = layout.content.gsub(/\{\{ ?cms:page:(\w+):string ?\}\}/, '{{ cms:text \1 }}') if layout.content.is_a? String
layout.content = layout.content.gsub(/\{\{ ?cms:page:([\w]+):string ?\}\}/, '{{ cms:text \1 }}') if layout.content.is_a? String
# {{cms:page:content:rich_text}} -> {{ cms:wysiwyg content }}
layout.content = layout.content.gsub(/\{\{ ?cms:page:(\w+):rich_text ?\}\}/, '{{ cms:wysiwyg \1 }}') if layout.content.is_a? String
layout.content = layout.content.gsub(/\{\{ ?cms:page:(\w+):([^:]*) ?}}/, '{{ cms:\2 \1 }}') if layout.content.is_a? String
layout.content = layout.content.gsub(/\{\{ ?cms:page:([\w]+):rich_text ?\}\}/, '{{ cms:wysiwyg \1 }}') if layout.content.is_a? String
layout.content = layout.content.gsub(/\{\{ ?cms:page:([\w]+):([^:]*) ?\}\}/, '{{ cms:\2 \1 }}') if layout.content.is_a? String
if layout.content.is_a? String
layout.content = layout.content.gsub(/\{\{ ?cms:field:(\w+):string ?\}\}/, '{{ cms:text \1, render: false }}')
layout.content = layout.content.gsub(/\{\{ ?cms:field:([\w]+):string ?\}\}/, '{{ cms:text \1, render: false }}')
end
if layout.content.is_a? String
layout.content = layout.content.gsub(/\{\{ ?cms:field:(\w+):([^:]*) ?}}/, '{{ cms:\2 \1, render: false }}')
layout.content = layout.content.gsub(/\{\{ ?cms:field:([\w]+):([^:]*) ?\}\}/, '{{ cms:\2 \1, render: false }}')
end
# {{ cms:partial:main/homepage }} -> {{ cms:partial "main/homepage" }}
@@ -27,7 +27,7 @@ class CmsTags < ActiveRecord::Migration[5.2]
if layout.content.is_a? String
layout.content = layout.content.gsub(%r{\{\{ ?cms:(\w+):([\w/-]+):([\w/-]+):([\w/-]+) ?\}\}}, '{{ cms:\1 \2 \3 \4}}')
end
layout.content = layout.content.gsub(/\{\{ ?cms:(\w+):(\w+):([^:]*) ?}}/, '{{ cms:\1 \2, "\3" }}') if layout.content.is_a? String
layout.content = layout.content.gsub(/\{\{ ?cms:(\w+):([\w]+):([^:]*) ?\}\}/, '{{ cms:\1 \2, "\3" }}') if layout.content.is_a? String
layout.content = layout.content.gsub(/cms:rich_text/, 'cms:wysiwyg') if layout.content.is_a? String
layout.content = layout.content.gsub(/cms:integer/, 'cms:number') if layout.content.is_a? String
if layout.content.is_a? String
@@ -49,20 +49,20 @@ class CmsTags < ActiveRecord::Migration[5.2]
fragment.content = fragment.content.gsub(%r{\{\{ ?cms:partial:([\w/]+) ?\}\}}, '{{ cms:partial \1 }}')
end
fragment.content = fragment.content.gsub(/\{\{ ?cms:page:(\w+):string ?\}\}/, '{{ cms:text \1 }}') if fragment.content.is_a? String
fragment.content = fragment.content.gsub(/\{\{ ?cms:page:([\w]+):string ?\}\}/, '{{ cms:text \1 }}') if fragment.content.is_a? String
if fragment.content.is_a? String
fragment.content = fragment.content.gsub(/\{\{ ?cms:page:(\w+):rich_text ?\}\}/, '{{ cms:wysiwyg \1 }}')
fragment.content = fragment.content.gsub(/\{\{ ?cms:page:([\w]+):rich_text ?\}\}/, '{{ cms:wysiwyg \1 }}')
end
fragment.content = fragment.content.gsub(%r{\{\{ ?cms:page:([\w/]+) ?\}\}}, '{{ cms:text \1 }}') if fragment.content.is_a? String
fragment.content = fragment.content.gsub(/\{\{ ?cms:page:(\w+):([^:]*) ?}}/, '{{ cms:\2 \1 }}') if fragment.content.is_a? String
fragment.content = fragment.content.gsub(/\{\{ ?cms:page:([\w]+):([^:]*) ?\}\}/, '{{ cms:\2 \1 }}') if fragment.content.is_a? String
if fragment.content.is_a? String
fragment.content = fragment.content.gsub(/\{\{ ?cms:field:(\w+):([^:]*) ?}}/, '{{ cms:\2 \1, render: false }}')
fragment.content = fragment.content.gsub(/\{\{ ?cms:field:([\w]+):([^:]*) ?\}\}/, '{{ cms:\2 \1, render: false }}')
end
fragment.content = fragment.content.gsub(/\{\{ ?cms:(\w+):(\w+) ?\}\}/, '{{ cms:\1 \2 }}') if fragment.content.is_a? String
fragment.content = fragment.content.gsub(/\{\{ ?cms:(\w+):([\w]+) ?\}\}/, '{{ cms:\1 \2 }}') if fragment.content.is_a? String
if fragment.content.is_a? String
fragment.content = fragment.content.gsub(/\{\{ ?cms:(\w+):(\w+):([^:]*) ?}}/, '{{ cms:\1 \2, "\3" }}')
fragment.content = fragment.content.gsub(/\{\{ ?cms:(\w+):([\w]+):([^:]*) ?\}\}/, '{{ cms:\1 \2, "\3" }}')
end
fragment.save if fragment.changed?
end

View File

@@ -1,8 +0,0 @@
# This migration comes from active_storage (originally 20180723000244)
class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
def up
return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)
add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id if table_exists?(:active_storage_blobs)
end
end

View File

@@ -1,8 +0,0 @@
# frozen_string_literal: true
class MissingUniqueness < ActiveRecord::Migration[6.0]
def change
add_index(:garden_types, [:name], unique: true)
add_index(:garden_types, [:slug], unique: true)
end
end

View File

@@ -1,6 +0,0 @@
class RemoveMedianFunction < ActiveRecord::Migration[6.0]
def change
# No longer needed, after upgrading to activemedian 0.2.0
ActiveMedian.drop_function
end
end

View File

@@ -2,15 +2,15 @@
# 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
# 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.
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_08_15_012538) do
ActiveRecord::Schema.define(version: 2019_12_26_051019) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -225,8 +225,6 @@ ActiveRecord::Schema.define(version: 2020_08_15_012538) do
t.text "slug", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["name"], name: "index_garden_types_on_name", unique: true
t.index ["slug"], name: "index_garden_types_on_slug", unique: true
end
create_table "gardens", id: :serial, force: :cascade do |t|

View File

@@ -47,8 +47,8 @@ GROWSTUFF_TWITTER_SECRET=""
# Used for connecting member accounts to Flickr
# Get Flickr key from http://www.flickr.com/services/apps/create/apply/
GROWSTUFF_FLICKR_KEY=""
GROWSTUFF_FLICKR_SECRET=""
GROWSTUFF_FLICKR_KEY="ebb5ef627143346f992201b02f12e4a8"
GROWSTUFF_FLICKR_SECRET="04368dcc21a624a8"
# https://developers.facebook.com/
GROWSTUFF_FACEBOOK_KEY=""
@@ -61,5 +61,3 @@ GROWSTUFF_FACEBOOK_SECRET=""
# set this flag to "true".
GROWSTUFF_ELASTICSEARCH="true"
GROWSTUFF_EMAIL='noreply@dev.growstuff.org'
ELASTIC_SEARCH_VERSION="7.5.1-amd64"

View File

@@ -11,7 +11,7 @@ class Growstuff::OauthSignupAction
# variable
#
def find_or_create_from_authorization(auth)
member ||= Member.kept.where(email: auth.info.email).first_or_create do |m|
member ||= Member.where(email: auth.info.email).first_or_create do |m|
m.email = auth.info.email
m.password = Devise.friendly_token[0, 20]
@@ -41,7 +41,7 @@ class Growstuff::OauthSignupAction
def establish_authentication(auth, member)
name = determine_name(auth)
member.authentications
authentication = member.authentications
.create_with(
name: name,
token: auth['credentials']['token'],
@@ -53,6 +53,8 @@ class Growstuff::OauthSignupAction
name: name,
member_id: member.id
)
authentication
end
def member_created?

View File

@@ -17,8 +17,8 @@ module Haml::Filters
CROP_REGEX = /(?<!\\)\[([^\[\]]+?)\]\(crop\)/.freeze
MEMBER_REGEX = /(?<!\\)\[([^\[\]]+?)\]\(member\)/.freeze
MEMBER_AT_REGEX = /(?<!\\)(@\w+)/.freeze
MEMBER_ESCAPE_AT_REGEX = /(?<!\\)\\(?=@\w+)/.freeze
MEMBER_AT_REGEX = /(?<!\\)(\@\w+)/.freeze
MEMBER_ESCAPE_AT_REGEX = /(?<!\\)\\(?=\@\w+)/.freeze
HOST = Rails.application.config.host
def expand_crops!
@@ -65,7 +65,7 @@ module Haml::Filters
def find_member(login_name)
# Remove @ if present
login_name = login_name[1..] if login_name.start_with?('@')
login_name = login_name[1..-1] if login_name.start_with?('@')
Member.case_insensitive_login_name(login_name).first
end
end

View File

@@ -3,12 +3,10 @@
require "English"
if ENV['CI']
if ENV['GITHUB_EVENT_NAME'] == 'pull_request'
author = ENV['GITHUB_ACTOR']
exit 1 unless author
puts "Checking to see if you're in CONTRIBUTORS.md..."
elsif ENV['TRAVIS_PULL_REQUEST']
if ENV['TRAVIS']
if ENV['TRAVIS_PULL_REQUEST']
require 'httparty'
repo = ENV['TRAVIS_REPO_SLUG']
pr = ENV['TRAVIS_PULL_REQUEST']
@@ -17,7 +15,7 @@ if ENV['CI']
author = response['user']['login'] if response && response['user']
# Could not determine author
exit 1 unless author
exit unless author
else
# We're in a Travis branch build; nothing to check
exit
@@ -36,8 +34,6 @@ end
# Escape chars in name, and make case insensitive
author_to_search_for = Regexp.new(Regexp.escape(author), Regexp::IGNORECASE)
puts("Checking for #{author} in CONTRIBUTORS.md")
unless File.read('CONTRIBUTORS.md').match?(author_to_search_for)
abort %(
Thanks for your contribution, #{author}!

View File

@@ -1,7 +1,5 @@
#!/bin/bash
source .env
if [[ -z "$ELASTIC_SEARCH_VERSION" ]]; then
echo "ELASTIC_SEARCH_VERSION variable not set"
else

View File

@@ -3,8 +3,7 @@
# tasks to run at deploy time, usually after 'rake db:migrate'
# Permanent tasks
rails db:migrate
rails assets:precompile
rake assets:precompile
# When adding tasks, do so in chronological order, and note the date
# when it was added. This will help us know which ones have been run

View File

@@ -26,7 +26,7 @@ describe CommentsController do
it { is_expected.to be_successful }
it { is_expected.to render_template("comments/index") }
it { expect(response.content_type).to eq("application/rss+xml; charset=utf-8") }
it { expect(response.content_type).to eq("application/rss+xml") }
it { expect(assigns(:comments)).to eq([last_comment, first_comment]) }
end
end

View File

@@ -66,33 +66,7 @@ describe CropsController do
it { is_expected.to be_successful }
it { is_expected.to render_template("crops/index") }
it { expect(response.content_type).to eq("application/rss+xml; charset=utf-8") }
end
end
describe 'CREATE' do
let(:crop_params) do
{
crop: {
name: 'aubergine',
en_wikipedia_url: "https://en.wikipedia.org/wiki/Eggplant"
},
alt_name: { "1": "egg plant", "2": "purple apple" },
sci_name: { "1": "fancy sci name", "2": "" }
}
end
subject { put :create, params: crop_params }
context 'not logged in' do
it { expect { subject }.not_to change(Crop, :count) }
end
context 'logged in as member' do
it { expect { subject }.not_to change(Crop, :count) }
end
context 'wrangler' do
include_context 'login as wrangler'
it { expect { subject }.to change(Crop, :count).by(1) }
it { expect { subject }.to change(AlternateName, :count).by(2) }
it { expect { subject }.to change(ScientificName, :count).by(1) }
it { expect(response.content_type).to eq("application/rss+xml") }
end
end
@@ -111,7 +85,7 @@ describe CropsController do
context 'wrangler' do
include_context 'login as wrangler'
it { expect { subject }.to change(Crop, :count).by(-1) }
it { expect { subject }.to change(Crop, :count).by -1 }
end
end
end

View File

@@ -12,7 +12,7 @@ describe LikesController do
describe "POST create" do
before { post :create, params: { type: 'Post', id: blogpost.id, format: :json } }
it { expect(response.content_type).to eq "application/json; charset=utf-8" }
it { expect(response.content_type).to eq "application/json" }
it { expect(Like.last.likeable_id).to eq(blogpost.id) }
it { expect(Like.last.likeable_type).to eq('Post') }
@@ -29,7 +29,7 @@ describe LikesController do
describe "DELETE destroy" do
before { delete :destroy, params: { type: like.likeable_type, id: like.likeable_id, format: :json } }
it { expect(response.content_type).to eq "application/json; charset=utf-8" }
it { expect(response.content_type).to eq "application/json" }
describe "un-liking something i liked before" do
it { expect(response.code).to eq('200') }

View File

@@ -57,7 +57,7 @@ describe MembersController do
it { expect(response).to be_successful }
it { expect(response).to render_template("members/show") }
it { expect(response.content_type).to eq("application/rss+xml; charset=utf-8") }
it { expect(response.content_type).to eq("application/rss+xml") }
end
end
end

View File

@@ -31,7 +31,7 @@ describe PostsController do
get :index, format: "rss"
expect(response).to be_successful
expect(response).to render_template("posts/index")
expect(response.content_type).to eq("application/rss+xml; charset=utf-8")
expect(response.content_type).to eq("application/rss+xml")
end
end
@@ -41,7 +41,7 @@ describe PostsController do
get :show, format: "rss", params: { id: post.slug }
expect(response).to be_successful
expect(response).to render_template("posts/show")
expect(response.content_type).to eq("application/rss+xml; charset=utf-8")
expect(response.content_type).to eq("application/rss+xml")
end
end
end

View File

@@ -4,8 +4,8 @@ require 'rails_helper'
require 'capybara/email/rspec'
describe "Planting reminder email", :js do
let(:member) { create :member }
let(:mail) { NotifierMailer.planting_reminder(member) }
let(:member) { create :member }
let(:mail) { Notifier.planting_reminder(member) }
# Unfortunately, we can't use the default url options for ActionMailer as configured in
# test.rb, since this isn't a mailer spec.

View File

@@ -16,7 +16,7 @@ describe "unsubscribe" do
expect(member.send_notification_email).to eq(true)
# generate planting reminder email
NotifierMailer.planting_reminder(member).deliver_now
Notifier.planting_reminder(member).deliver_now
open_email(member.email)
# clicking 'Unsubscribe' link will unsubscribe the member
@@ -35,7 +35,7 @@ describe "unsubscribe" do
# generate inbox notification email
notification.recipient = member
NotifierMailer.notify(notification).deliver_now
Notifier.notify(notification).deliver_now
open_email(member.email)
# clicking 'Unsubscribe' link will unsubscribe the member

View File

@@ -5,7 +5,7 @@ require 'cancan/matchers'
describe Ability do
let(:member) { FactoryBot.create(:member) }
let(:ability) { described_class.new(member) }
let(:ability) { described_class.new(member) }
context "notifications" do
it 'member can view their own notifications' do

View File

@@ -54,7 +54,7 @@ describe Photo do
# Check the relationship from the photo
it { expect(photo.photo_associations.count).to eq 1 }
it { expect(photo.photo_associations.map(&:crop)).to eq [crop] }
it { expect(photo.photo_associations.map(&:crop)).to eq [ crop ] }
it { expect(photo.crops.count).to eq 1 }
it { expect(photo.crops).to eq [crop] }
end
@@ -247,7 +247,7 @@ describe Photo do
it "finds just one" do
expect(described_class.search.count).to eq 1
end
it "finds the matching photo" do
it "finds the matching photo" do
expect(described_class.search).to include photo
end

View File

@@ -3,9 +3,13 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require 'simplecov'
require 'coveralls'
# output coverage locally AND send it to coveralls
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter])
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
])
# fail if there's a significant test coverage drop
SimpleCov.maximum_coverage_drop 1

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
describe "crops/index.html.haml" do
describe "crops/index" do
before do
controller.stub(:current_user) { nil }
page = 1

View File

@@ -1,49 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe "crops/show" do
before do
@crop = FactoryBot.create(:maize)
@posts = []
assign(:crop, @crop)
@member = FactoryBot.create(:crop_wrangling_member)
sign_in @member
@current_member = @member
@harvest = FactoryBot.create :harvest, owner: @member
controller.stub(:current_user) { @member }
end
it "hides sunniness block if no sunniness" do
render
expect(rendered).not_to have_content "Sunniness"
end
it "has sunniness block if sunny planting" do
FactoryBot.create(:sunny_planting, crop: @crop)
render
expect(rendered).to have_content "Sunniness"
end
it "hides planted from block if no planted_from" do
render
expect(rendered).not_to have_content "Planted from"
end
it "has planted from block if seed planting" do
FactoryBot.create(:seed_planting, crop: @crop)
render
expect(rendered).to have_content "Planted from"
end
it "hides harvested block if no harvests" do
render
expect(rendered).not_to have_content "Harvested for"
end
it "has harvested block if harvest" do
@crop.harvests << @harvest
render
expect(rendered).to have_content "Harvested for"
end
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
describe "harvests/index.html.haml" do
describe "harvests/index" do
before do
controller.stub(:current_user) { nil }
@member = FactoryBot.create(:member)

View File

@@ -16,4 +16,8 @@ describe "places/_map_attribution.html.haml", type: :view do
assert_select "a", href: "http://www.openstreetmap.org/copyright",
text: "ODbL"
end
it "links to CloudMade" do
assert_select "a", href: "http://cloudmade.com", text: "CloudMade"
end
end

View File

@@ -2,7 +2,7 @@
require 'rails_helper'
describe "plantings/index.html.haml" do
describe "plantings/index" do
let(:member) { FactoryBot.create(:member) }
let(:garden) { FactoryBot.create(:garden, owner: member) }
let(:tomato) { FactoryBot.create(:tomato, name: 'tomato') }

View File

@@ -1452,9 +1452,9 @@ lodash.templatesettings@^4.0.0:
lodash._reinterpolate "^3.0.0"
lodash@^4.17.11, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.10:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
version "4.17.14"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba"
integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==
lru-cache@^4.0.1:
version "4.1.5"