Compare commits

...

67 Commits

Author SHA1 Message Date
Brenda Wallace
76db8177d0 Only build the dev and mainline branches 2020-08-17 11:24:57 +12:00
Brenda Wallace
6735fa7535 REduce parallel jobs on travis to 3 2020-08-17 11:23:11 +12:00
Brenda Wallace
e92600a07e Run bin/setup on travis 2020-08-17 10:53:07 +12:00
Brenda Wallace
dba9a7b2b5 Read variables from .env when checking for elastic 2020-08-17 10:45:33 +12:00
Brenda Wallace
8c69652f4e Updating setup to read database.yaml and .env, and check for elastic 2020-08-17 10:44:55 +12:00
Brenda Wallace
70e9c029d7 Set up database config for parallel tests 2020-08-17 10:29:18 +12:00
Brenda Wallace
08c1a4e80d fix travis parallel config 2020-08-16 20:30:49 +12:00
Brenda Wallace
1ed8befb64 Merge branch 'upgrade/rails-6' into feature/parallel-tests 2020-08-16 20:29:37 +12:00
Brenda Wallace
0ba32ab15e Configure contributor check for github actions 2020-08-16 20:27:55 +12:00
Brenda Wallace
42ce0d2b9b Configure contributor check for github actions 2020-08-16 20:27:17 +12:00
Brenda Wallace
8eb101138d Setting user name and email in github actions 2020-08-16 16:41:16 +12:00
Brenda
d2aa8d2e9b gem updates 2020-08-16 16:36:33 +12:00
Brenda Wallace
7450dc43e2 Install bundler depencdencies 2020-08-16 16:33:00 +12:00
Brenda Wallace
0ec892171c Merge branch 'upgrade/rails-6' into feature/parallel-tests 2020-08-16 16:32:21 +12:00
Brenda Wallace
74c7b79eaa check out repo 2020-08-16 16:32:03 +12:00
Brenda Wallace
a8daccc621 Run tests in parallell 2020-08-16 15:52:27 +12:00
Brenda Wallace
9490960063 removing last mention of cloudmade
this company used to produce the leaflet widget, but that staff member moved elsewhere in like 2012 and took the code with them and made it open source. the credit is no longer needed
2020-08-16 15:40:01 +12:00
Brenda Wallace
e7980631d6 Help view spec find the correct template 2020-08-16 15:33:53 +12:00
Brenda Wallace
9d78dd603c only run static checks on github 2020-08-15 15:06:33 +12:00
Brenda Wallace
224e17352f Adding ru files to codeclimate 2020-08-15 15:05:02 +12:00
Brenda Wallace
9f1671cbc5 Explaning why brakeman is off 2020-08-15 15:04:41 +12:00
Brenda Wallace
503b54da1f Removing dependabot config 2020-08-15 15:03:31 +12:00
Brenda Wallace
8aa7fdda2d Renaming notifier to new rails 6 style 2020-08-15 15:02:23 +12:00
Brenda Wallace
ba86a480bb Removed cloudmade test 2020-08-15 15:00:04 +12:00
Brenda Wallace
45780ac3f0 Comment out a migration that needs an old gem to work 2020-08-15 13:32:11 +12:00
Brenda Wallace
e4942a6646 Upgrade to activemedian 0.2.0 2020-08-15 13:26:49 +12:00
Brenda Wallace
f77ab839ff Run github actions on push, pull request 2020-08-15 10:52:59 +12:00
Brenda Wallace
b63c9ca7eb Removed extra steps on travis 2020-08-15 10:51:45 +12:00
Brenda Wallace
d68acafd41 seperate steps on travis 2020-08-15 10:49:35 +12:00
Brenda Wallace
80e2487b1b Remove extra env variable 2020-08-15 10:43:33 +12:00
Brenda Wallace
26a3d6968c Update name from Notifier to NotifierMailer 2020-08-15 10:17:31 +12:00
Brenda Wallace
84717a7937 Prepare database in travis run 2020-08-15 10:15:47 +12:00
Brenda Wallace
3c4ecef985 Removed contributor check from travis 2020-08-15 10:14:41 +12:00
Brenda Wallace
a59db8c090 Adding contributor check to github actions 2020-08-15 09:48:42 +12:00
Brenda Wallace
757394ddd9 Updating content type in tests to include charset 2020-08-15 09:32:35 +12:00
Brenda Wallace
037dd8c548 Ensuring the postgresql media functions exist 2020-08-15 09:29:45 +12:00
Brenda Wallace
30fff768f2 Merge remote-tracking branch 'upstream/dev' into upgrade/rails-6 2020-08-15 09:27:48 +12:00
Brenda Wallace
a23b8f34f8 Adding github actions 2020-08-04 16:19:03 +12:00
Brenda Wallace
e6a01473fd ensure the activemedian methods are in the test db 2020-08-03 14:24:06 +12:00
Brenda Wallace
7b42d86921 Merge branch 'upgrade/rails-6' of github.com:Br3nda/growstuff into upgrade/rails-6 2020-08-02 14:46:00 +12:00
Brenda Wallace
a66187fe41 fixed ambiguous negative 2020-08-02 14:45:55 +12:00
Brenda Wallace
1e897ac671 Use member.kpt in auth 2020-08-02 14:45:45 +12:00
Brenda Wallace
989750ac47 Merge branch 'dev' into upgrade/rails-6 2020-08-02 14:24:13 +12:00
Brenda Wallace
61363305b5 Prefer ary[n..] over ary[n..-1]. 2020-08-02 13:57:20 +12:00
Brenda Wallace
4a8f76e21a removed redundant escaping 2020-08-02 13:56:16 +12:00
Brenda Wallace
2bddc15cb0 run travis-ci as test 2020-08-02 13:54:01 +12:00
Brenda Wallace
2cf449800c Add active median in test runner on travis-ci 2020-08-02 13:53:22 +12:00
Brenda Wallace
30d1fd67ab Rename Notifer to NotifierMailer 2020-08-02 13:46:01 +12:00
Brenda Wallace
aa2648784f Rubocop indentation fixes 2020-08-02 09:24:54 +12:00
Brenda Wallace
282e76b599 Apply suggestions from code review 2020-08-02 09:22:13 +12:00
Brenda Wallace
31dc367298 Disabling brakeman on codeclimate because it doesn't understand rails 6 2020-08-02 09:18:28 +12:00
Brenda Wallace
ca3265841c Apply suggestions from code review 2020-08-02 09:16:46 +12:00
Brenda
99ae2da126 Splitting up complex method in photos controller 2020-08-02 09:12:33 +12:00
Brenda
df2aacd7ff Added missing unique constraint to garden_types 2020-08-02 09:03:47 +12:00
Brenda Wallace
d629e0d976 Rubocop target is rails 6.0 2020-08-02 08:56:13 +12:00
Brenda Wallace
bf9e3328eb Removing link to cloudmade
because they no longer exist and the domain is used by something else now
2020-08-02 08:50:39 +12:00
Brenda Wallace
40989aeefe Removing deprecated commented out parts of application.rb 2020-08-02 08:50:20 +12:00
Brenda
a11db6767b rewrote order by to not be raw sql 2020-08-02 08:43:17 +12:00
Brenda
fc72f0072c removed redundant assignment 2020-08-02 08:34:02 +12:00
Brenda Wallace
0e02ee749f Align end 2020-08-02 08:32:57 +12:00
Brenda
94e6576b36 foreign key declarations not needed anymore 2020-08-02 08:30:24 +12:00
Brenda Wallace
1bfd3851e8 Enable the new rubocop cops 2020-08-02 08:23:52 +12:00
Brenda Wallace
d590a4337d Merge branch 'feature/dotenv' into upgrade/rails-6 2020-08-02 08:21:11 +12:00
Brenda
d0455c25ab Rubocop fixes after rails 6 upgrades 2020-08-02 08:19:29 +12:00
Brenda Wallace
7c55ce628a New robocops 2020-08-02 08:18:44 +12:00
Brenda Wallace
95bc0a927c Upgrade to rails 6 2020-08-02 08:12:38 +12:00
Brenda Wallace
8eb8275493 Upgrade rails gem to 6 2020-08-01 20:33:51 +12:00
60 changed files with 431 additions and 274 deletions

