mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 09:19:15 -04:00
Compare commits
10 Commits
release65
...
cesy-patch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3b664b06c | ||
|
|
c04dbd4599 | ||
|
|
76da9edc23 | ||
|
|
f8ee706023 | ||
|
|
8f5fd12863 | ||
|
|
65af9c88b1 | ||
|
|
a3e6edde7c | ||
|
|
dcfb088638 | ||
|
|
bf0f6c7579 | ||
|
|
73566832b9 |
47
.codeclimate.yml
Normal file
47
.codeclimate.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
plugins:
|
||||
brakeman:
|
||||
enabled: false # codeclimate's brakeman is stuck in rails 5 rules
|
||||
bundler-audit:
|
||||
enabled: true
|
||||
coffeelint:
|
||||
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"
|
||||
- "**.haml"
|
||||
- Gemfile.lock
|
||||
exclude_paths:
|
||||
- config/
|
||||
- db/
|
||||
- spec/
|
||||
- public/
|
||||
- app/assets/stylesheets/bootstrap-accessibility.css
|
||||
- app/assets/javascripts/bootstrap*
|
||||
- app/assets/stylesheets/leaflet_overrides.scss
|
||||
@@ -1,2 +1,2 @@
|
||||
# Ruby version
|
||||
VARIANT=3.3.4
|
||||
VARIANT=3.1.4
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye
|
||||
FROM mcr.microsoft.com/devcontainers/ruby:0-3.1-bullseye
|
||||
|
||||
# Install Rails
|
||||
RUN gem install rails:7.0.8
|
||||
RUN gem install rails:7.0.7 webdrivers:5.2.0
|
||||
|
||||
# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service
|
||||
# The value is a comma-separated list of allowed domains
|
||||
@@ -12,22 +12,11 @@ ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev,.preview.app.github.dev,.app.git
|
||||
#RUN bundle exec rake db:migrate
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends bash-completion
|
||||
|
||||
# Chrome for testing packages. https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-doesnt-launch-on-linux
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||
|
||||
# [Optional] Uncomment this line to install additional gems.
|
||||
# RUN gem install <your-gem-names-here>
|
||||
|
||||
# [Optional] Uncomment this line to install global node packages.
|
||||
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|
||||
|
||||
# We run as the vscode user.
|
||||
# Make sure this is writable as https://github.com/rubygems/rubygems/issues/6272 was removed
|
||||
RUN su root -c "mkdir -p /usr/local/rvm/gems/default/cache/bundler/"
|
||||
RUN su root -c "mkdir -p /usr/local/rvm/gems/default/bundler/gems/"
|
||||
RUN su root -c "chown -R vscode:rvm /usr/local/rvm/gems/"
|
||||
RUN su root -c "chmod -R 0755 /usr/local/rvm/gems/"
|
||||
|
||||
@@ -14,24 +14,16 @@
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// This can be used to network with other containers or the host.
|
||||
"forwardPorts": [3000, 5432, 9200, 8081],
|
||||
"forwardPorts": [3000, 5432, 9200],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
// these don't actually work as postCreateCommands, you need to run them manually
|
||||
// for some unknown reason, Github codespaces use rbenv and rvm simultaneously
|
||||
// and you need both to be correct for it to work
|
||||
"postCreateCommand": "nice -n 19 bundle install && nice -n 19 bundle exec rake db:create && nice -n 19 bundle exec rake db:migrate && nice -n19 bundle exec rake db:seed",
|
||||
"postCreateCommand": "nice -n 19 bundle install && nice -n 19 bundle exec rake db:create && nice -n 19 bundle exec rake db:migrate && nice -n19 bundle exec rake db:seed"
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"karunamurti.haml",
|
||||
"redhat.vscode-yaml",
|
||||
"CraigMaslowski.erb"
|
||||
]
|
||||
}
|
||||
}
|
||||
// "customizations": {},
|
||||
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
|
||||
45
.github/dependabot.yml
vendored
45
.github/dependabot.yml
vendored
@@ -7,10 +7,53 @@ updates:
|
||||
time: "07:00"
|
||||
open-pull-requests-limit: 20
|
||||
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
|
||||
|
||||
|
||||
40
.github/workflows/brakeman-analysis.yml
vendored
Normal file
40
.github/workflows/brakeman-analysis.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# 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:
|
||||
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@v4
|
||||
|
||||
# Customize the ruby version depending on your needs
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
|
||||
- name: Setup Brakeman
|
||||
env:
|
||||
BRAKEMAN_VERSION: '5.1.1' # 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@v3
|
||||
with:
|
||||
sarif_file: output.sarif.json
|
||||
102
.github/workflows/ci-features-admin.yml
vendored
102
.github/workflows/ci-features-admin.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Admin
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (admin/)
|
||||
run: bundle exec rspec spec/features/admin/ -fd -t ~@flaky
|
||||
102
.github/workflows/ci-features-comments.yml
vendored
102
.github/workflows/ci-features-comments.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Comments
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (comments/)
|
||||
run: bundle exec rspec spec/features/comments/ -fd -t ~@flaky
|
||||
103
.github/workflows/ci-features-conversations.yml
vendored
103
.github/workflows/ci-features-conversations.yml
vendored
@@ -1,103 +0,0 @@
|
||||
name: CI Features - Conversations
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (conversations/)
|
||||
run: bundle exec rspec spec/features/conversations/ -fd -t ~@flaky
|
||||
|
||||
102
.github/workflows/ci-features-crops.yml
vendored
102
.github/workflows/ci-features-crops.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Crops
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (crops/)
|
||||
run: bundle exec rspec spec/features/crops/ -fd -t ~@flaky
|
||||
102
.github/workflows/ci-features-gardens.yml
vendored
102
.github/workflows/ci-features-gardens.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Gardens
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (gardens/)
|
||||
run: bundle exec rspec spec/features/gardens/ -fd -t ~@flaky
|
||||
102
.github/workflows/ci-features-harvests.yml
vendored
102
.github/workflows/ci-features-harvests.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Harvests
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (harvests/)
|
||||
run: bundle exec rspec spec/features/harvests/ -fd -t ~@flaky
|
||||
102
.github/workflows/ci-features-home.yml
vendored
102
.github/workflows/ci-features-home.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Home
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (home/)
|
||||
run: bundle exec rspec spec/features/home/ -fd -t ~@flaky
|
||||
102
.github/workflows/ci-features-members.yml
vendored
102
.github/workflows/ci-features-members.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Members
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (members/)
|
||||
run: bundle exec rspec spec/features/members/ -fd -t ~@flaky
|
||||
102
.github/workflows/ci-features-plantings.yml
vendored
102
.github/workflows/ci-features-plantings.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Plantings
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (plantings/)
|
||||
run: bundle exec rspec spec/features/plantings/ -fd
|
||||
102
.github/workflows/ci-features-seeds.yml
vendored
102
.github/workflows/ci-features-seeds.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Seeds
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (seeds/)
|
||||
run: bundle exec rspec spec/features/seeds/ -fd -t ~@flaky
|
||||
102
.github/workflows/ci-features-timeline.yml
vendored
102
.github/workflows/ci-features-timeline.yml
vendored
@@ -1,102 +0,0 @@
|
||||
name: CI Features - Timeline
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (timeline/)
|
||||
run: bundle exec rspec spec/features/timeline/ -fd -t ~@flaky
|
||||
120
.github/workflows/ci-features.yml
vendored
120
.github/workflows/ci-features.yml
vendored
@@ -1,120 +0,0 @@
|
||||
name: CI Features
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
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@v4
|
||||
|
||||
- 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@v4
|
||||
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@v4
|
||||
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 (*_spec)
|
||||
run: bundle exec rspec spec/features/*_spec.rb -fd
|
||||
|
||||
- name: Run rspec (percy/)
|
||||
run: bundle exec rspec spec/features/percy/ -fd
|
||||
|
||||
- name: Run rspec (photos/)
|
||||
run: bundle exec rspec spec/features/photos/ -fd
|
||||
|
||||
- name: Run rspec (places/)
|
||||
run: bundle exec rspec spec/features/places/ -fd
|
||||
|
||||
- name: Run rspec (plantings/)
|
||||
run: bundle exec rspec spec/features/plantings/ -fd
|
||||
|
||||
- name: Run rspec (posts/)
|
||||
run: bundle exec rspec spec/features/posts/ -fd
|
||||
|
||||
- name: Run rspec (rss/)
|
||||
run: bundle exec rspec spec/features/rss/ -fd
|
||||
34
.github/workflows/ci.yml
vendored
34
.github/workflows/ci.yml
vendored
@@ -76,7 +76,7 @@ jobs:
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- name: Setup yarn cache
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
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 }}
|
||||
@@ -106,25 +106,17 @@ jobs:
|
||||
|
||||
- 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: Run rspec (lib)
|
||||
run: bundle exec rspec spec/lib/ -fd --fail-fast
|
||||
|
||||
- name: Run rspec (services)
|
||||
run: bundle exec rspec spec/services/ -fd --fail-fast
|
||||
|
||||
- name: Run rspec (models)
|
||||
run: bundle exec rspec spec/models/ -fd --fail-fast
|
||||
|
||||
- name: Run rspec (controllers)
|
||||
run: bundle exec rspec spec/controllers/ -fd --fail-fast
|
||||
|
||||
- name: Run rspec (views)
|
||||
run: bundle exec rspec spec/views/ -fd --fail-fast
|
||||
|
||||
- name: Run rspec (routing)
|
||||
run: bundle exec rspec spec/routing/ -fd --fail-fast
|
||||
|
||||
- name: Run rspec (request)
|
||||
run: bundle exec rspec spec/requests/ -fd --fail-fast
|
||||
- name: Report to code climate
|
||||
run: |
|
||||
gem install codeclimate-test-reporter
|
||||
codeclimate-test-reporter
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
inherit_from: .rubocop_todo.yml
|
||||
require:
|
||||
- rubocop-factory_bot
|
||||
- rubocop-capybara
|
||||
- rubocop-rails
|
||||
- rubocop-rspec
|
||||
- rubocop-rspec_rails
|
||||
- rubocop-rake
|
||||
AllCops:
|
||||
NewCops: enable
|
||||
Exclude:
|
||||
- 'db/schema.rb'
|
||||
- 'vendor/**/*'
|
||||
TargetRailsVersion: 7.1
|
||||
TargetRailsVersion: 6.0
|
||||
|
||||
Rails:
|
||||
Enabled: true
|
||||
|
||||
@@ -1,37 +1,15 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2024-07-13 05:47:38 UTC using RuboCop version 1.65.0.
|
||||
# on 2023-09-16 07:51:19 UTC using RuboCop version 1.56.3.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 231
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: link_or_button, strict
|
||||
Capybara/ClickLinkOrButtonStyle:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 39
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: DefaultSelector.
|
||||
Capybara/RSpec/HaveSelector:
|
||||
Exclude:
|
||||
- 'spec/features/conversations/index_spec.rb'
|
||||
- 'spec/features/footer_spec.rb'
|
||||
- 'spec/features/gardens/adding_gardens_spec.rb'
|
||||
- 'spec/features/harvests/harvesting_a_crop_spec.rb'
|
||||
- 'spec/features/members/list_spec.rb'
|
||||
- 'spec/features/plantings/planting_a_crop_spec.rb'
|
||||
- 'spec/features/seeds/adding_seeds_spec.rb'
|
||||
- 'spec/features/shared_examples/crop_suggest.rb'
|
||||
- 'spec/helpers/application_helper_spec.rb'
|
||||
- 'spec/support/feature_helpers.rb'
|
||||
- 'spec/views/posts/show.html.haml_spec.rb'
|
||||
|
||||
# Offense count: 14
|
||||
# Offense count: 15
|
||||
Capybara/SpecificMatcher:
|
||||
Exclude:
|
||||
- 'spec/features/crops/browse_crops_spec.rb'
|
||||
- 'spec/features/footer_spec.rb'
|
||||
- 'spec/features/gardens/adding_gardens_spec.rb'
|
||||
- 'spec/features/harvests/harvesting_a_crop_spec.rb'
|
||||
@@ -45,7 +23,8 @@ Capybara/VisibilityMatcher:
|
||||
|
||||
# Offense count: 6
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle, NonImplicitAssociationMethodNames.
|
||||
# Configuration parameters: Include, EnforcedStyle, NonImplicitAssociationMethodNames.
|
||||
# Include: spec/factories.rb, spec/factories/**/*.rb, features/support/factories/**/*.rb
|
||||
# SupportedStyles: explicit, implicit
|
||||
FactoryBot/AssociationStyle:
|
||||
Exclude:
|
||||
@@ -54,48 +33,81 @@ FactoryBot/AssociationStyle:
|
||||
- 'spec/factories/like.rb'
|
||||
- 'spec/factories/scientific_name.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Offense count: 8
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AutoCorrect, Include, EnforcedStyle, ExplicitOnly.
|
||||
# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb
|
||||
# Configuration parameters: Include, EnforcedStyle, ExplicitOnly.
|
||||
# Include: **/*_spec.rb, **/spec/**/*, spec/factories.rb, spec/factories/**/*.rb, features/support/factories/**/*.rb
|
||||
# SupportedStyles: create_list, n_times
|
||||
FactoryBot/CreateList:
|
||||
Exclude:
|
||||
- 'spec/factories/member.rb'
|
||||
- 'spec/helpers/gardens_helper_spec.rb'
|
||||
- 'spec/views/comments/index.rss.haml_spec.rb'
|
||||
- 'spec/views/home/index_spec.rb'
|
||||
- 'spec/views/photos/index.html.haml_spec.rb'
|
||||
- 'spec/views/places/show.html.haml_spec.rb'
|
||||
- 'spec/views/posts/index.html.haml_spec.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: Include, MaxAmount.
|
||||
# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb
|
||||
FactoryBot/ExcessiveCreateList:
|
||||
Exclude:
|
||||
- 'spec/controllers/posts_controller_spec.rb'
|
||||
- 'spec/features/crops/show_spec.rb'
|
||||
- 'spec/features/percy/percy_spec.rb'
|
||||
|
||||
# Offense count: 1127
|
||||
# Offense count: 1135
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Include.
|
||||
# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb
|
||||
FactoryBot/SyntaxMethods:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Offense count: 5
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
||||
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
||||
Layout/EmptyLineBetweenDefs:
|
||||
Exclude:
|
||||
- 'db/migrate/20171129041341_create_photographings.rb'
|
||||
- 'db/migrate/20190130090437_add_crop_to_photographings.rb'
|
||||
|
||||
# Offense count: 10
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: space, no_space
|
||||
Layout/LineContinuationSpacing:
|
||||
Exclude:
|
||||
- 'app/mailers/notifier_mailer.rb'
|
||||
- 'app/models/seed.rb'
|
||||
- 'lib/tasks/growstuff.rake'
|
||||
- 'spec/features/rss/plantings_spec.rb'
|
||||
- 'spec/features/rss/posts_spec.rb'
|
||||
- 'spec/features/rss/seeds_spec.rb'
|
||||
- 'spec/models/seed_spec.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: aligned, indented
|
||||
Layout/LineEndStringConcatenationIndentation:
|
||||
Exclude:
|
||||
- 'app/mailers/notifier_mailer.rb'
|
||||
- 'app/models/seed.rb'
|
||||
- 'lib/tasks/growstuff.rake'
|
||||
- 'spec/features/rss/plantings_spec.rb'
|
||||
- 'spec/features/rss/posts_spec.rb'
|
||||
- 'spec/features/rss/seeds_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
||||
# URISchemes: http, https
|
||||
Layout/LineLength:
|
||||
Exclude:
|
||||
- 'app/helpers/crops_helper.rb'
|
||||
- 'db/seeds.rb'
|
||||
Max: 304
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Lint/AmbiguousOperatorPrecedence:
|
||||
Exclude:
|
||||
- 'db/seeds.rb'
|
||||
- 'spec/helpers/gardens_helper_spec.rb'
|
||||
- 'spec/helpers/seeds_helper_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: RequireParenthesesForMethodChains.
|
||||
Lint/AmbiguousRange:
|
||||
Exclude:
|
||||
- 'app/models/concerns/search_activities.rb'
|
||||
- 'app/models/concerns/search_harvests.rb'
|
||||
- 'app/models/concerns/search_plantings.rb'
|
||||
|
||||
@@ -118,12 +130,6 @@ Lint/EmptyBlock:
|
||||
- 'spec/features/crops/crop_detail_page_spec.rb'
|
||||
- 'spec/requests/authentications_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Lint/RedundantCopDisableDirective:
|
||||
Exclude:
|
||||
- 'db/migrate/20230313015323_create_active_storage_tables.active_storage.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Lint/RedundantDirGlobSort:
|
||||
@@ -136,46 +142,48 @@ Lint/SuppressedException:
|
||||
Exclude:
|
||||
- 'lib/tasks/testing.rake'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: strict, consistent
|
||||
Lint/SymbolConversion:
|
||||
Exclude:
|
||||
- 'app/controllers/likes_controller.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AutoCorrect.
|
||||
Lint/UselessAssignment:
|
||||
Exclude:
|
||||
- 'config.rb'
|
||||
- 'config/compass.rb'
|
||||
|
||||
# Offense count: 52
|
||||
# Offense count: 45
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
||||
Metrics/AbcSize:
|
||||
Max: 151
|
||||
|
||||
# Offense count: 14
|
||||
# Offense count: 10
|
||||
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
|
||||
# AllowedMethods: refine
|
||||
Metrics/BlockLength:
|
||||
Max: 115
|
||||
|
||||
# Offense count: 7
|
||||
# Configuration parameters: CountComments, CountAsOne.
|
||||
Metrics/ClassLength:
|
||||
Max: 188
|
||||
Max: 61
|
||||
|
||||
# Offense count: 6
|
||||
# Configuration parameters: CountComments, CountAsOne.
|
||||
Metrics/ClassLength:
|
||||
Max: 171
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 32
|
||||
|
||||
# Offense count: 71
|
||||
# Offense count: 61
|
||||
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
||||
Metrics/MethodLength:
|
||||
Max: 127
|
||||
Max: 59
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: CountComments, CountAsOne.
|
||||
Metrics/ModuleLength:
|
||||
Max: 125
|
||||
|
||||
# Offense count: 5
|
||||
# Offense count: 3
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 32
|
||||
@@ -194,7 +202,7 @@ RSpec/ContextWording:
|
||||
|
||||
# Offense count: 36
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
|
||||
# Configuration parameters: SkipBlocks, EnforcedStyle.
|
||||
# SupportedStyles: described_class, explicit
|
||||
RSpec/DescribedClass:
|
||||
Exclude:
|
||||
@@ -204,7 +212,6 @@ RSpec/DescribedClass:
|
||||
|
||||
# Offense count: 13
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AutoCorrect.
|
||||
RSpec/EmptyExampleGroup:
|
||||
Exclude:
|
||||
- 'spec/controllers/authentications_controller_spec.rb'
|
||||
@@ -220,26 +227,24 @@ RSpec/EmptyExampleGroup:
|
||||
- 'spec/views/photos/edit.html.haml_spec.rb'
|
||||
- 'spec/views/posts/_single.html.haml_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowConsecutiveOneLiners.
|
||||
RSpec/EmptyLineAfterExample:
|
||||
Exclude:
|
||||
- 'spec/models/ability_spec.rb'
|
||||
|
||||
# Offense count: 140
|
||||
# Offense count: 134
|
||||
# Configuration parameters: CountAsOne.
|
||||
RSpec/ExampleLength:
|
||||
Max: 25
|
||||
|
||||
# Offense count: 32
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
RSpec/ExcessiveDocstringSpacing:
|
||||
Exclude:
|
||||
- 'spec/controllers/crops_controller_spec.rb'
|
||||
- 'spec/features/crops/crop_photos_spec.rb'
|
||||
|
||||
# Offense count: 30
|
||||
RSpec/ExpectInHook:
|
||||
Exclude:
|
||||
- 'spec/controllers/garden_types_controller_spec.rb'
|
||||
- 'spec/controllers/gardens_controller_spec.rb'
|
||||
- 'spec/features/admin/forums_spec.rb'
|
||||
- 'spec/features/admin/plant_parts_spec.rb'
|
||||
- 'spec/features/admin/roles_spec.rb'
|
||||
- 'spec/features/crops/crop_photos_spec.rb'
|
||||
- 'spec/features/members/list_spec.rb'
|
||||
- 'spec/features/plantings/planting_a_crop_spec.rb'
|
||||
@@ -255,12 +260,11 @@ RSpec/HookArgument:
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AutoCorrect.
|
||||
RSpec/HooksBeforeExamples:
|
||||
Exclude:
|
||||
- 'spec/features/crops/creating_a_crop_spec.rb'
|
||||
|
||||
# Offense count: 37
|
||||
# Offense count: 35
|
||||
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
|
||||
RSpec/IndexedLet:
|
||||
Exclude:
|
||||
@@ -268,7 +272,6 @@ RSpec/IndexedLet:
|
||||
- 'spec/controllers/plantings_controller_spec.rb'
|
||||
- 'spec/features/crops/crop_photos_spec.rb'
|
||||
- 'spec/features/members/list_spec.rb'
|
||||
- 'spec/features/members/profile_spec.rb'
|
||||
- 'spec/features/percy/percy_spec.rb'
|
||||
- 'spec/features/planting_reminder_spec.rb'
|
||||
- 'spec/features/timeline/index_spec.rb'
|
||||
@@ -276,7 +279,7 @@ RSpec/IndexedLet:
|
||||
- 'spec/models/member_spec.rb'
|
||||
- 'spec/views/forums/index.html.haml_spec.rb'
|
||||
|
||||
# Offense count: 720
|
||||
# Offense count: 710
|
||||
# Configuration parameters: AssignmentOnly.
|
||||
RSpec/InstanceVariable:
|
||||
Enabled: false
|
||||
@@ -285,12 +288,6 @@ RSpec/InstanceVariable:
|
||||
RSpec/LetSetup:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
RSpec/MatchArray:
|
||||
Exclude:
|
||||
- 'spec/models/post_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
RSpec/MessageChain:
|
||||
Exclude:
|
||||
@@ -307,16 +304,16 @@ RSpec/MultipleDescribes:
|
||||
Exclude:
|
||||
- 'spec/features/crops/crop_wranglers_spec.rb'
|
||||
|
||||
# Offense count: 152
|
||||
# Offense count: 147
|
||||
RSpec/MultipleExpectations:
|
||||
Max: 19
|
||||
|
||||
# Offense count: 138
|
||||
# Offense count: 137
|
||||
# Configuration parameters: AllowSubject.
|
||||
RSpec/MultipleMemoizedHelpers:
|
||||
Max: 14
|
||||
|
||||
# Offense count: 133
|
||||
# Offense count: 132
|
||||
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
||||
# SupportedStyles: always, named_only
|
||||
RSpec/NamedSubject:
|
||||
@@ -327,7 +324,7 @@ RSpec/NamedSubject:
|
||||
RSpec/NestedGroups:
|
||||
Max: 6
|
||||
|
||||
# Offense count: 403
|
||||
# Offense count: 407
|
||||
# Configuration parameters: AllowedPatterns.
|
||||
# AllowedPatterns: ^expect_, ^assert_
|
||||
RSpec/NoExpectationExample:
|
||||
@@ -339,6 +336,21 @@ RSpec/PendingWithoutReason:
|
||||
- 'spec/features/seeds/misc_seeds_spec.rb'
|
||||
- 'spec/features/unsubscribing_spec.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
RSpec/Rails/HaveHttpStatus:
|
||||
Exclude:
|
||||
- 'spec/controllers/api/v1/plantings_controller_spec.rb'
|
||||
- 'spec/controllers/harvests_controller_spec.rb'
|
||||
- 'spec/controllers/likes_controller_spec.rb'
|
||||
- 'spec/requests/harvests_spec.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Inferences.
|
||||
RSpec/Rails/InferredSpecType:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
RSpec/RepeatedDescription:
|
||||
Exclude:
|
||||
@@ -358,7 +370,6 @@ RSpec/RepeatedExampleGroupBody:
|
||||
|
||||
# Offense count: 6
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AutoCorrect.
|
||||
RSpec/ScatteredSetup:
|
||||
Exclude:
|
||||
- 'spec/features/percy/percy_spec.rb'
|
||||
@@ -371,6 +382,14 @@ RSpec/SpecFilePathFormat:
|
||||
Exclude:
|
||||
- 'spec/controllers/member_controller_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: Include.
|
||||
# Include: **/*_spec*rb*, **/spec/**/*
|
||||
RSpec/SpecFilePathSuffix:
|
||||
Exclude:
|
||||
- 'spec/features/seeds/seed_photos.rb'
|
||||
- 'spec/models/garden_type.rb'
|
||||
|
||||
# Offense count: 3
|
||||
RSpec/StubbedMock:
|
||||
Exclude:
|
||||
@@ -394,24 +413,7 @@ RSpec/VerifiedDoubles:
|
||||
- 'spec/controllers/gardens_controller_spec.rb'
|
||||
- 'spec/views/devise/shared/_links_spec.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: ResponseMethods.
|
||||
# ResponseMethods: response, last_response
|
||||
RSpecRails/HaveHttpStatus:
|
||||
Exclude:
|
||||
- 'spec/controllers/api/v1/plantings_controller_spec.rb'
|
||||
- 'spec/controllers/harvests_controller_spec.rb'
|
||||
- 'spec/controllers/likes_controller_spec.rb'
|
||||
- 'spec/requests/harvests_spec.rb'
|
||||
|
||||
# Offense count: 16
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Inferences.
|
||||
RSpecRails/InferredSpecType:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 28
|
||||
# Offense count: 26
|
||||
# Configuration parameters: Database, Include.
|
||||
# SupportedDatabases: mysql, postgresql
|
||||
# Include: db/**/*.rb
|
||||
@@ -434,6 +436,17 @@ Rails/Date:
|
||||
Exclude:
|
||||
- 'app/mailers/notifier_mailer.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: slashes, arguments
|
||||
Rails/FilePath:
|
||||
Exclude:
|
||||
- 'app/controllers/crops_controller.rb'
|
||||
- 'config/application.rb'
|
||||
- 'config/environments/development.rb'
|
||||
- 'db/seeds.rb'
|
||||
|
||||
# Offense count: 11
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
||||
@@ -472,13 +485,12 @@ Rails/I18nLocaleAssignment:
|
||||
Rails/I18nLocaleTexts:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Offense count: 2
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/controllers/**/*.rb, app/mailers/**/*.rb
|
||||
Rails/LexicallyScopedActionFilter:
|
||||
Exclude:
|
||||
- 'app/controllers/data_controller.rb'
|
||||
- 'app/controllers/registrations_controller.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Rails/OutputSafety:
|
||||
@@ -486,12 +498,6 @@ Rails/OutputSafety:
|
||||
- 'app/helpers/auto_suggest_helper.rb'
|
||||
- 'app/helpers/gardens_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/PluralizationGrammar:
|
||||
Exclude:
|
||||
- 'spec/requests/plantings_spec.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Include.
|
||||
@@ -502,10 +508,8 @@ Rails/RakeEnvironment:
|
||||
- 'lib/tasks/i18n.rake'
|
||||
- 'lib/tasks/testing.rake'
|
||||
|
||||
# Offense count: 9
|
||||
# Offense count: 10
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowedReceivers.
|
||||
# AllowedReceivers: ActionMailer::Preview, ActiveSupport::TimeZone
|
||||
Rails/RedundantActiveRecordAllMethod:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/roles_controller.rb'
|
||||
@@ -514,6 +518,7 @@ Rails/RedundantActiveRecordAllMethod:
|
||||
- 'app/controllers/plant_parts_controller.rb'
|
||||
- 'app/controllers/scientific_names_controller.rb'
|
||||
- 'app/services/openfarm_service.rb'
|
||||
- 'spec/features/members/deletion_spec.rb'
|
||||
- 'spec/features/percy/percy_spec.rb'
|
||||
- 'spec/models/harvest_spec.rb'
|
||||
|
||||
@@ -536,8 +541,8 @@ Rails/ResponseParsedBody:
|
||||
- 'spec/controllers/likes_controller_spec.rb'
|
||||
- 'spec/requests/api/v1/crop_request_spec.rb'
|
||||
- 'spec/requests/api/v1/gardens_request_spec.rb'
|
||||
- 'spec/requests/api/v1/harvests_request_spec.rb'
|
||||
- 'spec/requests/api/v1/members_request_spec.rb'
|
||||
- 'spec/requests/api/v1/harvest_request_spec.rb'
|
||||
- 'spec/requests/api/v1/member_request_spec.rb'
|
||||
- 'spec/requests/api/v1/photos_request_spec.rb'
|
||||
- 'spec/requests/api/v1/plantings_request_spec.rb'
|
||||
- 'spec/requests/api/v1/seeds_request_spec.rb'
|
||||
@@ -557,11 +562,26 @@ Rails/RootPathnameMethods:
|
||||
- 'app/controllers/crops_controller.rb'
|
||||
- 'app/helpers/icons_helper.rb'
|
||||
|
||||
# Offense count: 21
|
||||
# Offense count: 20
|
||||
# Configuration parameters: Include.
|
||||
# Include: db/**/*.rb
|
||||
Rails/ThreeStateBooleanColumn:
|
||||
Enabled: false
|
||||
Exclude:
|
||||
- 'db/migrate/20121203034745_add_tos_agreement_to_users.rb'
|
||||
- 'db/migrate/20130206051328_add_show_email_to_member.rb'
|
||||
- 'db/migrate/20130212123628_create_notifications.rb'
|
||||
- 'db/migrate/20130327120024_add_send_email_to_member.rb'
|
||||
- 'db/migrate/20130517051922_create_account_types.rb'
|
||||
- 'db/migrate/20130718011247_add_trading_to_seeds.rb'
|
||||
- 'db/migrate/20130722050836_remove_tradable_from_seeds.rb'
|
||||
- 'db/migrate/20130827105823_add_newsletter_to_member.rb'
|
||||
- 'db/migrate/20131025104228_add_fields_to_gardens.rb'
|
||||
- 'db/migrate/20140829230600_add_finished_to_planting.rb'
|
||||
- 'db/migrate/20140928085713_add_send_planting_reminder_to_member.rb'
|
||||
- 'db/migrate/20171022032108_all_the_predictions.rb'
|
||||
- 'db/migrate/20180213005731_seed_usage.rb'
|
||||
- 'db/migrate/20190720000555_create_mailboxer.mailboxer_engine.rb'
|
||||
- 'db/migrate/20190720000558_add_delivery_tracking_info_to_mailboxer_receipts.mailboxer_engine.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Configuration parameters: Include.
|
||||
@@ -583,18 +603,6 @@ Rails/WhereEquals:
|
||||
- 'app/models/harvest.rb'
|
||||
- 'app/models/planting.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/WhereRange:
|
||||
Exclude:
|
||||
- 'app/models/concerns/predict_planting.rb'
|
||||
- 'app/models/garden.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Rake/MethodDefinitionInTask:
|
||||
Exclude:
|
||||
- 'lib/tasks/growstuff.rake'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
@@ -614,7 +622,13 @@ Style/CommentedKeyword:
|
||||
- 'spec/models/photo_spec.rb'
|
||||
- 'spec/models/planting_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Offense count: 37
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowedVars.
|
||||
Style/FetchEnvVar:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: always, always_true, never
|
||||
@@ -622,16 +636,33 @@ Style/FrozenStringLiteralComment:
|
||||
Exclude:
|
||||
- 'config/initializers/new_framework_defaults_6_0.rb'
|
||||
- 'db/migrate/20200801084007_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb'
|
||||
- 'db/migrate/20200815012538_remove_median_function.rb'
|
||||
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Offense count: 2
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Style/GlobalStdStream:
|
||||
Exclude:
|
||||
- 'config/environments/production.rb'
|
||||
- 'lib/tasks/gbif.rake'
|
||||
- 'lib/tasks/openfarm.rake'
|
||||
|
||||
# Offense count: 5
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
||||
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
||||
# SupportedShorthandSyntax: always, never, either, consistent
|
||||
Style/HashSyntax:
|
||||
Exclude:
|
||||
- 'app/models/csv_importer.rb'
|
||||
- 'spec/requests/api/v1/gardens_request_spec.rb'
|
||||
- 'spec/requests/api/v1/plantings_request_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/IfUnlessModifier:
|
||||
Exclude:
|
||||
- 'bin/setup'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: AllowedMethods.
|
||||
@@ -653,23 +684,19 @@ Style/MixinUsage:
|
||||
- 'spec/rails_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: literals, strict
|
||||
Style/MutableConstant:
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/NegatedIfElseCondition:
|
||||
Exclude:
|
||||
- 'app/models/activity.rb'
|
||||
- 'app/helpers/crops_helper.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
|
||||
# SupportedStyles: predicate, comparison
|
||||
Style/NumericPredicate:
|
||||
Exclude:
|
||||
- 'app/helpers/crops_helper.rb'
|
||||
- 'app/helpers/harvests_helper.rb'
|
||||
- 'app/helpers/plantings_helper.rb'
|
||||
- 'app/models/concerns/predict_planting.rb'
|
||||
|
||||
# Offense count: 6
|
||||
Style/OpenStructUse:
|
||||
@@ -683,6 +710,15 @@ Style/OptionalBooleanParameter:
|
||||
Exclude:
|
||||
- 'app/models/concerns/member_newsletter.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: same_as_string_literals, single_quotes, double_quotes
|
||||
Style/QuotedSymbols:
|
||||
Exclude:
|
||||
- 'app/models/seed.rb'
|
||||
- 'spec/controllers/crops_controller_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Methods.
|
||||
@@ -690,6 +726,12 @@ Style/RedundantArgument:
|
||||
Exclude:
|
||||
- 'app/helpers/application_helper.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/RedundantConstantBase:
|
||||
Exclude:
|
||||
- 'config.ru'
|
||||
|
||||
# Offense count: 4
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: SafeForConstants.
|
||||
@@ -697,6 +739,19 @@ Style/RedundantFetchBlock:
|
||||
Exclude:
|
||||
- 'config/puma.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Style/RedundantRegexpArgument:
|
||||
Exclude:
|
||||
- 'db/migrate/20191119030244_cms_tags.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowMultipleReturnValues.
|
||||
Style/RedundantReturn:
|
||||
Exclude:
|
||||
- 'app/controllers/messages_controller.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowModifier.
|
||||
@@ -705,7 +760,7 @@ Style/SoleNestedConditional:
|
||||
- 'app/controllers/application_controller.rb'
|
||||
- 'app/controllers/messages_controller.rb'
|
||||
|
||||
# Offense count: 24
|
||||
# Offense count: 20
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Mode.
|
||||
Style/StringConcatenation:
|
||||
|
||||
@@ -1 +1 @@
|
||||
3.3.8
|
||||
3.1.4
|
||||
|
||||
@@ -93,12 +93,9 @@ submit the change with your pull request.
|
||||
- Martina Simicic / [simicic](https://github.com/simicic)
|
||||
- Rowan Crawford / [wombleton](https://github.com/wombleton)
|
||||
- Ítalo Pires / [italopires](https://github.com/italopires)
|
||||
- Bennett Zink / [bennett-zink](https://github.com/bennett-zink)
|
||||
- Dominick Thornton / [domthor](https://github.com/domthor)
|
||||
|
||||
## Bots
|
||||
|
||||
### Security and Dependency Updates
|
||||
- `codefactor-io[bot]`
|
||||
- DeppBot / [deppbot](https://github.com/deppbot)
|
||||
- `dependabot[bot]` [dependabot](https://github.com/dependabot-bot) / [dependabot-preview](https://github.com/apps/dependabot-preview)
|
||||
|
||||
36
Gemfile
36
Gemfile
@@ -5,13 +5,13 @@ source 'https://rubygems.org'
|
||||
# Match ruby version in .ruby-version
|
||||
ruby File.read('.ruby-version')
|
||||
|
||||
gem 'rails', '~> 7.2.0'
|
||||
gem 'rails', '~> 7.0.7'
|
||||
|
||||
# Keeping old sprockets
|
||||
# https://github.com/rails/sprockets-rails/issues/444#issuecomment-637817050
|
||||
gem "sprockets", "<4"
|
||||
|
||||
gem 'bundler', '>= 2.4.22'
|
||||
gem 'bundler', '>= 2.3.10'
|
||||
|
||||
gem 'coffee-rails'
|
||||
gem 'haml'
|
||||
@@ -24,7 +24,7 @@ gem 'rswag-api'
|
||||
gem 'rswag-ui'
|
||||
|
||||
# CSS framework
|
||||
gem "bootstrap", ">= 5.0.0"
|
||||
gem "bootstrap", ">= 4.6.2"
|
||||
gem 'material-sass', '4.1.1'
|
||||
|
||||
# Icons used by bootstrap/material-sass
|
||||
@@ -33,18 +33,18 @@ gem 'material_icons'
|
||||
# icons
|
||||
gem 'font-awesome-sass'
|
||||
|
||||
gem 'terser'
|
||||
gem 'uglifier' # JavaScript compressor
|
||||
|
||||
gem 'oj' # Speeds up json
|
||||
|
||||
# planting and harvest predictions
|
||||
# based on median values for the crop
|
||||
gem 'active_median'
|
||||
gem 'active_median', '0.2.0'
|
||||
gem 'active_record_union'
|
||||
|
||||
gem 'flickraw'
|
||||
gem 'jquery-rails'
|
||||
gem 'jquery-ui-rails', github: 'jquery-ui-rails/jquery-ui-rails', tag: 'v7.0.0' # See https://github.com/jquery-ui-rails/jquery-ui-rails/issues/146
|
||||
gem 'jquery-ui-rails'
|
||||
|
||||
gem 'cancancan' # for checking member privileges
|
||||
gem 'csv_shaper' # CSV export
|
||||
@@ -100,7 +100,7 @@ gem 'omniauth-twitter'
|
||||
gem "chartkick"
|
||||
|
||||
# clever elastic search
|
||||
gem 'elasticsearch', '~> 7.0.0'
|
||||
gem 'elasticsearch', '< 7.0.0'
|
||||
gem 'searchkick'
|
||||
|
||||
gem "hashie", ">= 3.5.3"
|
||||
@@ -124,19 +124,10 @@ gem 'rack-protection', '>= 2.0.1'
|
||||
gem 'mailboxer', '>= 0.15.1'
|
||||
|
||||
gem 'faraday'
|
||||
gem 'faraday_middleware'
|
||||
|
||||
gem 'rack-cors'
|
||||
|
||||
gem 'icalendar'
|
||||
|
||||
# for signups as requested by email service
|
||||
gem 'recaptcha'
|
||||
|
||||
# External APIs for data
|
||||
gem "gbifrb"
|
||||
|
||||
gem "msgpack"
|
||||
|
||||
group :production do
|
||||
gem 'bonsai-elasticsearch-rails' # Integration with Bonsa-Elasticsearch on heroku
|
||||
gem 'dalli'
|
||||
@@ -162,20 +153,14 @@ group :development, :test do
|
||||
gem 'factory_bot_rails' # for creating test data
|
||||
gem 'faker'
|
||||
gem 'haml-rails' # HTML templating language
|
||||
gem 'pry'
|
||||
gem 'query_diet'
|
||||
gem 'rspec-activemodel-mocks'
|
||||
gem 'rspec-rails' # unit testing framework
|
||||
gem 'rswag-specs'
|
||||
gem 'rubocop-capybara'
|
||||
gem 'rubocop-factory_bot'
|
||||
gem 'rubocop-rails'
|
||||
gem 'rubocop-rake'
|
||||
gem 'rubocop-rspec'
|
||||
gem 'rubocop-rspec_rails'
|
||||
gem 'webrat' # provides HTML matchers for view tests
|
||||
|
||||
gem 'crowdin-cli' # for translations
|
||||
gem 'dotenv-rails'
|
||||
|
||||
# cli utils
|
||||
@@ -187,12 +172,11 @@ group :development, :test do
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'axe-core-capybara'
|
||||
gem 'axe-core-rspec'
|
||||
gem 'codeclimate-test-reporter', require: false
|
||||
gem 'rails-controller-testing'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'timecop'
|
||||
gem 'vcr'
|
||||
gem 'webdrivers'
|
||||
end
|
||||
|
||||
group :travis do
|
||||
|
||||
762
Gemfile.lock
762
Gemfile.lock
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
# 🌱 Growstuff
|
||||
|
||||

|
||||
[](https://codeclimate.com/github/Growstuff/growstuff)
|
||||
|
||||
Welcome to the Growstuff project.
|
||||
|
||||
@@ -14,11 +15,6 @@ Growstuff was founded in 2012 and has been built by dozens of
|
||||
[contributors](CONTRIBUTORS.md). We are an inclusive, welcoming project, and
|
||||
encourage participation from people of all backgrounds and skill levels.
|
||||
|
||||
## Want to contribute?
|
||||
|
||||
Don't ask to ask, the best way to get started is to fork the project, start a codespace and get hacking.
|
||||
Dive on in and submit your PRs.
|
||||
|
||||
## Important links
|
||||
|
||||
* [Issues](https://github.com/orgs/Growstuff/projects/1) (features we're
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<!-- MIT Licenced, https://www.svgrepo.com/svg/336823/plan -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="48" height="48" fill="white" fill-opacity="0.01"/>
|
||||
<path d="M5 19H43V41C43 42.1046 42.1046 43 41 43H7C5.89543 43 5 42.1046 5 41V19Z" fill="#2F88FF" stroke="#000000" stroke-width="4" stroke-linejoin="round"/>
|
||||
<path d="M5 10C5 8.89543 5.89543 8 7 8H41C42.1046 8 43 8.89543 43 10V19H5V10Z" stroke="#000000" stroke-width="4" stroke-linejoin="round"/>
|
||||
<path d="M16 31L22 37L34 25" stroke="white" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M16 5V13" stroke="#000000" stroke-width="4" stroke-linecap="round"/>
|
||||
<path d="M32 5V13" stroke="#000000" stroke-width="4" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 916 B |
@@ -18,17 +18,6 @@
|
||||
// = require jquery-ui/widgets/autocomplete
|
||||
// = require bootstrap-sprockets
|
||||
// = require bootstrap-datepicker
|
||||
// = require bootstrap
|
||||
// = require material
|
||||
// = require_tree .
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function(event) {
|
||||
var popoverTrigger = Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
|
||||
popoverTrigger.map(function(popoverTrigger2) {
|
||||
return new bootstrap.Popover(popoverTrigger2);
|
||||
});
|
||||
|
||||
var tooltipTrigger = Array.prototype.slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
|
||||
tooltipTrigger.map(function(tooltipTrigger2) {
|
||||
return new bootstrap.Tooltip(tooltipTrigger2);
|
||||
});
|
||||
});
|
||||
|
||||
4
app/assets/javascripts/bootstrap-accessibility.min.js
vendored
Normal file
4
app/assets/javascripts/bootstrap-accessibility.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
app/assets/javascripts/bootstrap.js.coffee
Normal file
4
app/assets/javascripts/bootstrap.js.coffee
Normal file
@@ -0,0 +1,4 @@
|
||||
jQuery ->
|
||||
$("a[rel=popover]").popover()
|
||||
$(".tooltip").tooltip()
|
||||
$("a[rel=tooltip]").tooltip()
|
||||
@@ -5,7 +5,7 @@ jQuery ->
|
||||
$(".remove-altname-row").css("display", "inline-block")
|
||||
|
||||
-$ ->
|
||||
sci_template = "<div id='sci_template[INDEX]' class='template col-md-12'><div class='col-md-2'><label>Scientific name INDEX:</label></div><div class='col-md-8'><input name='sci_name[INDEX]' class='scientific-name-auto-suggest form-control' id='sci_name[INDEX]' data-source-url='/scientific_names/gbif_suggest')'></input><span class='help-block'>Scientific name of crop</span><input type='text' id='sci_gbif_key[INDEX]' class=''></div><div class='col-md-2'></div></div>"
|
||||
sci_template = "<div id='sci_template[INDEX]' class='template col-md-12'><div class='col-md-2'><label>Scientific name INDEX:</label></div><div class='col-md-8'><input name='sci_name[INDEX]' class='form-control', id='sci_name[INDEX]')'></input><span class='help-block'>Scientific name of crop.</span></div><div class='col-md-2'></div></div>"
|
||||
|
||||
sci_index = $('#scientific_names .template').length + 1
|
||||
|
||||
@@ -21,7 +21,7 @@ jQuery ->
|
||||
element = document.getElementById(tmp)
|
||||
element.remove()
|
||||
|
||||
alt_template = "<div id='alt_template[INDEX]' class='template col-md-12'><div class='col-md-2'><label>Alternate name INDEX:</label></div><div class='col-md-8'><input name='alt_name[INDEX]' class='form-control' id='alt_name[INDEX]')'></input><span class='help-block'>Alternate name of crop.</span></div><div class='col-md-2'></div></div>"
|
||||
alt_template = "<div id='alt_template[INDEX]' class='template col-md-12'><div class='col-md-2'><label>Alternate name INDEX:</label></div><div class='col-md-8'><input name='alt_name[INDEX]' class='form-control', id='alt_name[INDEX]')'></input><span class='help-block'>Alternate name of crop.</span></div><div class='col-md-2'></div></div>"
|
||||
|
||||
alt_index = $('#alternate_names .template').length + 1
|
||||
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
$(document).ready(function() {
|
||||
$('.like-btn').show();
|
||||
|
||||
/**
|
||||
* Handles the result of an ajax call and updates UI
|
||||
*
|
||||
* @param {object} data JSON data from ajax response
|
||||
* @param {string} type object type (ie: post, activity, etc)
|
||||
*/
|
||||
var likeableSuccess = function(data, type) {
|
||||
var target = '.' + type + '-' + data.id;
|
||||
var objectClass = type.charAt(0).toUpperCase() + type.slice(1);
|
||||
var likeButton = $(target + ' .' + type + '-like');
|
||||
var likeBadge = $(target + ' .like-badge');
|
||||
$('.post-like').on('ajax:success', function(event, data) {
|
||||
var likeButton = $('#post-' + data.id + ' .post-like');
|
||||
var likeBadge = $('#post-'+ data.id + ' .like-badge');
|
||||
|
||||
$(target + ' .like-count').text(data.like_count);
|
||||
$('#post-' + data.id + ' .like-count').text(data.like_count);
|
||||
if (data.liked_by_member) {
|
||||
likeBadge.addClass('liked');
|
||||
likeButton.data('method', 'delete');
|
||||
@@ -22,26 +14,11 @@ $(document).ready(function() {
|
||||
} else {
|
||||
likeBadge.removeClass('liked');
|
||||
likeButton.data('method', 'post');
|
||||
likeButton.attr('href', '/likes.json?type=' + objectClass + '&id=' + data.id);
|
||||
likeButton.attr('href', '/likes.json?type=Post&id=' + data.id);
|
||||
likeButton.text('Like');
|
||||
}
|
||||
};
|
||||
|
||||
$('.post-like').on('ajax:success', function(event, data) {
|
||||
likeableSuccess(data, 'post');
|
||||
});
|
||||
|
||||
$('.activity-like').on('ajax:success', function(event, data) {
|
||||
likeableSuccess(data, 'activity');
|
||||
});
|
||||
|
||||
$('.planting-like').on('ajax:success', function(event, data) {
|
||||
likeableSuccess(data, 'planting');
|
||||
});
|
||||
|
||||
$('.harvest-like').on('ajax:success', function(event, data) {
|
||||
likeableSuccess(data, 'harvest');
|
||||
});
|
||||
|
||||
$('.photo-like').on('ajax:success', function(event, data) {
|
||||
var likeBadge = $('#photo-'+ data.id + ' .like-badge');
|
||||
|
||||
1
app/assets/javascripts/nav.js
Normal file
1
app/assets/javascripts/nav.js
Normal file
@@ -0,0 +1 @@
|
||||
$('.dropdown-toggle').dropdown();
|
||||
@@ -1,31 +0,0 @@
|
||||
# TODO: This assumes one autocomplete per page.
|
||||
# Needs to be a function so that when we append one of these, it gets uniquely associated with the hidden controls.
|
||||
jQuery ->
|
||||
|
||||
if el = $( '.scientific-name-auto-suggest' )
|
||||
|
||||
id = $( '.scientific-name-auto-suggest-id' )
|
||||
|
||||
el.autocomplete
|
||||
minLength: 3,
|
||||
source: el.attr( 'data-source-url' ),
|
||||
focus: ( event, ui ) ->
|
||||
el.val( ui.item.canonicalName )
|
||||
id.val( ui.item.nameKey )
|
||||
false
|
||||
select: ( event, ui ) ->
|
||||
el.val( ui.item.canonicalName )
|
||||
id.val( ui.item.nameKey )
|
||||
false
|
||||
response: ( event, ui ) ->
|
||||
id.val( "" )
|
||||
for item in ui.content
|
||||
if item.name == el.val()
|
||||
id.val( item.nameKey )
|
||||
|
||||
if el.data( 'uiAutocomplete' )
|
||||
el.data( 'uiAutocomplete' )._renderItem = ( ul, item ) ->
|
||||
$( '<li class="list-group-item"></li>' )
|
||||
.data( 'item.autocomplete', item )
|
||||
.append( "<a>#{item.canonicalName} (#{item.scientificName}) - #{item.rank}</a>" )
|
||||
.appendTo( ul )
|
||||
@@ -1,22 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
var url = location.href.replace(/\/$/, '');
|
||||
|
||||
if (location.hash) {
|
||||
var hash = url.split('#');
|
||||
var triggerEl = document.querySelector('#myTab a[href="#' + hash[1] + '"]');
|
||||
var tab = new bootstrap.Tab(triggerEl);
|
||||
tab.show();
|
||||
url = location.href.replace(/\/#/, '#');
|
||||
history.replaceState(null, null, url);
|
||||
setTimeout(function() {
|
||||
$(window).scrollTop(0);
|
||||
}, 20);
|
||||
}
|
||||
|
||||
$('a[data-bs-toggle="tab"]').on('click', function() {
|
||||
var newUrl;
|
||||
var hash = $(this).attr('href');
|
||||
newUrl = url.split('#')[0] + hash;
|
||||
history.replaceState(null, null, newUrl);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
$(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.crop-sci-name {
|
||||
h5.crop-sci-name {
|
||||
background-color: $beige;
|
||||
color: $black;
|
||||
font-size: 0.7em;
|
||||
|
||||
@@ -40,22 +40,9 @@
|
||||
height: 250px;
|
||||
width: 100%;
|
||||
}
|
||||
.card {
|
||||
.badge-location {
|
||||
background-color: darken($blue, 10%);
|
||||
border-radius: 5%;
|
||||
color: $white;
|
||||
|
||||
.fa-map-marker {
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
.badge {
|
||||
text-overflow: ellipsis;
|
||||
white-space: normal;
|
||||
align-items: end;
|
||||
max-height: 1rlh;
|
||||
-webkit-line-clamp: 1;
|
||||
}
|
||||
}
|
||||
.badge-location {
|
||||
background-color: darken($blue, 10%);
|
||||
border-radius: 5%;
|
||||
color: $white;
|
||||
}
|
||||
|
||||
@@ -47,13 +47,4 @@
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
max-height: 2em;
|
||||
-webkit-line-clamp: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 0.5em;
|
||||
padding-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.seed-card {
|
||||
.text {
|
||||
opacity: 0.95;
|
||||
opacity: 0.8;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//$screen-md-min: 1028px
|
||||
|
||||
// Base colours
|
||||
$beige: #f4f2ef;
|
||||
$beige: #f3f1ee;
|
||||
$brown: #413f3b;
|
||||
|
||||
$green: #57803c;
|
||||
$green: #5f8e43;
|
||||
$blue: #2f4365;
|
||||
$red: #ff4d43;
|
||||
$orange: #ffa500;
|
||||
|
||||
@@ -54,12 +54,6 @@
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
.d-flex {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
border-left: 0;
|
||||
margin-left: 0;
|
||||
|
||||
@@ -8,9 +8,6 @@ body {
|
||||
font-family: $default-font;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
.navbar-brand {
|
||||
.site-name {
|
||||
font-family: "Modak", cursive;
|
||||
@@ -19,7 +16,7 @@ body {
|
||||
}
|
||||
|
||||
img {
|
||||
height: 100%;
|
||||
height: 60px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,15 +101,13 @@ section {
|
||||
background: $white;
|
||||
box-shadow: 1px 3px 3px 1px darken($beige, 20%);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
0.1s transform cubic-bezier(0.155, 1.105, 0.295, 1.12),
|
||||
0.1s box-shadow,
|
||||
0.1s -webkit-transform cubic-bezier(0.155, 1.105, 0.295, 1.12);
|
||||
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:
|
||||
1px 3px 3px 1px darken($beige, 30%);
|
||||
box-shadow: 0 10px 20px darken($beige, 30%), 0 4px 8px darken($beige, 40%);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +144,10 @@ section {
|
||||
color: $brown;
|
||||
}
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
background-color: $beige;
|
||||
}
|
||||
}
|
||||
|
||||
.img-cover,
|
||||
@@ -355,9 +354,7 @@ ul.thumbnail-buttons {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
.text-muted {
|
||||
color: $blue;
|
||||
}
|
||||
|
||||
.jumbotron {
|
||||
background-color: $beige;
|
||||
margin-bottom: 1em;
|
||||
@@ -367,23 +364,15 @@ ul.thumbnail-buttons {
|
||||
h1 {
|
||||
font-size: 400%;
|
||||
}
|
||||
.stats a {
|
||||
color: $black;
|
||||
}
|
||||
|
||||
// signup widget on homepage
|
||||
.signup {
|
||||
background-color: darken($green, 20%);
|
||||
border: 1px solid darken($green, 20%);
|
||||
color: $white;
|
||||
background-color: lighten($green, 40%);
|
||||
border: 1px solid lighten($green, 20%);
|
||||
border-radius: 6px;
|
||||
line-height: 200%;
|
||||
padding: 15px;
|
||||
text-align: center;
|
||||
|
||||
.btn-info {
|
||||
background-color: $blue;
|
||||
}
|
||||
}
|
||||
|
||||
.info {
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivitiesController < DataController
|
||||
def index
|
||||
@show_all = params[:all] == '1'
|
||||
|
||||
where = {}
|
||||
where['active'] = true unless @show_all
|
||||
|
||||
if params[:member_slug]
|
||||
@owner = Member.find_by(slug: params[:member_slug])
|
||||
where['owner_id'] = @owner.id unless @owner.nil?
|
||||
end
|
||||
|
||||
@activities = Activity.search(
|
||||
where:,
|
||||
page: params[:page],
|
||||
limit: 30,
|
||||
boost_by: [:created_at],
|
||||
load: false
|
||||
)
|
||||
@filename = "Growstuff-#{specifics}Activities-#{Time.zone.now.to_fs(:number)}.csv"
|
||||
respond_with(@activities)
|
||||
end
|
||||
|
||||
def show
|
||||
respond_with @activity
|
||||
end
|
||||
|
||||
def new
|
||||
@activity = Activity.new(
|
||||
owner: current_member,
|
||||
due_date: Date.today
|
||||
)
|
||||
if params[:garden_id]
|
||||
@activity.garden = Garden.find_by(
|
||||
owner: current_member,
|
||||
id: params[:garden_id]
|
||||
)
|
||||
end
|
||||
|
||||
if params[:planting_id]
|
||||
@activity.planting = Planting.find_by(
|
||||
owner: current_member,
|
||||
id: params[:planting_id]
|
||||
)
|
||||
end
|
||||
|
||||
respond_with @activity
|
||||
end
|
||||
|
||||
def edit
|
||||
# the following are needed to display the form but aren't used
|
||||
@gardens = @activity.owner.gardens.active.order_by_name
|
||||
@plantings = @activity.owner.plantings.active
|
||||
end
|
||||
|
||||
def create
|
||||
@activity = Activity.new(activity_params)
|
||||
@activity.owner = current_member
|
||||
@activity.save
|
||||
respond_with @activity
|
||||
end
|
||||
|
||||
def update
|
||||
@activity.update(activity_params)
|
||||
respond_with @activity
|
||||
end
|
||||
|
||||
def destroy
|
||||
@activity.destroy
|
||||
respond_with @activity, location: @activity.garden
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def activity_params
|
||||
params.require(:activity).permit(
|
||||
:name, :description, :category, :finished,
|
||||
:garden_id, :planting_id, :due_date
|
||||
)
|
||||
end
|
||||
|
||||
def specifics
|
||||
return if @owner.blank?
|
||||
|
||||
"#{@owner.to_param}-"
|
||||
end
|
||||
end
|
||||
@@ -8,7 +8,7 @@ module Admin
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@roles = Role.all.order(:name).paginate(page: params[:page])
|
||||
@roles = Role.all.order(:name)
|
||||
respond_with @roles
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ module Admin
|
||||
|
||||
def destroy
|
||||
@role.destroy
|
||||
respond_with @role, location: admin_roles_path, notice: "Role was successfully deleted"
|
||||
respond_with @role, location: admin_roles_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -8,7 +8,7 @@ class AdminController < ApplicationController
|
||||
|
||||
def newsletter
|
||||
authorize! :manage, :all
|
||||
@members = Member.confirmed.wants_newsletter.all.paginate(page: params[:page], per_page: 100)
|
||||
@members = Member.confirmed.wants_newsletter.all
|
||||
respond_with @members
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class AlternateNamesController < ApplicationController
|
||||
# GET /alternate_names
|
||||
# GET /alternate_names.json
|
||||
def index
|
||||
@alternate_names = AlternateName.all.order(:name).paginate(page: params[:page], per_page: 100)
|
||||
@alternate_names = AlternateName.all.order(:name)
|
||||
respond_with(@alternate_names)
|
||||
end
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
# Working from codespaces, we want to turn off validation
|
||||
skip_before_action :verify_authenticity_token if Rails.env.development? && ENV['CODESPACE_NAME']
|
||||
|
||||
include ApplicationHelper
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class CropsController < ApplicationController
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@sort = params[:sort]
|
||||
@crops = Crop.search('*', boost_by: %i(plantings_count harvests_count),
|
||||
limit: 100,
|
||||
page: params[:page],
|
||||
@@ -45,12 +46,6 @@ class CropsController < ApplicationController
|
||||
respond_with @crop, location: @crop
|
||||
end
|
||||
|
||||
def gbif
|
||||
@crop = Crop.find(params[:crop_slug])
|
||||
@crop.update_gbif_data!
|
||||
respond_with @crop, location: @crop
|
||||
end
|
||||
|
||||
def hierarchy
|
||||
@crops = Crop.toplevel.order(:name)
|
||||
respond_with @crops
|
||||
@@ -63,15 +58,7 @@ class CropsController < ApplicationController
|
||||
page: params[:page],
|
||||
per_page: Crop.per_page,
|
||||
current_member:)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
render
|
||||
end
|
||||
format.json do
|
||||
render json: @crops.to_a
|
||||
end
|
||||
end
|
||||
respond_with @crops
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -81,7 +68,7 @@ class CropsController < ApplicationController
|
||||
@companions = @crop.companions.approved
|
||||
end
|
||||
format.svg do
|
||||
icon_data = @crop.svg_icon.presence || File.read(Rails.root.join("app/assets/images/icons/sprout.svg"))
|
||||
icon_data = @crop.svg_icon.presence || File.read(Rails.root.join('app', 'assets', 'images', 'icons', 'sprout.svg'))
|
||||
send_data(icon_data, type: "image/svg+xml", disposition: "inline")
|
||||
end
|
||||
format.json do
|
||||
@@ -113,12 +100,7 @@ class CropsController < ApplicationController
|
||||
@crop.approval_status = "pending"
|
||||
end
|
||||
|
||||
if Crop.transaction { @crop.save && save_crop_names }
|
||||
notify_wranglers
|
||||
else
|
||||
@crop.alternate_names.build
|
||||
@crop.scientific_names.build
|
||||
end
|
||||
notify_wranglers if Crop.transaction { @crop.save && save_crop_names }
|
||||
|
||||
respond_with @crop
|
||||
end
|
||||
@@ -138,7 +120,6 @@ class CropsController < ApplicationController
|
||||
if @crop.approval_status_changed?(from: "pending", to: "approved")
|
||||
notifier.deliver_now!
|
||||
@crop.update_openfarm_data!
|
||||
@crop.update_gbif_data!
|
||||
end
|
||||
else
|
||||
@crop.approval_status = @crop.approval_status_was
|
||||
@@ -182,7 +163,7 @@ class CropsController < ApplicationController
|
||||
return if params[param_name].blank?
|
||||
|
||||
destroy_names(name_type)
|
||||
params[param_name].each_value do |value|
|
||||
params[param_name].each do |_i, value|
|
||||
create_name!(name_type, value) unless value.empty?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GardenCollaboratorsController < ApplicationController
|
||||
before_action :authenticate_member!, except: %i(index show)
|
||||
before_action :load_garden
|
||||
load_and_authorize_resource id_param: :slug
|
||||
|
||||
respond_to :html
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@garden_collaborators = @garden.garden_collaborators.paginate(page: params[:page])
|
||||
respond_with(@garden_collaborators)
|
||||
end
|
||||
|
||||
def show
|
||||
@garden_collaborator = GardenCollaborator.find(params[:garden_collaborator_id])
|
||||
|
||||
respond_with(@garden_collaborator)
|
||||
end
|
||||
|
||||
def new
|
||||
@garden_collaborator = GardenCollaborator.new(garden: @garden)
|
||||
|
||||
authorize! :create, @garden_collaborator
|
||||
|
||||
respond_with(@garden_collaborator)
|
||||
end
|
||||
|
||||
def edit
|
||||
@garden_collaborator = GardenCollaborator.find(params[:id])
|
||||
|
||||
authorize! :update, @garden_collaborator
|
||||
|
||||
respond_with(@garden_collaborator)
|
||||
end
|
||||
|
||||
def create
|
||||
@garden_collaborator = GardenCollaborator.new(garden: @garden)
|
||||
authorize! :create, @garden_collaborator
|
||||
|
||||
@member = Member.find_by(slug: params[:garden_collaborator][:member_slug])
|
||||
|
||||
@garden_collaborator.member = @member
|
||||
if @garden_collaborator.save
|
||||
redirect_to garden_garden_collaborators_path(@garden)
|
||||
else
|
||||
respond_with(@garden_collaborator)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@garden_collaborator = GardenCollaborator.find(params[:id])
|
||||
authorize! :update, @garden_collaborator
|
||||
|
||||
@member = Member.find_by(slug: params[:garden_collaborator][:member_slug])
|
||||
|
||||
@garden_collaborator.member = @member
|
||||
@garden_collaborator.save
|
||||
|
||||
respond_with(@garden_collaborator)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@garden_collaborator = GardenCollaborator.find(params[:id])
|
||||
|
||||
authorize! :destroy, @garden_collaborator
|
||||
|
||||
if @garden_collaborator.destroy
|
||||
redirect_to garden_garden_collaborators_path(@garden)
|
||||
else
|
||||
respond_with(@garden_collaborator)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_garden
|
||||
@garden = Garden.find_by(slug: params[:garden_slug])
|
||||
end
|
||||
|
||||
def garden_collaborator_params
|
||||
params.require(:garden_collaborator).permit(
|
||||
:member_slug
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -8,10 +8,7 @@ class GardensController < DataController
|
||||
|
||||
@gardens = @gardens.includes(:owner)
|
||||
@gardens = @gardens.active unless @show_all
|
||||
if @owner.present?
|
||||
@gardens = @gardens.left_joins(:garden_collaborators)
|
||||
@gardens = @gardens.where(owner: @owner).or(@gardens.where(garden_collaborators: { member: @owner }))
|
||||
end
|
||||
@gardens = @gardens.where(owner: @owner) if @owner.present?
|
||||
@gardens = @gardens.where.not(members: { confirmed_at: nil })
|
||||
.order(:name).paginate(page: params[:page])
|
||||
respond_with(@gardens)
|
||||
@@ -19,7 +16,6 @@ class GardensController < DataController
|
||||
|
||||
def show
|
||||
@current_plantings = @garden.plantings.current.includes(:crop, :owner).order(planted_at: :desc)
|
||||
@current_activities = @garden.activities.current.includes(:owner).order(created_at: :desc)
|
||||
@finished_plantings = @garden.plantings.finished.includes(:crop)
|
||||
@suggested_companions = Crop.approved.where(
|
||||
id: CropCompanion.where(crop_a_id: @current_plantings.select(:crop_id)).select(:crop_b_id)
|
||||
|
||||
@@ -58,7 +58,7 @@ class LikesController < ApplicationController
|
||||
|
||||
def failed(like, message)
|
||||
respond_to do |format|
|
||||
format.json { render(json: { error: message }, status: :forbidden) }
|
||||
format.json { render(json: { 'error': message }, status: :forbidden) }
|
||||
format.html do
|
||||
flash[:error] = message
|
||||
if like&.likeable
|
||||
|
||||
@@ -61,7 +61,7 @@ class MembersController < ApplicationController
|
||||
end
|
||||
|
||||
def unsubscribe
|
||||
verifier = ActiveSupport::MessageVerifier.new(ENV.fetch('RAILS_SECRET_TOKEN', nil))
|
||||
verifier = ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN'])
|
||||
decrypted_message = verifier.verify(params[:message])
|
||||
|
||||
@member = Member.find(decrypted_message[:member_id])
|
||||
|
||||
@@ -21,7 +21,7 @@ class MessagesController < ApplicationController
|
||||
return if params[:recipient_id].blank?
|
||||
|
||||
@recipient = Member.find_by(id: params[:recipient_id])
|
||||
nil if @recipient.nil?
|
||||
return if @recipient.nil?
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -41,7 +41,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
if resource.tos_agreement
|
||||
super
|
||||
super resource
|
||||
else
|
||||
finish_signup_path(resource)
|
||||
end
|
||||
|
||||
@@ -63,7 +63,7 @@ class PhotosController < ApplicationController
|
||||
|
||||
def photo_params
|
||||
params.require(:photo).permit(:source_id, :source, :title, :license_name,
|
||||
:license_url, :thumbnail_url, :fullsize_url, :link_url, :date_taken)
|
||||
:license_url, :thumbnail_url, :fullsize_url, :link_url)
|
||||
end
|
||||
|
||||
# Item with photos attached
|
||||
|
||||
@@ -6,7 +6,7 @@ class PlantPartsController < ApplicationController
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@plant_parts = PlantPart.all.order(:name).paginate(page: params[:page], per_page: 100)
|
||||
@plant_parts = PlantPart.all.order(:name)
|
||||
respond_with(@plant_parts)
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
class PlantingsController < DataController
|
||||
after_action :update_crop_medians, only: %i(create update destroy)
|
||||
after_action :update_planting_medians, only: :update
|
||||
respond_to :ics, only: [:index] # TODO: This can be shifted up when all relevant controllers respond to ical
|
||||
|
||||
def index
|
||||
@show_all = params[:all] == '1'
|
||||
@@ -30,13 +29,13 @@ class PlantingsController < DataController
|
||||
)
|
||||
|
||||
@filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_fs(:number)}.csv"
|
||||
|
||||
respond_with(@plantings)
|
||||
end
|
||||
|
||||
def show
|
||||
@photos = @planting.photos.includes(:owner).order(date_taken: :desc)
|
||||
@harvests = Harvest.search(where: { planting_id: @planting.id })
|
||||
@current_activities = @planting.activities.current.includes(:owner).order(created_at: :desc)
|
||||
@matching_seeds = matching_seeds
|
||||
@crop = @planting.crop
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
class RegistrationsController < Devise::RegistrationsController
|
||||
respond_to :json
|
||||
|
||||
prepend_before_action :check_captcha, only: [:create] # Change this to be any actions you want to protect with recaptcha.
|
||||
|
||||
def edit
|
||||
@twitter_auth = current_member.auth('twitter')
|
||||
@flickr_auth = current_member.auth('flickr')
|
||||
@@ -48,25 +46,6 @@ class RegistrationsController < Devise::RegistrationsController
|
||||
render "edit"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sign_up_params
|
||||
params.require(:member).permit(:login_name, :email, :tos_agreement, :newsletter, :password, :password_confirmation)
|
||||
end
|
||||
|
||||
def check_captcha
|
||||
return if verify_recaptcha # verify_recaptcha(action: 'signup') for v3
|
||||
|
||||
self.resource = resource_class.new sign_up_params
|
||||
resource.validate # Look for any other validation errors besides reCAPTCHA
|
||||
set_minimum_password_length
|
||||
|
||||
respond_with_navigational(resource) do
|
||||
flash.discard(:recaptcha_error) # We need to discard flash to avoid showing it on the next page reload
|
||||
render :new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# check if we need the current password to update fields
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ScientificNamesController < ApplicationController
|
||||
before_action :authenticate_member!, except: %i(index show gbif_suggest)
|
||||
load_and_authorize_resource except: [:gbif_suggest]
|
||||
before_action :authenticate_member!, except: %i(index show)
|
||||
load_and_authorize_resource
|
||||
respond_to :html, :json
|
||||
responders :flash
|
||||
|
||||
# GET /scientific_names
|
||||
# GET /scientific_names.json
|
||||
def index
|
||||
@scientific_names = ScientificName.all.order(:name).paginate(page: params[:page], per_page: 100)
|
||||
@scientific_names = ScientificName.all.order(:name)
|
||||
respond_with(@scientific_names)
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ class ScientificNamesController < ApplicationController
|
||||
def create
|
||||
@scientific_name = ScientificName.new(scientific_name_params)
|
||||
@scientific_name.creator = current_member
|
||||
gbif_sync!(@scientific_name)
|
||||
|
||||
@scientific_name.save
|
||||
respond_with(@scientific_name.crop)
|
||||
end
|
||||
@@ -43,9 +43,7 @@ class ScientificNamesController < ApplicationController
|
||||
# PUT /scientific_names/1
|
||||
# PUT /scientific_names/1.json
|
||||
def update
|
||||
@scientific_name.assign_attributes(scientific_name_params)
|
||||
gbif_sync!(@scientific_name)
|
||||
@scientific_name.save
|
||||
@scientific_name.update(scientific_name_params)
|
||||
respond_with(@scientific_name.crop)
|
||||
end
|
||||
|
||||
@@ -58,26 +56,9 @@ class ScientificNamesController < ApplicationController
|
||||
respond_with(@crop)
|
||||
end
|
||||
|
||||
def gbif_suggest
|
||||
render json: gbif_service.suggest(params[:term])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def gbif_sync!(model)
|
||||
return unless model.gbif_key
|
||||
|
||||
result = gbif_service.fetch(model.gbif_key)
|
||||
|
||||
model.gbif_rank = result["rank"]
|
||||
model.gbif_status = result["status"]
|
||||
end
|
||||
|
||||
def scientific_name_params
|
||||
params.require(:scientific_name).permit(:crop_id, :name, :gbif_key)
|
||||
end
|
||||
|
||||
def gbif_service
|
||||
GbifService.new
|
||||
params.require(:scientific_name).permit(:crop_id, :name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ class SeedsController < DataController
|
||||
end
|
||||
|
||||
def show
|
||||
@photos = @seed.photos.includes(:owner).order(created_at: :desc, id: :desc).paginate(page: params[:page], per_page: 30)
|
||||
@photos = @seed.photos.includes(:owner).order(created_at: :desc).paginate(page: params[:page])
|
||||
respond_with(@seed)
|
||||
end
|
||||
|
||||
|
||||
@@ -28,11 +28,10 @@ module ApplicationHelper
|
||||
"#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}"
|
||||
end
|
||||
|
||||
# A helper to replace the complex template compilation mess
|
||||
# of HAML, Tilt, and dynamic compilation with interpolated ruby.
|
||||
def markdownify(text)
|
||||
translator = Haml::Filters::GrowstuffMarkdown.new
|
||||
translator.expand_members!(translator.expand_crops!(text.to_s))
|
||||
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'])
|
||||
end
|
||||
|
||||
#
|
||||
|
||||
@@ -13,7 +13,7 @@ module AutoSuggestHelper
|
||||
resource = resource.class.name.downcase
|
||||
source_path = Rails.application.routes.url_helpers.send("search_#{source}s_path", format: :json)
|
||||
%(
|
||||
<input id="#{source}" class="auto-suggest #{options[:class]}" #{options[:required] ? 'required="required"' : ''}
|
||||
<input id="#{source}" class="auto-suggest #{options[:class]}"
|
||||
type="text" value="#{default}" data-source-url="#{source_path}",
|
||||
placeholder="e.g. lettuce">
|
||||
<noscript class="text-warning">
|
||||
|
||||
@@ -18,30 +18,6 @@ module ButtonsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def garden_plan_something_button(garden, classes: "btn btn-default")
|
||||
return unless can? :edit, garden
|
||||
|
||||
link_to new_activity_path(garden_id: garden.id), class: classes do
|
||||
activity_icon + ' ' + t('buttons.new_activity')
|
||||
end
|
||||
end
|
||||
|
||||
def plan_something_button
|
||||
return unless can? :create, Activity
|
||||
|
||||
link_to new_activity_path, class: "btn btn-default" do
|
||||
activity_icon + ' ' + t('buttons.new_activity')
|
||||
end
|
||||
end
|
||||
|
||||
def planting_plan_something_button(planting, classes: "btn btn-default")
|
||||
return unless can? :edit, planting
|
||||
|
||||
link_to new_activity_path(planting_id: planting.id), class: classes do
|
||||
activity_icon + ' ' + t('buttons.new_activity')
|
||||
end
|
||||
end
|
||||
|
||||
def garden_mark_active_button(garden, classes: 'btn')
|
||||
link_to t('buttons.mark_as_active'),
|
||||
garden_path(garden, garden: { active: 1 }),
|
||||
@@ -83,19 +59,6 @@ module ButtonsHelper
|
||||
edit_button(edit_planting_path(planting), classes:)
|
||||
end
|
||||
|
||||
def activity_edit_button(activity, classes: "btn btn-raised btn-info")
|
||||
edit_button(edit_activity_path(activity), classes:)
|
||||
end
|
||||
|
||||
def activity_finish_button(activity, classes: 'btn btn-default btn-secondary')
|
||||
return unless can?(:edit, activity) || activity.finished
|
||||
|
||||
link_to activity_path(slug: activity.slug, activity: { finished: 1 }),
|
||||
method: :put, class: "#{classes} append-date" do
|
||||
finished_icon + ' ' + t('buttons.mark_as_finished')
|
||||
end
|
||||
end
|
||||
|
||||
def planting_finish_button(planting, classes: 'btn btn-default btn-secondary')
|
||||
return unless can?(:edit, planting) || planting.finished
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ module CropsHelper
|
||||
|
||||
return "You don't have any seeds of this crop." if seeds.none?
|
||||
|
||||
if total_quantity == 0
|
||||
"You have an unknown quantity of seeds of this crop."
|
||||
else
|
||||
if total_quantity != 0
|
||||
"You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop."
|
||||
else
|
||||
"You have an unknown quantity of seeds of this crop."
|
||||
end
|
||||
end
|
||||
|
||||
def crop_ebay_seeds_url(crop)
|
||||
"https://www.ebay.com/sch/i.html?_nkw=#{CGI.escape crop.name}"
|
||||
"https://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{CGI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,12 +11,10 @@ module GardensHelper
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: Not used?
|
||||
def display_garden_name(garden)
|
||||
truncate(garden.name, length: 50, separator: ' ', omission: '... ')
|
||||
end
|
||||
|
||||
# TODO: Only used by specs?
|
||||
def display_garden_plantings(plantings)
|
||||
if plantings.blank?
|
||||
"None"
|
||||
|
||||
@@ -71,10 +71,6 @@ module IconsHelper
|
||||
icon('fas', 'seedling')
|
||||
end
|
||||
|
||||
def activity_icon
|
||||
icon('fas', 'fa-truck-pickup')
|
||||
end
|
||||
|
||||
def post_icon
|
||||
image_icon 'post'
|
||||
end
|
||||
@@ -97,7 +93,7 @@ module IconsHelper
|
||||
|
||||
def plant_part_icon(name)
|
||||
if File.exist? Rails.root.join('app', 'assets', 'images', 'icons', 'plant_parts', "#{name}.svg")
|
||||
image_tag "icons/plant_parts/#{name}.svg", class: 'img img-icon', 'aria-hidden' => "true", alt: name
|
||||
image_tag "icons/plant_parts/#{name}.svg", class: 'img img-icon', 'aria-hidden' => "true"
|
||||
else
|
||||
planting_icon
|
||||
end
|
||||
@@ -105,7 +101,7 @@ module IconsHelper
|
||||
|
||||
def crop_icon(crop)
|
||||
if crop.svg_icon.present?
|
||||
image_tag(crop_path(crop, format: 'svg'), class: 'crop-icon', alt: crop)
|
||||
image_tag(crop_path(crop, format: 'svg'), class: 'crop-icon')
|
||||
elsif crop.parent.present?
|
||||
crop_icon(crop.parent)
|
||||
else
|
||||
@@ -127,6 +123,6 @@ module IconsHelper
|
||||
end
|
||||
|
||||
def image_icon(icon)
|
||||
image_tag "icons/#{icon}.svg", class: 'img img-icon', 'aria-hidden' => "true", alt: icon
|
||||
image_tag "icons/#{icon}.svg", class: 'img img-icon', 'aria-hidden' => "true"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PostsHelper
|
||||
def display_post_truncated(post, length: 300)
|
||||
truncate(strip_tags(post.body), length:,
|
||||
separator: ' ', omission: '... ') { link_to "Read more", post_path(post) }
|
||||
end
|
||||
|
||||
def post_stripped_tags(post, length: 300)
|
||||
truncate(strip_tags(markdownify(post.body)), length:)
|
||||
truncate(strip_tags(post.body), length:)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
class NotifierMailer < ApplicationMailer
|
||||
# include NotificationsHelper
|
||||
default from: "Growstuff <#{ENV.fetch('GROWSTUFF_EMAIL', nil)}>"
|
||||
default from: "Growstuff <#{ENV['GROWSTUFF_EMAIL']}>"
|
||||
|
||||
def verifier
|
||||
unless ENV['RAILS_SECRET_TOKEN']
|
||||
raise "RAILS_SECRET_TOKEN environment variable" \
|
||||
"not set - have you created config/application.yml?"
|
||||
raise "RAILS_SECRET_TOKEN environment variable"\
|
||||
"not set - have you created config/application.yml?"
|
||||
end
|
||||
|
||||
ActiveSupport::MessageVerifier.new(ENV.fetch('RAILS_SECRET_TOKEN', nil))
|
||||
ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN'])
|
||||
end
|
||||
|
||||
def notify(notification)
|
||||
@@ -27,7 +27,7 @@ class NotifierMailer < ApplicationMailer
|
||||
|
||||
def planting_reminder(member)
|
||||
@member = member
|
||||
@sitename = ENV.fetch('GROWSTUFF_SITE_NAME', nil)
|
||||
@sitename = ENV['GROWSTUFF_SITE_NAME']
|
||||
|
||||
@late = []
|
||||
@super_late = []
|
||||
|
||||
@@ -79,7 +79,6 @@ class Ability
|
||||
can :manage, ScientificName
|
||||
can :manage, AlternateName
|
||||
can :openfarm, Crop
|
||||
can :gbif, Crop
|
||||
end
|
||||
|
||||
# any member can create a crop provisionally
|
||||
@@ -108,38 +107,12 @@ class Ability
|
||||
can :create, Planting
|
||||
can :update, Planting, garden: { owner_id: member.id }, crop: { approval_status: 'approved' }
|
||||
can :destroy, Planting, garden: { owner_id: member.id }, crop: { approval_status: 'approved' }
|
||||
can :update, Planting do |planting|
|
||||
planting.garden.garden_collaborators.where(member_id: member.id).any?
|
||||
end
|
||||
can :destroy, Planting do |planting|
|
||||
planting.garden.garden_collaborators.where(member_id: member.id).any?
|
||||
end
|
||||
|
||||
can :create, GardenCollaborator, garden: { owner_id: member.id }
|
||||
can :update, GardenCollaborator, garden: { owner_id: member.id }
|
||||
can :destroy, GardenCollaborator, garden: { owner_id: member.id }
|
||||
|
||||
can :create, Activity
|
||||
can :update, Activity, owner_id: member.id
|
||||
can :destroy, Activity, owner_id: member.id
|
||||
can :update, Activity do |activity|
|
||||
activity.garden&.garden_collaborators&.where(member_id: member.id)&.any?
|
||||
end
|
||||
can :destroy, Activity do |activity|
|
||||
activity.garden&.garden_collaborators&.where(member_id: member.id)&.any?
|
||||
end
|
||||
|
||||
can :create, Harvest
|
||||
can :update, Harvest, owner_id: member.id
|
||||
can :destroy, Harvest, owner_id: member.id
|
||||
can :update, Harvest, owner_id: member.id, planting: { owner_id: member.id }
|
||||
can :destroy, Harvest, owner_id: member.id, planting: { owner_id: member.id }
|
||||
can :update, Harvest do |harvest|
|
||||
harvest.planting&.garden&.garden_collaborators&.where(member_id: member.id)&.any?
|
||||
end
|
||||
can :destroy, Harvest do |harvest|
|
||||
harvest.planting&.garden&.garden_collaborators&.where(member_id: member.id)&.any?
|
||||
end
|
||||
|
||||
can :create, Photo
|
||||
can :update, Photo, owner_id: member.id
|
||||
@@ -175,10 +148,5 @@ class Ability
|
||||
can :destroy, PlantPart do |pp|
|
||||
pp.harvests.empty?
|
||||
end
|
||||
# Admins can't delete themselves
|
||||
cannot :destroy, Member
|
||||
can :destroy, Member do |other_member|
|
||||
other_member&.id != member.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Activity < ApplicationRecord
|
||||
extend FriendlyId
|
||||
include Ownable
|
||||
include Finishable
|
||||
include SearchActivities
|
||||
include Likeable
|
||||
|
||||
belongs_to :garden, optional: true
|
||||
belongs_to :planting, optional: true
|
||||
|
||||
friendly_id :activity_slug, use: %i(slugged finders)
|
||||
|
||||
CATEGORIES = ["General", "Weeding", "Soil Cultivation", "Fertilizing", "Pruning", "Topical Application/Treating", "Watering"]
|
||||
|
||||
validates :name, presence: true
|
||||
validates :category, inclusion: { in: CATEGORIES }, presence: true
|
||||
validates :owner, presence: true
|
||||
|
||||
validates :slug, uniqueness: true
|
||||
|
||||
delegate :location, :latitude, :longitude, to: :owner
|
||||
delegate :login_name, :slug, :location, to: :owner, prefix: true
|
||||
|
||||
def activity_slug
|
||||
"#{owner.login_name}-#{name}-#{id}".downcase.tr(' ', '-')
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module GbifData
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
def update_gbif_data!
|
||||
GbifService.new.update_crop(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -9,8 +9,8 @@ module MemberFlickr
|
||||
if @flickr.nil?
|
||||
flickr_auth = auth('flickr')
|
||||
if flickr_auth
|
||||
FlickRaw.api_key = ENV.fetch('GROWSTUFF_FLICKR_KEY', nil)
|
||||
FlickRaw.shared_secret = ENV.fetch('GROWSTUFF_FLICKR_SECRET', nil)
|
||||
FlickRaw.api_key = ENV['GROWSTUFF_FLICKR_KEY']
|
||||
FlickRaw.shared_secret = ENV['GROWSTUFF_FLICKR_SECRET']
|
||||
@flickr = FlickRaw::Flickr.new
|
||||
@flickr.access_token = flickr_auth.token
|
||||
@flickr.access_secret = flickr_auth.secret
|
||||
|
||||
@@ -77,22 +77,9 @@ module PredictPlanting
|
||||
finish_predicted_at <= Time.zone.today
|
||||
end
|
||||
|
||||
# Deactivate any plantings over time_limit that are super late in small batches.
|
||||
def self.archive!(time_limit: 3.years.ago, limit: 1000)
|
||||
active_plantings = Planting.annual.active.where("planted_at < ?", time_limit).order(planted_at: :asc).limit(limit)
|
||||
active_plantings.each do |planting|
|
||||
if planting.finish_is_predicatable? && planting.super_late?
|
||||
planting.finished = true
|
||||
planting.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def calculate_percentage_grown
|
||||
return 0 if age_in_days < 0
|
||||
|
||||
percent = (age_in_days / expected_lifespan.to_f) * 100
|
||||
(percent > 100 ? 100 : percent)
|
||||
end
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SearchActivities
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
searchkick merge_mappings: true,
|
||||
settings: { number_of_shards: 1, number_of_replicas: 0 },
|
||||
mappings: {
|
||||
properties: {
|
||||
active: { type: :boolean },
|
||||
created_at: { type: :integer }
|
||||
}
|
||||
}
|
||||
|
||||
def search_data
|
||||
{
|
||||
slug:,
|
||||
active:,
|
||||
finished: finished?,
|
||||
name:,
|
||||
due_date:,
|
||||
category:,
|
||||
garden_id:,
|
||||
garden_name: garden&.name,
|
||||
planting_id:,
|
||||
planting_name: planting&.crop&.name,
|
||||
description:,
|
||||
|
||||
# owner
|
||||
owner_id:,
|
||||
owner_login_name:,
|
||||
owner_slug:,
|
||||
|
||||
# timestamps
|
||||
created_at: created_at.to_i,
|
||||
updated_at: updated_at.to_i
|
||||
}
|
||||
end
|
||||
|
||||
def self.homepage_records(limit)
|
||||
records = []
|
||||
owners = []
|
||||
1..limit.times do
|
||||
where = {
|
||||
# photos_count: { gt: 0 },
|
||||
owner_id: { not: owners }
|
||||
}
|
||||
one_record = search('*',
|
||||
limit: 1,
|
||||
where:,
|
||||
boost_by: [:created_at],
|
||||
load: false).first
|
||||
return records if one_record.nil?
|
||||
|
||||
owners << one_record.owner_id
|
||||
records << one_record
|
||||
end
|
||||
records
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -30,9 +30,6 @@ module SearchPlantings
|
||||
quantity:,
|
||||
sunniness:,
|
||||
garden_id:,
|
||||
garden_slug: garden&.garden_slug,
|
||||
garden_name: garden&.name,
|
||||
description:,
|
||||
|
||||
first_harvest_predicted_at:,
|
||||
finish_predicted_at:,
|
||||
@@ -56,8 +53,7 @@ module SearchPlantings
|
||||
harvests_count:,
|
||||
|
||||
# timestamps
|
||||
created_at: created_at.to_i,
|
||||
updated_at: updated_at.to_i
|
||||
created_at: created_at.to_i
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ class Crop < ApplicationRecord
|
||||
extend FriendlyId
|
||||
include PhotoCapable
|
||||
include OpenFarmData
|
||||
include GbifData
|
||||
include SearchCrops
|
||||
|
||||
friendly_id :name, use: %i(slugged finders)
|
||||
|
||||
@@ -59,7 +59,7 @@ class CsvImporter
|
||||
|
||||
alternate_names.split(/,\s*/).each do |name|
|
||||
altname = AlternateName.find_by(name:, crop: @crop)
|
||||
altname ||= AlternateName.create! name:, crop: @crop, creator: cropbot
|
||||
altname ||= AlternateName.create! name: name, crop: @crop, creator: cropbot
|
||||
@crop.alternate_names << altname
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class Follow < ApplicationRecord
|
||||
recipient_id: followed_id,
|
||||
sender_id: follower_id,
|
||||
subject: "#{follower.login_name} is now following you",
|
||||
body: "#{follower.login_name} just followed you on #{ENV.fetch('GROWSTUFF_SITE_NAME', nil)}. "
|
||||
body: "#{follower.login_name} just followed you on #{ENV['GROWSTUFF_SITE_NAME']}. "
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,8 +9,6 @@ class Garden < ApplicationRecord
|
||||
|
||||
has_many :plantings, dependent: :destroy
|
||||
has_many :crops, through: :plantings
|
||||
has_many :activities, dependent: :destroy
|
||||
has_many :garden_collaborators, dependent: :destroy
|
||||
|
||||
belongs_to :garden_type, optional: true
|
||||
|
||||
@@ -80,16 +78,6 @@ class Garden < ApplicationRecord
|
||||
|
||||
def reindex(refresh: false); end
|
||||
|
||||
# Deactivate any gardens with no active plantings
|
||||
def self.archive!(time_limit: 3.years.ago, limit: 1000)
|
||||
Garden.active.where("gardens.updated_at < ?", time_limit).order(updated_at: :asc).limit(limit).each do |active_garden|
|
||||
unless active_garden.plantings.active.any?
|
||||
active_garden.active = false
|
||||
active_garden.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def strip_blanks
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GardenCollaborator < ApplicationRecord
|
||||
belongs_to :member
|
||||
belongs_to :garden
|
||||
|
||||
validates :member_id, uniqueness: { scope: :garden }
|
||||
validate :not_garden_owner
|
||||
|
||||
def not_garden_owner
|
||||
return unless member
|
||||
return unless garden
|
||||
|
||||
errors.add(:member_id, "cannot be the garden owner") if garden.owner == member
|
||||
end
|
||||
|
||||
def member_slug
|
||||
@member&.slug
|
||||
end
|
||||
|
||||
def member_slug=(_slug)
|
||||
member_slug
|
||||
end
|
||||
end
|
||||
@@ -6,7 +6,6 @@ class Harvest < ApplicationRecord
|
||||
include PhotoCapable
|
||||
include Ownable
|
||||
include SearchHarvests
|
||||
include Likeable
|
||||
|
||||
friendly_id :harvest_slug, use: %i(slugged finders)
|
||||
|
||||
@@ -153,10 +152,7 @@ class Harvest < ApplicationRecord
|
||||
def owner_must_match_planting
|
||||
return if planting.blank? # only check if we are linked to a planting
|
||||
|
||||
return if owner == planting.owner || planting.garden.garden_collaborators.where(member_id: owner).any?
|
||||
|
||||
errors.add(:owner,
|
||||
"of harvest must be the same as planting, or a collaborator on that garden")
|
||||
errors.add(:owner, "of harvest must be the same as planting") unless owner == planting.owner
|
||||
end
|
||||
|
||||
def harvest_must_be_after_planting
|
||||
|
||||
@@ -19,7 +19,6 @@ class Member < ApplicationRecord
|
||||
has_many :plantings, foreign_key: 'owner_id', dependent: :destroy, inverse_of: :owner
|
||||
has_many :seeds, foreign_key: 'owner_id', dependent: :destroy, inverse_of: :owner
|
||||
has_many :harvests, foreign_key: 'owner_id', dependent: :destroy, inverse_of: :owner
|
||||
has_many :activities, foreign_key: 'owner_id', dependent: :destroy, inverse_of: :owner
|
||||
has_and_belongs_to_many :roles
|
||||
has_many :notifications, foreign_key: 'recipient_id', inverse_of: :recipient
|
||||
has_many :sent_notifications, foreign_key: 'sender_id', inverse_of: :sender, class_name: "Notification"
|
||||
|
||||
@@ -9,20 +9,15 @@ class Photo < ApplicationRecord
|
||||
|
||||
has_many :photo_associations, dependent: :delete_all, inverse_of: :photo
|
||||
|
||||
# This doesn't work, ActiveRecord tries to use the polymoriphic photographable
|
||||
# This doesn't work, ActiveRecord tries to use the polymoriphinc photographable
|
||||
# relationship instead.
|
||||
# has_many :crops, through: :photo_associations, counter_cache: true
|
||||
def crops
|
||||
Crop.distinct.joins(:photo_associations).where(photo_associations: { photo: self })
|
||||
end
|
||||
|
||||
validates :fullsize_url, url: true, presence: true
|
||||
validates :thumbnail_url, url: true, presence: true
|
||||
validates :link_url, url: true, presence: true
|
||||
validates :owner, presence: true
|
||||
validates :title, presence: true
|
||||
validates :license_name, presence: true # Should assert this is one of CC-BY, CC-BY-NC, etc
|
||||
validates :license_url, url: true, allow_blank: true
|
||||
validates :fullsize_url, url: true
|
||||
validates :thumbnail_url, url: true
|
||||
|
||||
# creates a relationship for each assignee type
|
||||
PHOTO_CAPABLE.each do |type|
|
||||
|
||||
@@ -8,7 +8,6 @@ class Planting < ApplicationRecord
|
||||
include PredictPlanting
|
||||
include PredictHarvest
|
||||
include SearchPlantings
|
||||
include Likeable
|
||||
|
||||
friendly_id :planting_slug, use: %i(slugged finders)
|
||||
|
||||
@@ -23,7 +22,6 @@ class Planting < ApplicationRecord
|
||||
belongs_to :garden
|
||||
belongs_to :crop, counter_cache: true
|
||||
has_many :harvests, dependent: :destroy
|
||||
has_many :activities, dependent: :destroy
|
||||
|
||||
#
|
||||
# Ancestry of food
|
||||
@@ -61,7 +59,6 @@ class Planting < ApplicationRecord
|
||||
to: :crop, prefix: true
|
||||
delegate :login_name, :slug, :location, to: :owner, prefix: true
|
||||
delegate :slug, to: :planting, prefix: true
|
||||
delegate :slug, :name, to: :garden, prefix: true
|
||||
|
||||
delegate :annual?, :perennial?, :svg_icon, to: :crop
|
||||
delegate :location, :longitude, :latitude, to: :garden
|
||||
@@ -128,9 +125,6 @@ class Planting < ApplicationRecord
|
||||
end
|
||||
|
||||
def owner_must_match_garden_owner
|
||||
return if owner == garden.owner || garden.garden_collaborators.where(member_id: owner).any?
|
||||
|
||||
errors.add(:owner,
|
||||
"must be the same as garden, or a collaborator on that garden")
|
||||
errors.add(:owner, "must be the same as garden") unless owner == garden.owner
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,11 +24,8 @@ class Post < ApplicationRecord
|
||||
#
|
||||
# Validations
|
||||
validates :subject, presence: true, length: { maximum: 255 }
|
||||
validates :body, presence: true
|
||||
|
||||
def author_date_subject
|
||||
return unless author
|
||||
|
||||
# slugs are created before created_at is set
|
||||
time = created_at || Time.zone.now
|
||||
"#{author.login_name} #{time.strftime('%Y%m%d')} #{subject}"
|
||||
|
||||
@@ -33,17 +33,17 @@ class Seed < ApplicationRecord
|
||||
validates :days_until_maturity_max, allow_nil: true,
|
||||
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
||||
validates :tradable_to, allow_blank: false,
|
||||
inclusion: { in: TRADABLE_TO_VALUES, message: "You may only trade seed nowhere, " \
|
||||
"locally, nationally, or internationally" }
|
||||
inclusion: { in: TRADABLE_TO_VALUES, message: "You may only trade seed nowhere, "\
|
||||
"locally, nationally, or internationally" }
|
||||
validates :organic, allow_blank: false,
|
||||
inclusion: { in: ORGANIC_VALUES, message: "You must say whether the seeds " \
|
||||
"are organic or not, or that you don't know" }
|
||||
inclusion: { in: ORGANIC_VALUES, message: "You must say whether the seeds "\
|
||||
"are organic or not, or that you don't know" }
|
||||
validates :gmo, allow_blank: false,
|
||||
inclusion: { in: GMO_VALUES, message: "You must say whether the seeds are " \
|
||||
"genetically modified or not, or that you don't know" }
|
||||
inclusion: { in: GMO_VALUES, message: "You must say whether the seeds are "\
|
||||
"genetically modified or not, or that you don't know" }
|
||||
validates :heirloom, allow_blank: false,
|
||||
inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds" \
|
||||
"are heirloom, hybrid, or unknown" }
|
||||
inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds"\
|
||||
"are heirloom, hybrid, or unknown" }
|
||||
|
||||
#
|
||||
# Delegations
|
||||
@@ -56,7 +56,7 @@ class Seed < ApplicationRecord
|
||||
default_scope { joins(:owner).merge(Member.kept) } # Ensure owner exists
|
||||
scope :tradable, -> { where.not(tradable_to: 'nowhere') }
|
||||
scope :interesting, -> { tradable.has_location }
|
||||
scope :has_location, -> { joins(:owner).where.not('members.location': nil) }
|
||||
scope :has_location, -> { joins(:owner).where.not("members.location": nil) }
|
||||
scope :recent, -> { order(created_at: :desc) }
|
||||
scope :active, -> { where('finished <> true').where('finished_at IS NULL OR finished_at < ?', Time.zone.now) }
|
||||
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'English'
|
||||
class GbifService
|
||||
def initialize
|
||||
@cropbot = Member.find_by(login_name: 'cropbot')
|
||||
@species = Gbif::Species
|
||||
end
|
||||
|
||||
def suggest(term)
|
||||
# Query the GBIF name autocomplete and discover the scientific name.
|
||||
# [
|
||||
# {
|
||||
# "key": 2932942,
|
||||
# "nameKey": 1970347,
|
||||
# "kingdom": "Plantae",
|
||||
# "phylum": "Tracheophyta",
|
||||
# "order": "Solanales",
|
||||
# "family": "Solanaceae",
|
||||
# "genus": "Capsicum",
|
||||
# "species": "Capsicum chinense",
|
||||
# "kingdomKey": 6,
|
||||
# "phylumKey": 7707728,
|
||||
# "classKey": 220,
|
||||
# "orderKey": 1176,
|
||||
# "familyKey": 7717,
|
||||
# "genusKey": 2932937,
|
||||
# "speciesKey": 2932942,
|
||||
# "parent": "Capsicum",
|
||||
# "parentKey": 2932937,
|
||||
# "nubKey": 2932942,
|
||||
# "scientificName": "Capsicum chinense Jacq.",
|
||||
# "canonicalName": "Capsicum chinense",
|
||||
# "rank": "SPECIES",
|
||||
# "status": "ACCEPTED",
|
||||
# "synonym": false,
|
||||
# "higherClassificationMap": {
|
||||
# "6": "Plantae",
|
||||
# "220": "Magnoliopsida",
|
||||
# "1176": "Solanales",
|
||||
# "7717": "Solanaceae",
|
||||
# "2932937": "Capsicum",
|
||||
# "7707728": "Tracheophyta"
|
||||
# },
|
||||
# "class": "Magnoliopsida"
|
||||
# },
|
||||
# {
|
||||
# "key": 12079498,
|
||||
# "nameKey": 81778754,
|
||||
# "kingdom": "Plantae",
|
||||
# "phylum": "Tracheophyta",
|
||||
# "order": "Solanales",
|
||||
# "family": "Solanaceae",
|
||||
# "genus": "Capsicum",
|
||||
# "species": "Capsicum chinense",
|
||||
# "kingdomKey": 6,
|
||||
# "phylumKey": 7707728,
|
||||
# "classKey": 220,
|
||||
# "orderKey": 1176,
|
||||
# "familyKey": 7717,
|
||||
# "genusKey": 2932937,
|
||||
# "speciesKey": 2932942,
|
||||
# "parent": "Capsicum",
|
||||
# "parentKey": 2932937,
|
||||
# "nubKey": 12079498,
|
||||
# "scientificName": "Capsicum annuum var. chinense (Jacq.) Alef.",
|
||||
# "canonicalName": "Capsicum annuum chinense",
|
||||
# "rank": "VARIETY",
|
||||
# "status": "SYNONYM",
|
||||
# "synonym": true,
|
||||
# "higherClassificationMap": {
|
||||
# "6": "Plantae",
|
||||
# "220": "Magnoliopsida",
|
||||
# "1176": "Solanales",
|
||||
# "7717": "Solanaceae",
|
||||
# "2932937": "Capsicum",
|
||||
# "2932942": "Capsicum chinense",
|
||||
# "7707728": "Tracheophyta"
|
||||
# },
|
||||
# "class": "Magnoliopsida"
|
||||
# }
|
||||
# ]
|
||||
|
||||
@species.name_suggest(q: term)
|
||||
end
|
||||
|
||||
def import!
|
||||
Crop.order(updated_at: :desc).each do |crop|
|
||||
Rails.logger.debug { "#{crop.id}, #{crop.name}" }
|
||||
update_crop(crop) if crop.valid?
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
Rails.logger.error($ERROR_INFO.message)
|
||||
end
|
||||
end
|
||||
|
||||
def update_crop(crop)
|
||||
# Attempt to resolve the scientific names via /species/match.
|
||||
gbif_usage_key = crop.scientific_names.detect { |sn| sn.gbif_key.present? }&.gbif_key
|
||||
unless gbif_usage_key
|
||||
crop.scientific_names.each do |sn|
|
||||
result = @species.name_backbone(name: sn.name) # , higherTaxonKey: 6, nameType: 'SCIENTIFIC')
|
||||
next unless result["confidence"] > 95 && result["matchType"] == "EXACT"
|
||||
|
||||
sn.gbif_key = result["usageKey"]
|
||||
sn.gbif_rank = result["rank"]
|
||||
sn.gbif_status = result["status"]
|
||||
sn.save!
|
||||
end
|
||||
|
||||
gbif_usage_key = crop.scientific_names.detect { |sn| sn.gbif_key.present? }&.gbif_key
|
||||
end
|
||||
|
||||
# No match? Fall back to common names
|
||||
unless gbif_usage_key
|
||||
query_results = @species.name_lookup(q: crop.name, higherTaxonKey: 6)
|
||||
|
||||
# We only want one result, otherwise it needs human.
|
||||
return unless query_results["results"].length == 1
|
||||
|
||||
query_result = query_results["results"].first
|
||||
|
||||
gbif_usage_key = query_result["key"]
|
||||
|
||||
crop.scientific_names.create!(gbif_key: gbif_usage_key, name: query_result["canonicalName"], creator: @cropbot)
|
||||
end
|
||||
|
||||
gbif_record = fetch(gbif_usage_key)
|
||||
if gbif_record.present?
|
||||
# crop.update! openfarm_data: gbif_record.fetch('data', false)
|
||||
# save_companions(crop, gbif_record)
|
||||
save_photos(crop, gbif_usage_key)
|
||||
else
|
||||
Rails.logger.debug "\tcrop not found on GBIF"
|
||||
# crop.update!(openfarm_data: false)
|
||||
end
|
||||
end
|
||||
|
||||
def save_photos(crop, key)
|
||||
# https://api.gbif.org/v1/occurrence/search?taxon_key=3084850
|
||||
|
||||
occurrences = Gbif::Occurrences.search(taxonKey: key, mediatype: 'StillImage', limit: 3, hasCoordinate: true)
|
||||
occurrences["results"].each do |result|
|
||||
next unless result["media"]
|
||||
|
||||
media = result["media"].first
|
||||
next unless media["identifier"]
|
||||
|
||||
# Example: "https://inaturalist-open-data.s3.amazonaws.com/photos/250226497/original.jpg"
|
||||
url = media["identifier"]
|
||||
md5 = Digest::MD5.hexdigest(url)
|
||||
width = 200
|
||||
thumbnail = "https://api.gbif.org/v1/image/cache/#{width}x/occurrence/#{result['key']}/media/#{md5}"
|
||||
|
||||
next unless url.start_with? 'http'
|
||||
next if Photo.find_by(source_id: result["key"], source: 'gbif')
|
||||
next if media["references"].blank?
|
||||
|
||||
photo = Photo.new(
|
||||
# This is for the overall observation which may technically have multiple media. However, we're only taking the first.
|
||||
source_id: result["key"],
|
||||
source: 'gbif',
|
||||
owner: @cropbot,
|
||||
thumbnail_url: thumbnail,
|
||||
fullsize_url: url,
|
||||
title: "Photo by #{media['creator']} via #{media['publisher']} (Copyright #{media['rightsHolder']})",
|
||||
license_name: case media["license"]
|
||||
when "http://creativecommons.org/licenses/by/4.0/"
|
||||
"CC BY 4.0"
|
||||
when "http://creativecommons.org/licenses/by-nc/4.0/"
|
||||
"CC BY-NC 4.0"
|
||||
else
|
||||
media["license"]
|
||||
end,
|
||||
license_url: media["license"],
|
||||
link_url: media["references"]
|
||||
)
|
||||
photo.date_taken = DateTime.parse(media["created"]) if media["created"]
|
||||
if photo.valid?
|
||||
Photo.transaction do
|
||||
photo.save
|
||||
PhotoAssociation.find_or_create_by! photo:, photographable: crop
|
||||
end
|
||||
Rails.logger.debug { "\t saved photo #{photo.id} #{photo.source_id}" }
|
||||
else
|
||||
Rails.logger.warn "Photo not valid"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def fetch(key)
|
||||
Gbif::Request.new("species/#{key}", nil, nil, nil).perform
|
||||
end
|
||||
end
|
||||
@@ -17,21 +17,10 @@ class TimelineService
|
||||
.union_all(comments_query)
|
||||
.union_all(photos_query)
|
||||
.union_all(seeds_query)
|
||||
.union_all(activities_query)
|
||||
.where.not(event_at: nil)
|
||||
.order(event_at: :desc)
|
||||
end
|
||||
|
||||
def self.activities_query
|
||||
Activity.select(
|
||||
:id,
|
||||
"'activity' as event_type",
|
||||
'COALESCE(activities.due_date, activities.created_at) as event_at',
|
||||
:owner_id,
|
||||
'null as crop_id'
|
||||
)
|
||||
end
|
||||
|
||||
def self.plantings_query
|
||||
Planting.select(
|
||||
:id,
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
- if can?(:edit, activity)
|
||||
%span.dropdown.activity-actions
|
||||
%a#activity-actions-button.btn.btn-info.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", type: "button", href: '#'} Actions
|
||||
.dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"}
|
||||
= activity_edit_button(activity, classes: 'dropdown-item')
|
||||
- if activity.active
|
||||
= activity_finish_button(activity, classes: 'dropdown-item')
|
||||
.dropdown-divider
|
||||
= delete_button(activity, classes: 'dropdown-item text-danger')
|
||||
@@ -1,35 +0,0 @@
|
||||
- cache activity do
|
||||
.card.activity{class: activity.active ? '' : 'card-finished'}
|
||||
= link_to activity_path(slug: activity.slug) do
|
||||
-# = image_tag activity.thumbnail_url ? activity.thumbnail_url : placeholder_image, class: 'img-card', alt: planting.crop_name
|
||||
|
||||
- if member_signed_in? && current_member.id == activity.owner_id
|
||||
= link_to activity_path(slug: activity.slug) do
|
||||
.activity-quick-actions
|
||||
.dropdown
|
||||
%a.activity-menu.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", type: "button", href: '#'}
|
||||
|
||||
.dropdown-menu{"aria-labelledby" => "activity-menu"}
|
||||
= link_to edit_activity_path(slug: activity.slug), class: 'dropdown-item' do
|
||||
= edit_icon
|
||||
= t('buttons.edit')
|
||||
|
||||
- if activity.active
|
||||
= activity_finish_button(activity, classes: 'dropdown-item')
|
||||
|
||||
- if can? :destroy, activity
|
||||
.dropdown-divider
|
||||
= delete_button(activity, classes: 'dropdown-item text-danger')
|
||||
= link_to activity_path(slug: activity.slug) do
|
||||
.card-body.text-center
|
||||
%h4= activity.name
|
||||
.text-center= activity.description
|
||||
- if activity.garden
|
||||
.text-center= activity.garden
|
||||
- if activity.planting
|
||||
.text-center= activity.planting
|
||||
.card-footer
|
||||
.float-right
|
||||
%span.chip.member-chip
|
||||
= link_to member_path(slug: activity.owner_slug) do
|
||||
= activity.owner_login_name
|
||||
@@ -1,7 +0,0 @@
|
||||
#{link_to event_model.category, event_model} - #{event_model.name}
|
||||
|
||||
- if event_model.planting
|
||||
%span on #{link_to event_model.planting, event_model.planting}
|
||||
|
||||
- if event_model.garden
|
||||
%span in #{link_to event_model.garden, event_model.garden}
|
||||
@@ -1,54 +0,0 @@
|
||||
.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2
|
||||
.card-header
|
||||
- if content_for? :title
|
||||
%h1.h2-responsive.text-center
|
||||
= planting_icon
|
||||
%strong=yield :title
|
||||
= bootstrap_form_for(@activity) do |f|
|
||||
.card-body
|
||||
- if @activity.errors.any?
|
||||
#error_explanation
|
||||
%h2
|
||||
= pluralize(@activity.errors.size, "error")
|
||||
prohibited this activity from being saved:
|
||||
%ul
|
||||
- @activity.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
= f.text_field :name, required: true, label: 'What needs to be done?'
|
||||
.row
|
||||
.col-md-4
|
||||
= f.select(:category, Activity::CATEGORIES, include_blank: true)
|
||||
.row
|
||||
.col-md-12
|
||||
= f.text_area :description, rows: 6, label: 'Tell us more about it'
|
||||
|
||||
.row
|
||||
.col-md-4
|
||||
= f.collection_radio_buttons(:garden_id, @activity.owner.gardens.active,
|
||||
:id, :name,
|
||||
label: 'Is this for a specific garden?')
|
||||
= link_to "Add a garden.", new_garden_path
|
||||
|
||||
.col-md-4
|
||||
= f.collection_radio_buttons(:planting_id, @activity.owner.plantings.active,
|
||||
:id, :crop_name,
|
||||
label: 'Is this for a specific planting?')
|
||||
= link_to "Add a planting.", new_planting_path
|
||||
|
||||
.col-md-4
|
||||
= f.date_field :due_date,
|
||||
value: @activity.due_date ? @activity.due_date.to_fs(:ymd) : '',
|
||||
label: 'When?'
|
||||
|
||||
%hr
|
||||
|
||||
.row
|
||||
.col-md-6
|
||||
= f.check_box :finished, label: 'Mark as finished'
|
||||
%span.help-block= t('.finish_helper')
|
||||
|
||||
.card-footer
|
||||
.text-right= f.submit 'Save'
|
||||
@@ -1,20 +0,0 @@
|
||||
.card
|
||||
.card-body
|
||||
.row
|
||||
.col
|
||||
%h4
|
||||
Planned by
|
||||
= link_to @activity.owner, @activity.owner
|
||||
= link_to "view all #{@activity.owner}'s activities", member_activities_path(@activity.owner)
|
||||
|
||||
- if @activity.garden
|
||||
%p
|
||||
Planned in
|
||||
= link_to @activity.garden, @activity.garden
|
||||
|
||||
- if @activity.planting
|
||||
%p
|
||||
Planned for
|
||||
= link_to @activity.planting, @activity.planting
|
||||
|
||||
.col= render "members/avatar", member: @activity.owner
|
||||
@@ -1,3 +0,0 @@
|
||||
= content_for :title, "Editing activity"
|
||||
|
||||
= render 'form'
|
||||
@@ -1,47 +0,0 @@
|
||||
csv.headers :id,
|
||||
:growstuff_url,
|
||||
:name,
|
||||
:category,
|
||||
:description,
|
||||
:owner_id,
|
||||
:owner_name,
|
||||
:garden_id,
|
||||
:garden_name,
|
||||
:planting_id,
|
||||
:planting_name,
|
||||
:due_date,
|
||||
:finished,
|
||||
:date_added,
|
||||
:last_modified,
|
||||
:license
|
||||
|
||||
@activities.each do |a|
|
||||
csv.row a do |csv, activity|
|
||||
|
||||
csv.cell :id
|
||||
csv.cell :growstuff_url, activity_url(a.slug)
|
||||
|
||||
csv.cell :name, a.description
|
||||
csv.cell :category, a.description
|
||||
csv.cell :description, a.description
|
||||
|
||||
csv.cell :owner_id, a.owner_id
|
||||
csv.cell :owner_name, a.owner_login_name
|
||||
|
||||
csv.cell :garden_id, a.garden_id
|
||||
csv.cell :garden_name, a.garden_name
|
||||
|
||||
csv.cell :planting_id, a.planting_id
|
||||
csv.cell :planting_name, a.planting_name
|
||||
|
||||
csv.cell :due_date, a.due_date ? a.due_date : ''
|
||||
|
||||
csv.cell :finished
|
||||
|
||||
csv.cell :date_added, Time.at(a.created_at).to_fs(:db)
|
||||
csv.cell :last_modified, Time.at(a.updated_at).to_fs(:db)
|
||||
|
||||
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,43 +0,0 @@
|
||||
- content_for :title, title('activities', @owner, nil, @planting)
|
||||
|
||||
- content_for :breadcrumbs do
|
||||
- if @owner
|
||||
%li.breadcrumb-item= link_to 'Activities', activities_path
|
||||
%li.breadcrumb-item.active= link_to "#{@owner}'s activities", activities_path(owner: @owner)
|
||||
- else
|
||||
%li.breadcrumb-item.active= link_to 'Activities', activities_path
|
||||
|
||||
.row
|
||||
.col-md-2
|
||||
%h1
|
||||
= activity_icon
|
||||
= title('activities', @owner, nil, @planting)
|
||||
= render 'layouts/nav', model: Activity
|
||||
= link_to show_inactive_tickbox_path('activities', owner: @owner, crop: nil, show_all: @show_all) do
|
||||
= check_box_tag 'active', 'all', @show_all
|
||||
include finished activities
|
||||
%hr
|
||||
- if @owner.present?
|
||||
= render @owner, cached: true
|
||||
|
||||
%section.open-data
|
||||
%h2 Open Data
|
||||
%p= t('label.data')
|
||||
- ['csv', 'json', 'rss'].each do |format|
|
||||
.badge.badge-info
|
||||
= link_to (@owner ? member_activities_path(@owner, format: format) : activities_path(format: format)) do
|
||||
= icon 'fas', format.to_s
|
||||
= format.upcase
|
||||
- if @owner
|
||||
.badge.badge-info= link_to "iCal", member_activities_path(@owner, format: 'ics', protocol: 'webcal', only_path: false)
|
||||
.badge.badge-success= link_to 'API Methods', '/api-docs'
|
||||
|
||||
.col-md-10
|
||||
|
||||
%section
|
||||
%h2= title('activities', @owner, nil, @planting)
|
||||
= will_paginate @activities
|
||||
.index-cards
|
||||
- @activities.each do |a|
|
||||
= render 'activities/card', activity: a
|
||||
= will_paginate @activities
|
||||
@@ -1,37 +0,0 @@
|
||||
<%
|
||||
# TODO Refactor to a Activity <-> Ical view class?
|
||||
cal = Icalendar::Calendar.new
|
||||
cal.description = "Activities by #{@owner.login_name}"
|
||||
@activities.each do |activity|
|
||||
|
||||
event = Icalendar::Event.new
|
||||
|
||||
lines = []
|
||||
lines << "Garden: #{activity['garden_name'] ? activity['garden_name'] : 'N/A' }"
|
||||
lines << "Planting: #{activity['planting_name'] ? activity['planting_name'] : 'N/A' }"
|
||||
|
||||
lines << activity.description
|
||||
finish_date = Date.parse(activity['due_date']) rescue nil
|
||||
|
||||
event.dtstart = Time.at(activity['created_at'])
|
||||
event.dtend = finish_date || 1.day.from_now
|
||||
event.summary = "#{activity['name']} - #{activity['category']}"
|
||||
event.description = lines.join("\n")
|
||||
event.ip_class = "PUBLIC"
|
||||
event.url = activity_url(slug: activity['slug'])
|
||||
|
||||
cal.add_event(event)
|
||||
|
||||
if finish_date && finish_date > Date.today
|
||||
todo = Icalendar::Todo.new
|
||||
todo.dtstart = finish_date || Date.today
|
||||
todo.due = finish_date
|
||||
todo.summary = "#{activity['name']} - #{activity['category']}"
|
||||
todo.description = lines.join("\n")
|
||||
|
||||
cal.add_todo(todo)
|
||||
end
|
||||
end
|
||||
cal.publish
|
||||
%>
|
||||
<%= cal.to_ical %>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{ version: 2.0 }
|
||||
%channel
|
||||
%title
|
||||
Recent activities from #{@owner ? @owner : 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})
|
||||
%link= activities_url
|
||||
- @activities.each do |activity|
|
||||
%item
|
||||
%title #{activity['name']}
|
||||
%pubdate= activity['created_at'].to_fs(:rfc822)
|
||||
%description
|
||||
:escaped
|
||||
<p>Category: #{activity['category']}</p>
|
||||
<p>Due Date: #{activity['due_date'] ? activity['due_date'] : 'unknown' }</p>
|
||||
<p>Garden: #{activity['garden_name'] ? activity['garden_name'] : 'N/A' }</p>
|
||||
<p>Planting: #{activity['planting_name'] ? activity['planting_name'] : 'N/A' }</p>
|
||||
:escaped_markdown
|
||||
#{ strip_tags markdownify(activity['description']) }
|
||||
%link= activity_url(slug: activity['slug'])
|
||||
%guid= activity_url(slug: activity['slug'])
|
||||
@@ -1,3 +0,0 @@
|
||||
= content_for :title, t('activities.plan_something')
|
||||
|
||||
= render 'form'
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user