View File

@@ -11,7 +11,7 @@ engines:
coffeelint:
enabled: true
brakeman:
enabled: true
enabled: false # codeclimate's brakeman is stuck in rails 5 rules
bundler-audit:
enabled: true
duplication:
@@ -23,6 +23,7 @@ engines:
ratings:
paths:
- "**.rb"
- "**.ru"
- "**.js"
- "**.coffee"
- "**.scss"

15
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: CI
on: [pull_request]
jobs:
contributors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install ruby version specified in .ruby-version
uses: ruby/setup-ruby@v1
- name: Check contributors
run: |
./script/check_contributors_md.rb

View File

@@ -4,7 +4,7 @@ AllCops:
Exclude:
- 'db/schema.rb'
- 'vendor/**/*'
TargetRailsVersion: 5.2
TargetRailsVersion: 6.0
Rails:
Enabled: true
@@ -60,3 +60,75 @@ Rails/SkipsModelValidations:
Exclude:
- 'db/migrate/20190317023129_finished_boolean.rb'
- 'db/seeds.rb'
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Lint/DeprecatedOpenSSLConstant:
Enabled: true
Lint/DuplicateElsifCondition:
Enabled: true
Lint/MixedRegexpCaptureTypes:
Enabled: true
Lint/RaiseException:
Enabled: true
Lint/StructNewOverride:
Enabled: true
Style/AccessorGrouping:
Enabled: true
Style/ArrayCoercion:
Enabled: true
Style/BisectedAttrAccessor:
Enabled: false
Style/CaseLikeIf:
Enabled: true
Style/ExponentialNotation:
Enabled: true
Style/HashAsLastArrayItem:
Enabled: true
Style/HashEachMethods:
Enabled: true
Style/HashLikeCase:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/RedundantAssignment:
Enabled: true
Style/RedundantFetchBlock:
Enabled: true
Style/RedundantFileExtensionInRequire:
Enabled: true
Style/RedundantRegexpCharacterClass:
Enabled: true
Style/RedundantRegexpEscape:
Enabled: true
Style/SlicingWithRange:
Enabled: true
Rails/ActiveRecordCallbacksOrder:
Enabled: true
Rails/FindById:
Enabled: true
Rails/Inquiry:
Enabled: true
Rails/MailerName:
Enabled: true
Rails/MatchRoute:
Enabled: true
Rails/NegateInclude:
Enabled: true
Rails/Pluck:
Enabled: true
Rails/PluckInWhere:
Enabled: true
Rails/RenderInline:
Enabled: true
Rails/RenderPlainText:
Enabled: true
Rails/ShortI18n:
Enabled: true
Rails/WhereExists:
Enabled: true

View File

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

View File

@@ -4,7 +4,7 @@ source 'https://rubygems.org'
ruby '2.6.5'
gem 'rails', '5.2.4.3'
gem 'rails', '6.0.3.2'
# Keeping old sprockets
# https://github.com/rails/sprockets-rails/issues/444#issuecomment-637817050
@@ -38,7 +38,7 @@ gem 'oj' # Speeds up json
# planting and harvest predictions
# based on median values for the crop
gem 'active_median', '0.1.4' # needs postgresql update https://github.com/Growstuff/growstuff/issues/1757
gem 'active_median', '0.2.0'
gem 'active_record_union'
gem 'flickraw'
@@ -112,7 +112,7 @@ gem 'rake', '>= 10.0.0'
gem "responders"
# allows soft delete. Used for members.
gem 'discard', '~> 1.0'
gem 'discard', '~> 1.2'
gem 'xmlrpc' # fixes rake error - can be removed if not needed later
@@ -155,6 +155,7 @@ group :development, :test do
gem 'faker'
gem 'haml-rails' # HTML templating language
gem 'query_diet'
gem 'parallel_tests'
gem 'rspec-activemodel-mocks'
gem 'rspec-rails' # unit testing framework
gem 'rswag-specs'

View File

@@ -3,57 +3,71 @@ GEM
remote: https://rails-assets.org/
specs:
abstract_type (0.0.7)
actioncable (5.2.4.3)
actionpack (= 5.2.4.3)
actioncable (6.0.3.2)
actionpack (= 6.0.3.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
actionmailbox (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
mail (>= 2.7.1)
actionmailer (6.0.3.2)
actionpack (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.4.3)
actionview (= 5.2.4.3)
activesupport (= 5.2.4.3)
actionpack (6.0.3.2)
actionview (= 6.0.3.2)
activesupport (= 6.0.3.2)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.4.3)
activesupport (= 5.2.4.3)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.2)
actionpack (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
nokogiri (>= 1.8.5)
actionview (6.0.3.2)
activesupport (= 6.0.3.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_link_to (1.0.5)
actionpack
addressable
active_median (0.1.4)
activerecord
active_median (0.2.0)
activerecord (>= 4.2)
active_record_union (1.3.0)
activerecord (>= 4.0)
active_utils (3.3.17)
activesupport (>= 4.2)
i18n
activejob (5.2.4.3)
activesupport (= 5.2.4.3)
activejob (6.0.3.2)
activesupport (= 6.0.3.2)
globalid (>= 0.3.6)
activemodel (5.2.4.3)
activesupport (= 5.2.4.3)
activerecord (5.2.4.3)
activemodel (= 5.2.4.3)
activesupport (= 5.2.4.3)
arel (>= 9.0)
activestorage (5.2.4.3)
actionpack (= 5.2.4.3)
activerecord (= 5.2.4.3)
activemodel (6.0.3.2)
activesupport (= 6.0.3.2)
activerecord (6.0.3.2)
activemodel (= 6.0.3.2)
activesupport (= 6.0.3.2)
activestorage (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
marcel (~> 0.3.1)
activesupport (5.2.4.3)
activesupport (6.0.3.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
@@ -63,11 +77,10 @@ GEM
abstract_type (~> 0.0.7)
adamantium (~> 0.2)
equalizer (~> 0.0.11)
arel (9.0.0)
ast (2.4.1)
autoprefixer-rails (9.7.6)
autoprefixer-rails (9.8.6.1)
execjs
bcrypt (3.1.13)
bcrypt (3.1.15)
better_errors (2.7.1)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
@@ -76,7 +89,7 @@ GEM
bonsai-elasticsearch-rails (7.0.1)
elasticsearch-model (< 8)
elasticsearch-rails (< 8)
bootstrap (4.5.0)
bootstrap (4.5.2)
autoprefixer-rails (>= 9.1.0)
popper_js (>= 1.14.3, < 2)
sassc-rails (>= 2.0.0)
@@ -140,16 +153,16 @@ GEM
concord (0.1.5)
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
concurrent-ruby (1.1.6)
concurrent-ruby (1.1.7)
connection_pool (2.2.3)
coveralls (0.8.19)
json (>= 1.8, < 3)
simplecov (~> 0.12.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
tins (~> 1.6)
coveralls (0.7.1)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
crass (1.0.6)
csv_shaper (1.3.1)
csv_shaper (1.3.2)
activesupport (>= 3.0.0)
dalli (2.7.10)
database_cleaner (1.8.5)
@@ -159,10 +172,12 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.3)
diff-lcs (1.4.4)
discard (1.2.0)
activerecord (>= 4.2, < 7)
docile (1.1.5)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
@@ -183,7 +198,7 @@ GEM
equalizer (0.0.11)
erubi (1.9.0)
erubis (2.7.0)
excon (0.73.0)
excon (0.76.0)
execjs (2.7.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
@@ -196,11 +211,11 @@ GEM
multipart-post (>= 1.2, < 3)
faraday_middleware (1.0.0)
faraday (~> 1.0)
ffi (1.13.0)
ffi (1.13.1)
flickraw (0.9.10)
font-awesome-sass (5.13.0)
sassc (>= 1.11)
friendly_id (5.3.0)
friendly_id (5.4.0)
activerecord (>= 4.0.0)
geocoder (1.6.3)
gibbon (1.2.1)
@@ -243,7 +258,10 @@ GEM
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
httparty (0.18.0)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
httparty (0.18.1)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.5)
@@ -271,7 +289,7 @@ GEM
js-routes (1.4.9)
railties (>= 4)
sprockets-rails
json (2.3.0)
json (2.3.1)
json-schema (2.8.1)
addressable (>= 2.4)
jsonapi-resources (0.10.2)
@@ -320,9 +338,10 @@ GEM
mini_portile2 (2.4.0)
minitest (5.14.1)
moneta (1.0.0)
multi_json (1.14.1)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
netrc (0.11.0)
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
@@ -353,6 +372,8 @@ GEM
rack
orm_adapter (0.5.0)
parallel (1.19.2)
parallel_tests (3.1.0)
parallel
parser (2.7.1.4)
ast (~> 2.4.1)
percy-capybara (4.0.2)
@@ -374,18 +395,20 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.4.3)
actioncable (= 5.2.4.3)
actionmailer (= 5.2.4.3)
actionpack (= 5.2.4.3)
actionview (= 5.2.4.3)
activejob (= 5.2.4.3)
activemodel (= 5.2.4.3)
activerecord (= 5.2.4.3)
activestorage (= 5.2.4.3)
activesupport (= 5.2.4.3)
rails (6.0.3.2)
actioncable (= 6.0.3.2)
actionmailbox (= 6.0.3.2)
actionmailer (= 6.0.3.2)
actionpack (= 6.0.3.2)
actiontext (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
activemodel (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
bundler (>= 1.3.0)
railties (= 5.2.4.3)
railties (= 6.0.3.2)
sprockets-rails (>= 2.0.0)
rails-assets-leaflet (1.5.1)
rails-assets-leaflet.markercluster (1.4.1)
@@ -399,20 +422,20 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-i18n (5.1.3)
rails-i18n (6.0.0)
i18n (>= 0.7, < 2)
railties (>= 5.0, < 6)
railties (>= 6.0.0, < 7)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (5.2.4.3)
actionpack (= 5.2.4.3)
activesupport (= 5.2.4.3)
railties (6.0.3.2)
actionpack (= 6.0.3.2)
activesupport (= 6.0.3.2)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
raindrops (0.19.1)
rake (13.0.1)
@@ -425,6 +448,11 @@ GEM
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
@@ -466,17 +494,17 @@ GEM
rswag-ui (2.3.1)
actionpack (>= 3.1, < 7.0)
railties (>= 3.1, < 7.0)
rubocop (0.88.0)
rubocop (0.89.1)
parallel (~> 1.10)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.1.0, < 1.0)
rubocop-ast (>= 0.3.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.2.0)
parser (>= 2.7.0.1)
rubocop-ast (0.3.0)
parser (>= 2.7.1.4)
rubocop-rails (2.7.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
@@ -514,12 +542,12 @@ GEM
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sexp_processor (4.14.1)
sexp_processor (4.15.0)
sidekiq (6.1.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
simplecov (0.12.0)
simplecov (0.13.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
@@ -538,7 +566,7 @@ GEM
tins (~> 1.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (0.19.4)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.1)
@@ -549,6 +577,9 @@ GEM
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (1.7.0)
unicorn (5.6.0)
kgio (~> 2.6)
@@ -575,7 +606,7 @@ GEM
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
websocket-driver (0.7.2)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
will_paginate (3.3.0)
@@ -584,12 +615,13 @@ GEM
xmlrpc (0.3.0)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.0)
PLATFORMS
ruby
DEPENDENCIES
active_median (= 0.1.4)
active_median (= 0.2.0)
active_record_union
active_utils
better_errors
@@ -614,7 +646,7 @@ DEPENDENCIES
dalli
database_cleaner
devise
discard (~> 1.0)
discard (~> 1.2)
dotenv-rails
elasticsearch (< 7.0.0)
factory_bot_rails
@@ -651,6 +683,7 @@ DEPENDENCIES
omniauth-facebook
omniauth-flickr (>= 0.0.15)
omniauth-twitter
parallel_tests
percy-capybara (~> 4.0.0)
pg (< 1.0.0)
platform-api
@@ -658,7 +691,7 @@ DEPENDENCIES
query_diet
rack-cors
rack-protection (>= 2.0.1)
rails (= 5.2.4.3)
rails (= 6.0.3.2)
rails-assets-leaflet.markercluster!
rails-controller-testing
rails_12factor

View File

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

View File

@@ -145,9 +145,9 @@ class CropsController < ApplicationController
def notifier
case @crop.approval_status
when "approved"
Notifier.crop_request_approved(@crop.requester, @crop)
NotifierMailer.crop_request_approved(@crop.requester, @crop)
when "rejected"
Notifier.crop_request_rejected(@crop.requester, @crop)
NotifierMailer.crop_request_rejected(@crop.requester, @crop)
end
end
@@ -164,7 +164,7 @@ class CropsController < ApplicationController
return if current_member.role? :crop_wrangler
Role.crop_wranglers&.each do |w|
Notifier.new_crop_request(w, @crop).deliver_now!
NotifierMailer.new_crop_request(w, @crop).deliver_now!
end
end

View File

@@ -2,6 +2,7 @@
class PhotosController < ApplicationController
before_action :authenticate_member!, except: %i(index show)
before_action :set_crop_and_planting, only: :index
after_action :expire_homepage, only: %i(create destroy)
load_and_authorize_resource
respond_to :html, :json
@@ -13,19 +14,10 @@ class PhotosController < ApplicationController
end
def index
where = {}
if params[:crop_slug]
@crop = Crop.find params[:crop_slug]
where = { crops: @crop.id }
elsif params[:planting_id]
@planting = Planting.find params[:planting_id]
where = { planting_id: @planting.id }
end
@photos = Photo.search(
load: false,
boost_by: [:created_at],
where: where,
where: index_where_clause,
page: params[:page],
limit: Photo.per_page
)
@@ -112,4 +104,19 @@ class PhotosController < ApplicationController
pager.replace photos
end
end
def index_where_clause
if params[:crop_slug]
{ crops: @crop.id }
elsif params[:planting_id]
{ planting_id: @planting.id }
else
{}
end
end
def set_crop_and_planting
@crop = Crop.find params[:crop_slug] if params[:crop_slug]
@planting = Planting.find params[:planting_id] if params[:planting_id]
end
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,6 @@
# frozen_string_literal: true
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
@@ -11,24 +10,31 @@ def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts "Install JavaScript dependencies"
system('bin/yarn')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Copying sample files =="
unless File.exist?('config/database.yml')
FileUtils.cp 'config/database.yml.example', 'config/database.yml'
end
unless File.exist?('.env')
FileUtils.cp 'env-example', '.env'
end
puts "\n== Checking for elastic search =="
system! 'script/check_elasticsearch.sh'
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ development:
test:
adapter: postgresql
database: growstuff_test
database: growstuff_test<%= ENV['TEST_ENV_NUMBER'] %>
production:
adapter: postgresql

View File

@@ -1,16 +1,10 @@
development:
adapter: postgresql
database: growstuff_dev
host: localhost
user: postgres
password: postgres
test:
adapter: postgresql
database: growstuff_test
host: localhost
user: postgres
password: postgres
database: growstuff_test<%= ENV['TEST_ENV_NUMBER'] %>
production:
adapter: postgresql

View File

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

View File

@@ -12,6 +12,8 @@
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
@@ -20,6 +22,9 @@
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,15 +2,15 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_12_26_051019) do
ActiveRecord::Schema.define(version: 2020_08_15_012538) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -225,6 +225,8 @@ ActiveRecord::Schema.define(version: 2019_12_26_051019) do
t.text "slug", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["name"], name: "index_garden_types_on_name", unique: true
t.index ["slug"], name: "index_garden_types_on_slug", unique: true
end
create_table "gardens", id: :serial, force: :cascade do |t|

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -66,7 +66,7 @@ describe CropsController do
it { is_expected.to be_successful }
it { is_expected.to render_template("crops/index") }
it { expect(response.content_type).to eq("application/rss+xml") }
it { expect(response.content_type).to eq("application/rss+xml; charset=utf-8") }
end
end
@@ -85,7 +85,7 @@ describe CropsController do
context 'wrangler' do
include_context 'login as wrangler'
it { expect { subject }.to change(Crop, :count).by -1 }
it { expect { subject }.to change(Crop, :count).by(-1) }
end
end
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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