Compare commits

..

106 Commits

Author SHA1 Message Date
Cesy
c08beb5291 Merge pull request #1495 from Growstuff/dev
Release 37
2017-12-22 09:54:32 +00:00
pozorvlak
269f3164b7 Merge pull request #1497 from Br3nda/feature/admin-nicer
Nicer admin interface
2017-12-18 11:33:02 +00:00
Shiny
9d47b2b029 Merge branch 'dev' into feature/admin-nicer 2017-12-18 15:10:36 +13:00
Daniel O'Connor
81e26aaf02 Merge pull request #1496 from Br3nda/feature/ordering
Feature/ordering
2017-12-18 09:30:51 +10:30
Shiny
d62322b498 Merge branch 'dev' into feature/admin-nicer 2017-12-18 06:59:33 +13:00
Shiny
ebb2f90294 Merge branch 'dev' into feature/ordering 2017-12-18 06:59:17 +13:00
Shiny
72922a160d Merge pull request #1498 from Growstuff/bundle-update-2017-12-18-000857
Bundle Update on 2017-12-18
2017-12-18 06:58:50 +13:00
deppbot
0699716c19 Bundle Update on 2017-12-18 2017-12-18 00:08:58 +08:00
Brenda Wallace
4c35987cb7 Ignore long method in ability.rb 2017-12-17 17:57:19 +13:00
Brenda Wallace
54e0806f38 don't check role is there's no member 2017-12-17 17:55:14 +13:00
Brenda Wallace
99828c7c01 Updated spec for new admin#index 2017-12-17 17:54:13 +13:00
Brenda Wallace
25d2773464 Use nested module/class definitions instead of compact style. 2017-12-17 17:50:30 +13:00
Brenda Wallace
233a30a045 Haml code style fix up 2017-12-17 17:49:05 +13:00
Brenda Wallace
01a7463ae8 Split up ability.rb into methods 2017-12-17 12:47:41 +13:00
Brenda Wallace
8a446ecbfc Member admin 2017-12-17 12:45:19 +13:00
Brenda Wallace
efc60e6313 Nicer layout on editing roles 2017-12-17 12:11:55 +13:00
Brenda Wallace
406b2dbf04 Make admin index a bit nicer 2017-12-17 12:06:03 +13:00
Brenda Wallace
ac056b4eb5 Merge remote-tracking branch 'upstream/dev' into dev 2017-12-17 12:05:42 +13:00
Brenda Wallace
2394f4d237 One view for showing photos on an item 2017-12-17 11:40:55 +13:00
Brenda Wallace
2a4fd57050 Merge remote-tracking branch 'upstream/dev' into feature/ordering 2017-12-17 10:18:25 +13:00
Shiny
5c885d675e Merge branch 'master' into dev 2017-12-17 10:05:25 +13:00
Shiny
0b08691160 Merge pull request #1474 from Br3nda/feature/photos-1457
Polymorphic relationship to photos
2017-12-17 10:04:30 +13:00
Brenda Wallace
b1052a2dbf Order posts by most recent 2017-12-17 10:01:51 +13:00
Brenda Wallace
95a923ff5f Order the plantings on the front page 2017-12-17 10:01:51 +13:00
deppbot
c8e34b640e Bundle Update on 2017-12-14 2017-12-17 10:01:51 +13:00
Brenda Wallace
6f2b4b13cd Only show photo pagination if there are photos 2017-12-17 09:55:52 +13:00
Brenda Wallace
970da53873 Merge remote-tracking branch 'origin/feature/photos-1457' into feature/photos-1457 2017-12-17 09:15:24 +13:00
Brenda Wallace
3aa2f0bd3b Paginate photos on seeds#show (inc feature specs) 2017-12-17 08:55:08 +13:00
Shiny
8c1514bc04 Merge branch 'dev' into feature/photos-1457 2017-12-15 17:13:12 +13:00
Daniel O'Connor
d2e39f58d5 Merge pull request #1494 from Br3nda/fix/ordering
More ordering fixes
2017-12-15 12:57:08 +10:30
Brenda Wallace
3d3a3b669e Order posts by most recent 2017-12-15 13:28:41 +13:00
Brenda Wallace
8697e56323 Order the plantings on the front page 2017-12-15 13:26:48 +13:00
Shiny
472b2eb192 Merge branch 'dev' into feature/photos-1457 2017-12-15 12:10:36 +13:00
Cesy
1698157d8d Merge pull request #1492 from Growstuff/bundle-update-2017-12-14-201051
Bundle Update on 2017-12-14
2017-12-14 12:25:49 +00:00
deppbot
ff652ae234 Bundle Update on 2017-12-14 2017-12-14 20:10:52 +08:00
Shiny
b4fcf004cd Merge pull request #1484 from Growstuff/dev
Release 36
2017-12-14 19:37:02 +13:00
Brenda Wallace
25e9ef892d Merge remote-tracking branch 'origin/feature/photos-1457' into feature/photos-1457 2017-12-14 08:45:40 +13:00
Shiny
82149d4565 Merge branch 'dev' into feature/photos-1457 2017-12-14 08:44:31 +13:00
Brenda Wallace
fcd3e36e36 Removed commented out code 2017-12-14 08:42:51 +13:00
pozorvlak
b783448ec3 Merge pull request #1485 from Br3nda/planting-harvests
Show photos of a planting's harvests
2017-12-13 12:08:23 +00:00
pozorvlak
e8b5850bfe Merge branch 'dev' into planting-harvests 2017-12-13 10:57:40 +00:00
pozorvlak
bca72680c4 Merge pull request #1490 from Br3nda/dependabot/npm_and_yarn/coffeelint-2.0.7
Bump coffeelint from 1.16.0 to 2.0.7
2017-12-13 10:57:18 +00:00
pozorvlak
358eb96684 Merge branch 'dev' into dependabot/npm_and_yarn/coffeelint-2.0.7 2017-12-13 10:29:18 +00:00
pozorvlak
05807d41f4 Merge pull request #1491 from Br3nda/flickr-auth-fix
Fix Growstuff::OauthSignupAction not found error when connecting flickr
2017-12-13 10:27:16 +00:00
Shiny
96f1995768 Merge branch 'dev' into dependabot/npm_and_yarn/coffeelint-2.0.7 2017-12-13 23:26:07 +13:00
Shiny
deefbbce71 Merge branch 'dev' into planting-harvests 2017-12-13 23:25:56 +13:00
Brenda Wallace
f8e51f4b45 Merge remote-tracking branch 'origin/feature/photos-1457' into feature/photos-1457 2017-12-13 22:35:29 +13:00
Brenda Wallace
1c8b75b7cb add and show photos for seeds
close #1457
2017-12-13 22:34:16 +13:00
Brenda Wallace
1f66df0743 Fixed link to associated flickr, twitter, facebook accountss
fixes #1479
2017-12-13 22:23:22 +13:00
Brenda Wallace
72f52230a1 Fix Growstuff::OauthSignupAction not found error when connecting flickr account 2017-12-13 22:19:41 +13:00
Shiny
700fba58e8 Merge branch 'dev' into feature/photos-1457 2017-12-13 21:52:55 +13:00
Daniel O'Connor
acecbe93c1 Merge pull request #1487 from Growstuff/bundle-update-2017-12-11-160933
Bundle Update on 2017-12-11
2017-12-13 16:20:36 +10:00
dependabot[bot]
bafe2b7fd1 Bump coffeelint from 1.16.0 to 2.0.7
Bumps [coffeelint](https://github.com/clutchski/coffeelint) from 1.16.0 to 2.0.7.
- [Commits](https://github.com/clutchski/coffeelint/commits)
2017-12-12 11:00:57 +00:00
Shiny
3be1454a69 Merge branch 'dev' into bundle-update-2017-12-11-160933 2017-12-12 12:36:54 +13:00
Shiny
232e5d50ac Merge branch 'dev' into planting-harvests 2017-12-12 12:36:33 +13:00
pozorvlak
7207a39039 Merge pull request #1486 from Br3nda/cleanup/routes
Convert hashes in routes
2017-12-11 10:47:18 +00:00
deppbot
291f865f7f Bundle Update on 2017-12-11 2017-12-11 16:09:34 +08:00
Brenda Wallace
47e82eb0a7 Convert hashes in routes 2017-12-10 19:50:08 +13:00
Brenda Wallace
08dc2a0513 Show photos of a planting's harvests 2017-12-09 22:24:51 +13:00
Brenda Wallace
4f64698403 Merge remote-tracking branch 'origin/feature/photos-1457' into feature/photos-1457 2017-12-09 20:59:56 +13:00
Brenda Wallace
14551b6ec8 Merge remote-tracking branch 'upstream/dev' into feature/photos-1457
Conflicts:
	spec/models/crop_spec.rb
2017-12-09 20:59:20 +13:00
Shiny
5d44196947 Merge branch 'master' into dev 2017-12-09 13:28:10 +13:00
Shiny
1c41cb7b66 Merge pull request #1483 from Growstuff/bundle-update-2017-12-08-121126
Bundle Update on 2017-12-08
2017-12-09 08:25:36 +13:00
Shiny
c3c55eaa09 Merge branch 'dev' into bundle-update-2017-12-08-121126 2017-12-09 08:15:28 +13:00
pozorvlak
98aa9521fe Merge pull request #1482 from Br3nda/ordering
Fixes to ordering
2017-12-08 12:04:48 +00:00
Shiny
96bb345ca9 Merge branch 'dev' into ordering 2017-12-08 20:20:27 +13:00
Shiny
9de991a075 Merge branch 'dev' into bundle-update-2017-12-08-121126 2017-12-08 20:19:39 +13:00
Shiny
f76619864c Merge pull request #1477 from Br3nda/upgrade-rubocop
Rubocop upgrade (and some style fixes)
2017-12-08 20:19:08 +13:00
deppbot
ec149997b0 Bundle Update on 2017-12-08 2017-12-08 12:11:27 +08:00
Brenda Wallace
ac07f18b2d Show most recent seeds first 2017-12-07 15:00:16 +13:00
Brenda Wallace
4ce3e8968f crops#show order posts by most recent first 2017-12-07 14:58:57 +13:00
Brenda Wallace
cd35538b83 Order forums by name 2017-12-07 13:42:48 +13:00
Shiny
0f317f624e Merge branch 'dev' into feature/photos-1457 2017-12-07 13:40:19 +13:00
Brenda Wallace
35d8461811 Order recent plantings by when they were planted 2017-12-07 13:39:32 +13:00
Brenda Wallace
8d03a3ffa8 Most recent photos is a crop's default photo 2017-12-06 21:47:01 +13:00
Brenda Wallace
2b0f199329 change string replacement for performance reasons 2017-12-06 15:19:34 +13:00
Brenda Wallace
24f18f78da use bare percent literals 2017-12-06 14:33:51 +13:00
Brenda Wallace
3cc637017d Avoid {} for multiline 2017-12-06 14:29:21 +13:00
Brenda Wallace
37f9dcd7dd for simple loops, use Integer.times 2017-12-06 14:26:58 +13:00
Brenda Wallace
f516ef2e57 Don't use :: for method calls 2017-12-06 14:24:17 +13:00
Brenda Wallace
182c626226 Prefer if/unless modifier 2017-12-06 14:23:12 +13:00
Brenda Wallace
ea2fcd09dc Fixed last old style word array 2017-12-06 14:18:51 +13:00
Brenda Wallace
878fc7ebcd Use symbol procs 2017-12-06 14:17:34 +13:00
Brenda Wallace
3fdc23098e Use perl names for cli script variables 2017-12-06 14:16:47 +13:00
Brenda Wallace
515325c44e Fixed up % delimiters 2017-12-06 14:14:31 +13:00
Brenda Wallace
25b1836146 Removed nil comparison 2017-12-06 14:13:01 +13:00
Brenda Wallace
c925c95398 Use next, instead of a if wrapper 2017-12-06 14:11:27 +13:00
Brenda Wallace
2d00206abf Converted sprintf to format 2017-12-06 14:10:26 +13:00
Brenda Wallace
f499f245de Added new line after block end, for rubocpo 2017-12-06 14:08:05 +13:00
Brenda Wallace
35414391c3 modified spec to please rubocop 2017-12-06 14:07:18 +13:00
Brenda Wallace
1f7f4f52d1 Updated ability_spec.rb to use block end new lines 2017-12-06 14:02:48 +13:00
Brenda Wallace
b4efeee904 Merge remote-tracking branch 'origin/upgrade-rubocop' into upgrade-rubocop 2017-12-06 11:23:03 +13:00
Brenda Wallace
5b588bf9e9 Rubocop change namespace of some cops 2017-12-06 11:21:25 +13:00
Daniel O'Connor
07611e9a5d Merge branch 'dev' into upgrade-rubocop 2017-12-05 11:38:52 +10:30
Daniel O'Connor
baa89a790f Merge pull request #1480 from Growstuff/bundle-update-2017-12-05-081300
Bundle Update on 2017-12-05
2017-12-05 11:38:18 +10:30
deppbot
00395ae68b Bundle Update on 2017-12-05 2017-12-05 08:13:00 +08:00
Shiny
41e26a2c74 Merge branch 'dev' into feature/photos-1457 2017-12-03 21:09:04 +13:00
Brenda Wallace
a6a7f789a3 Rubocop upgrade (and some style fixes) 2017-12-01 21:07:39 +13:00
Brenda Wallace
c4c659f159 DRY specs, and use create_list in crops model spec 2017-11-30 13:37:47 +13:00
Brenda Wallace
14b16b0d8c Moved photo.items's item lookup to a class method 2017-11-30 11:23:34 +13:00
Brenda Wallace
697779e67c Don't add item to photo is already there 2017-11-30 10:15:05 +13:00
Brenda Wallace
35ce8b84db Adding a unique index on the items <--> photos table 2017-11-30 09:56:47 +13:00
Brenda Wallace
ccbdfe51f6 Modified a spec to avoid a chicken and an egg 2017-11-29 22:30:11 +13:00
Brenda Wallace
ff57176d60 Simplified the photos controller a bit 2017-11-29 22:13:03 +13:00
Brenda Wallace
12700d6268 Added polymorphic relationship to photos 2017-11-29 21:41:22 +13:00
Brenda Wallace
17fd6f61a5 Added polymorphic relationship to photos 2017-11-29 20:14:27 +13:00
103 changed files with 632 additions and 634 deletions

View File

@@ -7,12 +7,14 @@ AllCops:
Exclude:
- 'db/schema.rb'
- 'vendor/**/*'
TargetRailsVersion: 4.0
Rails:
Enabled: true
Style/FileName:
Exclude:
- 'Guardfile'
- 'Gemfile'
- 'Gemfile.lock'
@@ -26,12 +28,12 @@ Style/PercentLiteralDelimiters:
'%i': ()
'%w': ()
Style/MultilineMethodCallIndentation:
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation
Style/AlignParameters:
Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation
Metrics/LineLength:

View File

@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --no-offense-counts`
# on 2017-11-05 20:41:45 +1300 using RuboCop version 0.47.1.
# on 2017-12-06 11:20:15 +1300 using RuboCop version 0.49.1.
# 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
@@ -18,12 +18,6 @@ Lint/UnusedMethodArgument:
- 'app/controllers/passwords_controller.rb'
- 'app/controllers/registrations_controller.rb'
- 'app/validators/approved_validator.rb'
- 'spec/views/plantings/show.html.haml_spec.rb'
# Cop supports --auto-correct.
Performance/StringReplacement:
Exclude:
- 'spec/rails_helper.rb'
Rails/FilePath:
Exclude:
@@ -62,37 +56,6 @@ Style/AsciiComments:
Exclude:
- 'config/initializers/comfortable_mexican_sofa.rb'
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: percent_q, bare_percent
Style/BarePercentLiterals:
Exclude:
- 'app/helpers/auto_suggest_helper.rb'
- 'spec/support/feature_helpers.rb'
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
# SupportedStyles: line_count_based, semantic, braces_for_chaining
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
# FunctionalMethods: let, let!, subject, watch
# IgnoredMethods: lambda, proc, it
Style/BlockDelimiters:
Exclude:
- 'spec/controllers/order_items_controller_spec.rb'
- 'spec/features/notifications_spec.rb'
- 'spec/models/ability_spec.rb'
- 'spec/models/comment_spec.rb'
- 'spec/models/follow_spec.rb'
- 'spec/models/member_spec.rb'
- 'spec/models/post_spec.rb'
- 'spec/views/crops/edit.html.haml_spec.rb'
# Cop supports --auto-correct.
Style/BlockEndNewline:
Exclude:
- 'spec/models/ability_spec.rb'
- 'spec/models/member_spec.rb'
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
@@ -101,38 +64,10 @@ Style/ClassAndModuleChildren:
- 'lib/actions/oauth_signup_action.rb'
- 'lib/haml/filters/escaped_markdown.rb'
# Cop supports --auto-correct.
Style/ColonMethodCall:
Exclude:
- 'spec/lib/haml/filters/escaped_markdown_spec.rb'
- 'spec/lib/haml/filters/growstuff_markdown_spec.rb'
# Cop supports --auto-correct.
Style/EachForSimpleLoop:
Exclude:
- 'spec/models/crop_spec.rb'
- 'spec/views/home/_crops.html.haml_spec.rb'
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- 'app/helpers/application_helper.rb'
- 'spec/helpers/application_helper_spec.rb'
- 'spec/views/shop/index_spec.rb'
Style/IdenticalConditionalBranches:
Exclude:
- 'app/controllers/follows_controller.rb'
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'app/helpers/crops_helper.rb'
- 'config/initializers/geocoder.rb'
- 'lib/tasks/growstuff.rake'
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: line_count_dependent, lambda, literal
@@ -146,32 +81,11 @@ Style/MultilineIfModifier:
Exclude:
- 'spec/rails_helper.rb'
Style/MultilineTernaryOperator:
Exclude:
- 'app/controllers/order_items_controller.rb'
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'app/models/planting.rb'
# Cop supports --auto-correct.
Style/NegatedIf:
Exclude:
- 'app/helpers/crops_helper.rb'
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
Exclude:
- 'lib/tasks/growstuff.rake'
# Cop supports --auto-correct.
Style/NilComparison:
Exclude:
- 'lib/tasks/growstuff.rake'
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison
@@ -187,14 +101,6 @@ Style/ParallelAssignment:
Exclude:
- 'app/mailers/notifier.rb'
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'app/helpers/auto_suggest_helper.rb'
- 'spec/features/signin_spec.rb'
- 'spec/features/signout_spec.rb'
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
@@ -205,23 +111,3 @@ Style/RegexpLiteral:
- 'spec/views/devise/registrations/edit_spec.rb'
- 'spec/views/members/index.html.haml_spec.rb'
- 'spec/views/posts/index.html.haml_spec.rb'
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles.
# SupportedStyles: use_perl_names, use_english_names
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to, define_method
Style/SymbolProc:
Exclude:
- 'lib/tasks/growstuff.rake'
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
MinSize: 4

View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
source 'https://rubygems.org'
ruby '2.4.1'
@@ -46,8 +47,8 @@ gem 'comfortable_mexican_sofa' # content management system
gem 'bootstrap-kaminari-views' # bootstrap views for kaminari
gem 'kaminari' # pagination
gem 'activemerchant'
gem 'active_utils'
gem 'activemerchant'
gem 'sidekiq'
# Markdown formatting for updates etc
@@ -144,7 +145,7 @@ group :development, :test do
gem 'rainbow', '< 2.2.0' # See https://github.com/sickill/rainbow/issues/44
gem 'rspec-activemodel-mocks'
gem 'rspec-rails' # unit testing framework
gem 'rubocop', '<= 0.47.1', require: false # Pin to rubocop (0.47.1) as 0.48.0 is buggy
gem 'rubocop'
gem 'selenium-webdriver'
gem 'webrat' # provides HTML matchers for view tests
end

View File

@@ -58,7 +58,7 @@ GEM
public_suffix (>= 2.0.2, < 4.0)
arel (6.0.4)
ast (2.3.0)
autoprefixer-rails (7.1.6)
autoprefixer-rails (7.2.3)
execjs
bcrypt (3.1.11)
better_errors (2.2.0)
@@ -81,7 +81,7 @@ GEM
sass (>= 3.3.4)
bootstrap_form (2.7.0)
builder (3.2.3)
bullet (5.6.1)
bullet (5.7.0)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.10.0)
byebug (9.1.0)
@@ -174,15 +174,15 @@ GEM
faraday
multi_json
erubis (2.7.0)
excon (0.59.0)
excon (0.60.0)
execjs (2.7.0)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
faker (1.8.4)
i18n (~> 0.5)
faker (1.8.5)
i18n (~> 0.9.1)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
@@ -232,11 +232,11 @@ GEM
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
haml_lint (0.25.1)
haml_lint (0.26.0)
haml (>= 4.0, < 5.1)
rainbow
rake (>= 10, < 13)
rubocop (>= 0.47.0)
rubocop (>= 0.49.0)
sysexits (~> 1.1)
hashie (3.5.6)
heroics (0.0.24)
@@ -297,7 +297,7 @@ GEM
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
kgio (2.11.0)
kgio (2.11.1)
kramdown (1.16.2)
launchy (2.4.3)
addressable (~> 2.3)
@@ -335,7 +335,7 @@ GEM
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
oauth (0.5.3)
oauth (0.5.4)
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
@@ -353,8 +353,8 @@ GEM
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth-oauth2 (1.5.0)
oauth2 (~> 1.1)
omniauth (~> 1.2)
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
@@ -366,6 +366,7 @@ GEM
cocaine (~> 0.5.5)
mime-types
mimemagic (~> 0.3.0)
parallel (1.12.1)
parser (2.4.0.2)
ast (~> 2.3)
pg (0.21.0)
@@ -375,7 +376,7 @@ GEM
moneta (~> 0.8.1)
plupload-rails (1.2.1)
rails (>= 3.1)
poltergeist (1.16.0)
poltergeist (1.17.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
@@ -461,19 +462,20 @@ GEM
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
rubocop (0.47.1)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
ruby-units (2.2.0)
ruby-units (2.2.1)
ruby_dep (1.5.0)
ruby_parser (3.10.1)
sexp_processor (~> 4.9)
rubyzip (1.2.1)
sass (3.5.3)
sass (3.5.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
@@ -519,11 +521,11 @@ GEM
thread_safe (0.3.6)
tilt (2.0.8)
timecop (0.9.1)
tins (1.16.0)
tins (1.16.3)
trollop (1.16.2)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (3.2.0)
uglifier (4.0.2)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.3.0)
unicorn (5.3.1)
@@ -623,7 +625,7 @@ DEPENDENCIES
responders
rspec-activemodel-mocks
rspec-rails
rubocop (<= 0.47.1)
rubocop
ruby-units
sass-rails
selenium-webdriver

View File

@@ -1,13 +1,13 @@
guard :rspec,
cmd: 'bundle exec rspec --format documentation',
failed_mode: :keep do
cmd: 'bundle exec rspec --format documentation',
failed_mode: :keep do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/libs/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
end
end

0
Rakefile Normal file → Executable file
View File

View File

@@ -1,38 +0,0 @@
module Growstuff
module Constants
class PhotoModels
PLANTING = { type: 'planting', class: 'Planting', relation: 'plantings' }.freeze
HARVEST = { type: 'harvest', class: 'Harvest', relation: 'harvests' }.freeze
GARDEN = { type: 'garden', class: 'Garden', relation: 'gardens' }.freeze
SEED = { type: 'seed', class: 'Seed', relation: 'seeds' }.freeze
ALL = [PLANTING, HARVEST, GARDEN, SEED].freeze
def self.types
ALL.map do |model|
model[:type]
end
end
def self.relations
ALL.map do |model|
model[:relation]
end
end
def self.get_relation(object, type)
relation = ALL.select do |model|
model[:type] == type
end[0][:relation]
object.send(relation)
end
def self.get_item(type)
class_name = ALL.select do |model|
model[:type] == type
end[0][:class]
class_name.constantize
end
end
end
end

View File

@@ -0,0 +1,14 @@
module Admin
class MembersController < ApplicationController
before_action :auth!
def index
@members = Member.order(:login_name).paginate(page: params[:page])
end
private
def auth!
authorize! :manage, :all
end
end
end

View File

@@ -1,21 +1,23 @@
class Admin::OrdersController < ApplicationController
def index
authorize! :manage, :all
respond_to do |format|
format.html # index.html.haml
end
end
def search
authorize! :manage, :all
@orders = Order.search(by: params[:search_by], for: params[:search_text])
if @orders.empty?
flash[:alert] = "Couldn't find order with #{params[:search_by]} = #{params[:search_text]}"
module Admin
class OrdersController < ApplicationController
def index
authorize! :manage, :all
respond_to do |format|
format.html # index.html.haml
end
end
respond_to do |format|
format.html # index.html.haml
def search
authorize! :manage, :all
@orders = Order.search(by: params[:search_by], for: params[:search_text])
if @orders.empty?
flash[:alert] = "Couldn't find order with #{params[:search_by]} = #{params[:search_text]}"
end
respond_to do |format|
format.html # index.html.haml
end
end
end
end

View File

@@ -1,5 +1,5 @@
class AlternateNamesController < ApplicationController
before_action :authenticate_member!, except: [:index, :show]
before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
responders :flash

View File

@@ -1,3 +1,4 @@
require './lib/actions/oauth_signup_action'
class AuthenticationsController < ApplicationController
before_action :authenticate_member!
load_and_authorize_resource

View File

@@ -1,5 +1,5 @@
class CommentsController < ApplicationController
before_action :authenticate_member!, except: [:index, :show]
before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
respond_to :rss, only: :index

View File

@@ -1,9 +1,9 @@
require 'will_paginate/array'
class CropsController < ApplicationController
before_action :authenticate_member!, except: [:index, :hierarchy, :search, :show]
before_action :authenticate_member!, except: %i(index hierarchy search show)
load_and_authorize_resource
skip_authorize_resource only: [:hierarchy, :search]
skip_authorize_resource only: %i(hierarchy search)
respond_to :html, :json, :rss, :csv
responders :flash
@@ -50,7 +50,7 @@ class CropsController < ApplicationController
def show
@crop = Crop.includes(:scientific_names, plantings: :photos).find(params[:id])
@posts = @crop.posts.paginate(page: params[:page])
@posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page])
respond_to do |format|
format.html # show.html.haml
@@ -134,7 +134,7 @@ class CropsController < ApplicationController
end
def recreate_names(param_name, name_type)
return unless params[param_name].present?
return if params[param_name].blank?
destroy_names(name_type)
params[param_name].each do |_i, value|
create_name!(name_type, value) unless value.empty?
@@ -159,9 +159,9 @@ class CropsController < ApplicationController
:request_notes,
:reason_for_rejection,
:rejection_notes,
scientific_names_attributes: [:scientific_name,
:_destroy,
:id])
scientific_names_attributes: %i(scientific_name
_destroy
id))
end
def filename
@@ -173,7 +173,7 @@ class CropsController < ApplicationController
include: {
plantings: {
include: {
owner: { only: [:id, :login_name, :location, :latitude, :longitude] }
owner: { only: %i(id login_name location latitude longitude) }
}
},
scientific_names: { only: [:name] },

View File

@@ -1,6 +1,6 @@
class GardensController < ApplicationController
before_action :authenticate_member!, except: [:index, :show]
after_action :expire_homepage, only: [:create, :delete]
before_action :authenticate_member!, except: %i(index show)
after_action :expire_homepage, only: %i(create delete)
load_and_authorize_resource
respond_to :html, :json

View File

@@ -18,6 +18,7 @@ class HarvestsController < ApplicationController
def show
@matching_plantings = matching_plantings if @harvest.owner == current_member
@photos = @harvest.photos.order(created_at: :desc).paginate(page: params[:page])
respond_with(@harvest)
end

View File

@@ -1,6 +1,6 @@
class MembersController < ApplicationController
load_and_authorize_resource except: [:finish_signup, :unsubscribe, :view_follows, :view_followers, :show]
skip_authorize_resource only: [:nearby, :unsubscribe, :finish_signup]
load_and_authorize_resource except: %i(finish_signup unsubscribe view_follows view_followers show)
skip_authorize_resource only: %i(nearby unsubscribe finish_signup)
respond_to :html, :json, :rss
after_action :expire_homepage, only: :create
@@ -62,7 +62,6 @@ class MembersController < ApplicationController
@member.update(@type => false)
flash.now[:notice] = I18n.t('members.unsubscribed', email_type: EMAIL_TYPE_STRING[@type])
rescue ActiveSupport::MessageVerifier::InvalidSignature
flash.now[:alert] = I18n.t('members.unsubscribe.error')
end
@@ -88,11 +87,11 @@ class MembersController < ApplicationController
end
def member_json_fields
[
:id, :login_name,
:slug, :bio, :created_at,
:location, :latitude, :longitude
]
%i(
id login_name
slug bio created_at
location latitude longitude
)
end
def members

View File

@@ -30,7 +30,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
@authentication = action.establish_authentication(auth, member)
if action.member_created?
raise "Invalid provider" unless ['facebook', 'twitter', 'flickr'].index(auth['provider'].to_s)
raise "Invalid provider" unless %w(facebook twitter flickr).index(auth['provider'].to_s)
session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"]
sign_in member

View File

@@ -3,11 +3,19 @@ class PhotoAssociationsController < ApplicationController
respond_to :json, :html
def destroy
raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class
@photo = Photo.find_by!(id: params[:photo_id], owner: current_member)
collection = Growstuff::Constants::PhotoModels.get_relation(@photo, params[:type])
item_class = Growstuff::Constants::PhotoModels.get_item(params[:type])
@item = item_class.find_by!(id: params[:id], owner_id: current_member.id)
collection.delete(@item)
@item = Photographing.item(item_id, item_class)
@item.photos.delete(@photo)
# @photo.destroy_if_unused
respond_with(@photo)
end
def item_class
params[:type].capitalize
end
def item_id
params[:id]
end
end

View File

@@ -1,6 +1,6 @@
class PhotosController < ApplicationController
before_action :authenticate_member!, except: [:index, :show]
after_action :expire_homepage, only: [:create, :delete]
before_action :authenticate_member!, except: %i(index show)
after_action :expire_homepage, only: %i(create delete)
load_and_authorize_resource
respond_to :html, :json
responders :flash
@@ -36,7 +36,7 @@ class PhotosController < ApplicationController
@photo = find_or_create_photo_from_flickr_photo
@item = item_to_link_to
raise "Could not find this #{type} owned by you" unless @item
collection << @item unless collection.include?(@item)
@item.photos << @photo unless @item.photos.include? @photo
@photo.save! if @photo.present?
end
respond_with @photo
@@ -74,21 +74,12 @@ class PhotosController < ApplicationController
end
# Item with photos attached
#
def item_to_link_to
raise "No item id provided" if item_id.nil?
raise "No item type provided" if item_type.nil?
raise "Missing or invalid type provided" unless photos_supported_on_type?(item_type)
item_class = Growstuff::Constants::PhotoModels.get_item(item_type)
item_class.find_by!(id: params[:id], owner_id: current_member.id)
end
def collection
Growstuff::Constants::PhotoModels.get_relation(@photo, item_type)
end
def photos_supported_on_type?(_type)
Growstuff::Constants::PhotoModels.types.include?(item_type)
item_class = item_type.capitalize
raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class
item_class.constantize.find_by!(id: params[:id], owner_id: current_member.id)
end
#

View File

@@ -7,9 +7,9 @@ class PlacesController < ApplicationController
format.html
# json response is whatever we want to map here
format.json do
render json: Member.located.to_json(only: [
:id, :login_name, :slug, :location, :latitude, :longitude
])
render json: Member.located.to_json(only: %i(
id login_name slug location latitude longitude
))
end
end
end
@@ -22,9 +22,9 @@ class PlacesController < ApplicationController
respond_to do |format|
format.html # show.html.haml
format.json do
render json: @nearby_members.to_json(only: [
:id, :login_name, :slug, :location, :latitude, :longitude
])
render json: @nearby_members.to_json(only: %i(
id login_name slug location latitude longitude
))
end
end
end

View File

@@ -31,6 +31,7 @@ class PlantingsController < ApplicationController
@planting = Planting.includes(:owner, :crop, :garden, :photos)
.friendly
.find(params[:id])
@photos = @planting.photos.order(created_at: :desc).includes(:owner).paginate(page: params[:page])
respond_with @planting
end

View File

@@ -1,8 +1,8 @@
class PostsController < ApplicationController
before_action :authenticate_member!, except: [:index, :show]
before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
respond_to :rss, only: [:index, :show]
respond_to :rss, only: %i(index show)
# GET /posts
# GET /posts.json

View File

@@ -1,5 +1,5 @@
class ScientificNamesController < ApplicationController
before_action :authenticate_member!, except: [:index, :show]
before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
responders :flash

View File

@@ -1,5 +1,5 @@
class SeedsController < ApplicationController
before_action :authenticate_member!, except: [:index, :show]
before_action :authenticate_member!, except: %i(index show)
load_and_authorize_resource
respond_to :html, :json
respond_to :csv, only: :index
@@ -19,6 +19,7 @@ class SeedsController < ApplicationController
# GET /seeds/1
# GET /seeds/1.json
def show
@photos = @seed.photos.includes(:owner).order(created_at: :desc).paginate(page: params[:page])
respond_with(@seed)
end

View File

@@ -1,11 +1,11 @@
module ApplicationHelper
def price_in_dollars(price)
sprintf('%.2f', price / 100.0)
format('%.2f', price / 100.0)
end
# 999 cents becomes 9.99 AUD -- for products/orders/etc
def price_with_currency(price)
sprintf('%.2f %s', price / 100.0, Growstuff::Application.config.currency)
format('%.2f %s', price / 100.0, Growstuff::Application.config.currency)
end
def parse_date(str)

View File

@@ -11,7 +11,7 @@ module AutoSuggestHelper
resource = resource.class.name.downcase
source_path = Rails.application.routes.url_helpers.send("#{source}s_search_path")
%Q{
%(
<input id="#{source}" class="auto-suggest #{options[:class]}"
type="text" value="#{default}" data-source-url="#{source_path}",
placeholder="e.g. lettuce">
@@ -20,6 +20,6 @@ module AutoSuggestHelper
</noscript>
<input id="#{resource}_#{source}_id" class="auto-suggest-id"
type="hidden" name="#{resource}[#{source}_id]" value="#{default_id}">
}.html_safe
).html_safe
end
end

View File

@@ -8,9 +8,7 @@ module CropsHelper
total_quantity += seed.quantity if seed.quantity
end
if !seeds.any?
return "You don't have any seeds of this crop."
end
return "You don't have any seeds of this crop." if seeds.none?
if total_quantity != 0
"You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop."

View File

@@ -15,7 +15,7 @@ module HarvestsHelper
if harvest.unit == 'individual' # just the number
number_to_human(harvest.quantity, strip_insignificant_zeros: true)
elsif !harvest.unit.blank? # pluralize anything else
elsif harvest.unit.present? # pluralize anything else
pluralize(number_to_human(harvest.quantity, strip_insignificant_zeros: true), harvest.unit)
else
"#{number_to_human(harvest.quantity, strip_insignificant_zeros: true)} #{harvest.unit}"

View File

@@ -10,11 +10,11 @@ module PlantingsHelper
end
def display_planted_from(planting)
!planting.planted_from.blank? ? planting.planted_from : "not specified"
planting.planted_from.present? ? planting.planted_from : "not specified"
end
def display_planting_quantity(planting)
!planting.quantity.blank? ? planting.quantity : "not specified"
planting.quantity.present? ? planting.quantity : "not specified"
end
def display_planting(planting)

View File

@@ -1,7 +1,13 @@
class Ability
include CanCan::Ability
def initialize(member) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def initialize(member)
anon_abilities(member)
member_abilities(member) if member.present?
admin_abilities(member) if member.present? && member.role?(:admin)
end
def anon_abilities(_member)
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
# everyone can do these things, even non-logged in
@@ -35,7 +41,9 @@ class Ability
can :read, AlternateName do |an|
an.crop.approved?
end
end
def member_abilities(member) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
return unless member
# members can see even rejected or pending crops if they requested it
@@ -126,7 +134,9 @@ class Ability
can :destroy, Follow
cannot :destroy, Follow, followed_id: member.id # can't unfollow yourself
end
def admin_abilities(member)
return unless member.role? :admin
can :read, :all

View File

@@ -1,18 +1,10 @@
require_relative '../../constants/photo_models.rb'
module PhotoCapable
extend ActiveSupport::Concern
included do
has_and_belongs_to_many :photos # rubocop:disable Rails/HasAndBelongsToMany
has_many :photos, through: :photographings, as: :photographable
has_many :photographings, as: :photographable, dependent: :destroy
before_destroy :remove_from_list
scope :has_photos, -> { includes(:photos).where.not(photos: { id: nil }) }
end
def remove_from_list
photolist = photos.to_a # save a temp copy of the photo list
photos.clear # clear relationship b/w object and photo
photolist.each(&:destroy_if_unused)
end
end

View File

@@ -1,6 +1,6 @@
class Crop < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: [:slugged, :finders]
friendly_id :name, use: %i(slugged finders)
##
## Triggers
@@ -120,7 +120,8 @@ class Crop < ActiveRecord::Base
# later we can choose a default photo based on different criteria,
# eg. popularity
def default_photo
return photos.first if photos.any?
# most recent photo
return photos.order(created_at: :desc).first if photos.any?
# Crop has no photos? Look for the most recent harvest with a photo.
harvest_with_photo = Harvest.where(crop_id: id).joins(:photos).order('harvests.id DESC').limit(1).first

View File

@@ -34,7 +34,7 @@ class CsvImporter
def add_scientific_names(scientific_names)
names_to_add = []
if !scientific_names.blank? # i.e. we actually passed something in, which isn't a given
if scientific_names.present? # i.e. we actually passed something in, which isn't a given
names_to_add = scientific_names.split(/,\s*/)
elsif @crop.parent && !@crop.parent.scientific_names.empty? # pick up from parent
names_to_add = @crop.parent.scientific_names.map(&:name)

View File

@@ -1,31 +1,19 @@
require_relative '../constants/photo_models.rb'
class Photo < ActiveRecord::Base
belongs_to :owner, class_name: 'Member'
Growstuff::Constants::PhotoModels.relations.each do |relation|
has_and_belongs_to_many relation.to_sym # rubocop:disable Rails/HasAndBelongsToMany
end
PHOTO_CAPABLE = %w(Garden Planting Harvest Seed).freeze
before_destroy { all_associations.clear }
has_many :photographings, foreign_key: :photo_id, dependent: :destroy
# creates a relationship for each assignee type
PHOTO_CAPABLE.each do |type|
has_many type.downcase.pluralize.to_s.to_sym,
through: :photographings,
source: :photographable,
source_type: type
end
default_scope { joins(:owner) } # Ensures the owner still exists
def associations?
plantings.any? || harvests.any? || gardens.any? || seeds.any?
end
def all_associations
associations = []
Growstuff::Constants::PhotoModels.relations.each do |association_name|
associations << send(association_name.to_s).to_a
end
associations.flatten!
end
def destroy_if_unused
destroy if all_associations.empty?
end
# This is split into a side-effect free method and a side-effecting method
# for easier stubbing and testing.
def flickr_metadata
@@ -43,6 +31,14 @@ class Photo < ActiveRecord::Base
}
end
def associations?
photographings.size.positive?
end
def destroy_if_unused
destroy unless associations?
end
def calculate_title(info)
if id && title # already has a title saved
title

View File

@@ -0,0 +1,12 @@
class Photographing < ActiveRecord::Base
belongs_to :photo
belongs_to :photographable, polymorphic: true
def self.item(item_id, item_type)
find_by!(photographable_id: item_id, photographable_type: item_type).photographable
end
def item
find_by!(photographable_id: photographable_id, photographable_type: photographable_type).photographable
end
end

View File

@@ -26,6 +26,7 @@ class Planting < ActiveRecord::Base
scope :finished, -> { where(finished: true) }
scope :current, -> { where(finished: false) }
scope :interesting, -> { has_photos.one_per_owner }
scope :recent, -> { order(created_at: :desc) }
scope :one_per_owner, lambda {
joins("JOIN members m ON (m.id=plantings.owner_id)
LEFT OUTER JOIN plantings p2

View File

@@ -43,7 +43,7 @@ class Post < ActiveRecord::Base
# return posts sorted by recent activity
def self.recently_active
Post.all.sort do |a, b|
Post.order(created_at: :desc).sort do |a, b|
b.recent_activity <=> a.recent_activity
end
end

View File

@@ -1,7 +1,7 @@
class Seed < ActiveRecord::Base
extend FriendlyId
include PhotoCapable
friendly_id :seed_slug, use: [:slugged, :finders]
friendly_id :seed_slug, use: %i(slugged finders)
TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze
ORGANIC_VALUES = ['certified organic', 'non-certified organic', 'conventional/non-organic', 'unknown'].freeze

View File

@@ -2,16 +2,28 @@
%h2 Manage
%ul#admin_links
%li= link_to "Account types", account_types_path
%li= link_to "Alternate names", alternate_names_path
%li= link_to "Scientific names", scientific_names_path
%li= link_to "Products", products_path
%li= link_to "Roles", roles_path
%li= link_to "Forums", forums_path
%li= link_to "Newsletter subscribers", admin_newsletter_path
%li= link_to "CMS", comfy_admin_cms_path
.row
.col-md-4
%h2 Site admin
%ul#site_admin
%li= link_to "Account types", account_types_path
%li= link_to "Products", products_path
%li= link_to "Roles", roles_path
%li= link_to "Forums", forums_path
%li= link_to "CMS", comfy_admin_cms_path
%h2 Orders
.col-md-4
%h2 Crop data admin
%ul
%li= link_to "Alternate names", alternate_names_path
%li= link_to "Scientific names", scientific_names_path
.col-md-4
%h2 Member admin
%ul
%li= link_to "Newsletter subscribers", admin_newsletter_path
%li= link_to "Members", admin_members_path
= render "admin/orders/searchform"
.row
.col-md-12
%h2 Orders
= render "admin/orders/searchform"

View File

@@ -0,0 +1,15 @@
.pagination
= page_entries_info @members
= will_paginate @members
%table.table.table-striped
%tr
%th Name
%th Email
%th
%th
- @members.each do |member|
%tr
%td= ember.login_name
%td= member.email

View File

@@ -16,7 +16,7 @@
confirm: "Are you sure you want to remove this connection?",
method: :delete, class: "remove"
- else
= link_to 'Connect to Twitter', '/auth/twitter'
= link_to 'Connect to Twitter', '/members/auth/twitter'
.row
.col-md-12
@@ -30,7 +30,7 @@
confirm: "Are you sure you want to remove this connection?",
method: :delete, class: "remove"
- else
= link_to 'Connect to Flickr', '/auth/flickr'
= link_to 'Connect to Flickr', '/members/auth/flickr'
.row
.col-md-12
@@ -44,4 +44,4 @@
confirm: "Are you sure you want to remove this connection?",
method: :delete, class: "remove"
- else
= link_to 'Connect to Facebook', '/auth/facebook'
= link_to 'Connect to Facebook', '/members/auth/facebook'

View File

@@ -0,0 +1,29 @@
.panel.panel-success
.panel-heading
%h3.panel-title
= link_to "#{harvest.owner.login_name}'s #{harvest.crop.name} harvest", harvest
- if can? :edit, harvest
%a.pull-right{ href: edit_harvest_path(harvest), role: "button", id: "edit_harvest_glyphicon" }
%span.glyphicon.glyphicon-pencil{ title: "Edit" }
.panel-body
.row
.col-md-4
= link_to image_tag((harvest.default_photo ? harvest.default_photo.thumbnail_url : 'placeholder_150.png'),
alt: harvest.crop.name, class: 'img'),
harvest
.col-md-8
%dl.dl-horizontal
%dt Crop :
%dd= link_to harvest.crop.name, harvest.crop
%dt Plant part :
%dd= link_to harvest.plant_part, harvest.plant_part
%dt Quantity :
%dd= display_quantity(harvest)
%dt Harvest date :
%dd= harvest.harvested_at
.panel-footer
%dt Description
%dd.truncate
= display_harvest_description(harvest)
= if harvest.description.present?
- link_to "Read more", harvest_path(harvest)

View File

@@ -1,29 +1,9 @@
.panel.panel-success
.panel-heading
%h3.panel-title
= link_to "#{harvest.owner.login_name}'s #{harvest.crop.name} harvest", harvest
- if can? :edit, harvest
%a.pull-right{ href: edit_harvest_path(harvest), role: "button", id: "edit_harvest_glyphicon" }
%span.glyphicon.glyphicon-pencil{ title: "Edit" }
.panel-body
.row
.col-md-4
= link_to image_tag((harvest.default_photo ? harvest.default_photo.thumbnail_url : 'placeholder_150.png'),
alt: harvest.crop.name, class: 'img'),
harvest
.col-md-8
%dl.dl-horizontal
%dt Crop :
%dd= link_to harvest.crop.name, harvest.crop
%dt Plant part :
%dd= link_to harvest.plant_part, harvest.plant_part
%dt Quantity :
%dd= display_quantity(harvest)
%dt Harvest date :
%dd= harvest.harvested_at
.panel-footer
%dt Description
%dd.truncate
= display_harvest_description(harvest)
= if harvest.description.present?
- link_to "Read more", harvest_path(harvest)
.thumbnail
.harvest-thumbnail
- if harvest
= link_to image_tag((harvest.default_photo ? harvest.default_photo.thumbnail_url : 'placeholder_150.png'),
alt: harvest.crop.name, class: 'img'),
harvest
.harvestinfo
.harvest-name
= link_to harvest, harvest

View File

@@ -15,7 +15,7 @@
- unless @harvests.empty?
- @harvests.each do |harvest|
.col-md-6
= render partial: 'harvests/thumbnail', locals: { harvest: harvest }
= render 'harvests/card', harvest: harvest
.pagination
= page_entries_info @harvests

View File

@@ -48,15 +48,4 @@
:growstuff_markdown
#{ @harvest.description != "" ? strip_tags(@harvest.description) : "No description given." }
- if !@harvest.photos.empty? || (can?(:edit, @harvest) && can?(:create, Photo))
%h2 Pictures
%ul.thumbnails
- @harvest.photos.each do |p|
.col-md-2.six-across
= render partial: 'photos/thumbnail', locals: { photo: p }
- if can?(:create, Photo) && can?(:edit, @harvest)
.col-md-2
.thumbnail{ style: 'height: 220px' }
%p{ style: 'text-align: center; padding-top: 50px' }
= link_to "Add photo", new_photo_path(type: "harvest", id: @harvest.id), class: 'btn btn-primary'
= render 'photos/item_photos', item: @harvest, type: 'harvest', photos: @photos

View File

@@ -14,7 +14,7 @@
.col-md-4.hidden-xs
- cache cache_key_for(Planting) do
%h2= t('.recently_planted')
= render partial: 'plantings/list', locals: { plantings: Planting.includes(:owner, :photos).interesting.first(6) }
= render 'plantings/list', plantings: Planting.includes(:owner, :photos).interesting.recent.first(6)
.row
.col-md-12

View File

@@ -2,10 +2,10 @@
- posts = Post.limit(6)
- if posts
= render partial: "posts/summary", locals: { posts: posts, howmany: 6 }
= render "posts/summary", posts: posts, howmany: 6
- cache cache_key_for(Forum) do
- forums = Forum.all
- forums = Forum.all.order(:name)
- if forums
%ul.list-inline
%li

View File

@@ -2,7 +2,7 @@
%h2= t('.title')
.row
.col-md-8
- Seed.includes(:owner, crop: :photos).interesting.first(6).each do |seed|
- Seed.includes(:owner, crop: :photos).order(created_at: :desc).interesting.first(6).each do |seed|
.col-md-3
.thumbnail
- cache cache_key_for(Crop, seed.id) do

View File

@@ -13,7 +13,7 @@
%small
%br/
Recently planted:
!= member.plantings.first(3).map { |p| link_to p.crop_name, p }.join(", ")
!= member.plantings.order(created_at: :desc).first(3).map { |p| link_to p.crop_name, p }.join(", ")
%p
%small
Joined
@@ -24,4 +24,3 @@
= [localize_plural(member.gardens, Garden),
localize_plural(member.plantings, Planting),
localize_plural(member.seeds, Seed)].join(", ")

View File

@@ -0,0 +1,16 @@
- if photos.size.positive? || (can?(:edit, item) && can?(:create, Photo))
%h2 Photos
- if photos.size.positive?
.row
.pagination
= page_entries_info photos
= will_paginate photos
.row
- photos.each do |photo|
.col-md-2.six-across= render 'photos/thumbnail', photo: photo
- if can?(:create, Photo) && can?(:edit, item)
.col-md-2
.thumbnail
= link_to new_photo_path(type: type, id: item.id), class: 'btn btn-primary' do
%span.glyphicon.glyphicon-camera{ title: "Add photo" }
Add photo

View File

@@ -16,7 +16,7 @@
%span.glyphicon.glyphicon-ok{ title: "Finished" }
Mark as finished
- if can?(:create, Harvest)
- if can? :edit, planting
= link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do
%span.glyphicon.glyphicon-leaf{ title: "Harvest" }
Harvest

View File

@@ -1,8 +1,12 @@
- unless planting.harvests.empty?
Harvests:
%ul
- planting.harvests.includes(:crop).each do |harvest|
%li
= harvest.harvested_at ? harvest.harvested_at : "undated"
= link_to harvest, harvest_path(harvest)
= link_to "more harvests from this planting", planting_harvests_path(planting)
- if planting.harvests.empty?
%p no harvests yet
- else
.row
- planting.harvests.order(created_at: :desc).includes(:crop).each do |harvest|
.col-xs-6.col-md-2
= render 'harvests/thumbnail', harvest: harvest
- if can? :edit, planting
.col-xs-6.col-md-2
= link_to new_planting_harvest_path(planting), class: 'btn btn-primary' do
%span.glyphicon.glyphicon-leaf{ title: "Harvest" }
Harvest

View File

@@ -1,15 +1,14 @@
- if planting.crop.perennial
%p Perennial
- elsif !planting.planted?
- if show_explanation == true
Progress: 0% - not planted yet
- if show_explanation
%p Progress: 0% - not planted yet
= render "plantings/progress_bar", status: "not planted", progress: 0
- elsif planting.finished?
= render "plantings/progress_bar", status: 'finished', progress: 100
- elsif planting.finish_predicted_at.nil?
- if show_explanation == true
Progress: Not enough data
%p Progress: Not enough data
= render "plantings/progress_bar", status: "unknown", progress: nil
- else
= render "plantings/progress_bar", status: 'growing', progress: planting.percentage_grown

View File

@@ -9,6 +9,7 @@
= tag("meta", property: "og:url", content: request.original_url)
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
%p= render 'plantings/actions', planting: @planting
.row.planting
.col-md-6
%dl.dl-horizontal.planting-attributes
@@ -45,11 +46,11 @@
%dd
- if @planting.finish_predicted_at.present?
= @planting.finish_predicted_at
- else
- elsif @planting.planted_at.blank?
%strong Set planted date to get predictions
%dt Finished:
%dd= display_finished(@planting)
- if @planting.finished?
%dt Finished:
%dd= display_finished(@planting)
- if @planting.crop.median_lifespan.present?
%dt Expected Lifespan:
%dd #{@planting.crop.median_lifespan} days
@@ -63,10 +64,11 @@
%dt Last Harvest:
%dd #{@planting.days_to_last_harvest} days after planting
%p= render 'plantings/harvests', planting: @planting
%p= render 'plantings/progress', planting: @planting, show_explanation: true
= render 'plantings/actions', planting: @planting
%h2 Progress
%p= render 'plantings/progress', planting: @planting, show_explanation: true
%h2 Harvests
%p= render 'plantings/harvests', planting: @planting
.col-md-6
= render partial: "crops/index_card", locals: { crop: @planting.crop }
@@ -81,15 +83,4 @@
:growstuff_markdown
#{ @planting.description != "" ? strip_tags(@planting.description) : "No description given." }
- if !@planting.photos.empty? || (can?(:edit, @planting) && can?(:create, Photo))
%h2 Photos
.row
- @planting.photos.includes(:owner).each do |p|
.col-md-2.six-across
= render partial: 'photos/thumbnail', locals: { photo: p }
- if can?(:create, Photo) && can?(:edit, @planting)
.col-md-2
.thumbnail{ style: 'height: 220px' }
%p{ style: 'text-align: center; padding-top: 50px' }
= link_to "Add photo", new_photo_path(type: "planting", id: @planting.id), class: 'btn btn-primary'
= render 'photos/item_photos', item: @planting, type: 'planting', photos: @photos

View File

@@ -1,18 +1,19 @@
= form_for @role do |f|
- if @role.errors.any?
#error_explanation
%h2
= pluralize(@role.errors.size, "error")
prohibited this role from being saved:
%ul
- @role.errors.full_messages.each do |msg|
%li= msg
.row
- if @role.errors.any?
#error_explanation
%h2
= pluralize(@role.errors.size, "error")
prohibited this role from being saved:
%ul
- @role.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :name
= f.text_field :name
.col-md2= f.label :name
.col-md10= f.text_field :name
.field
= f.label :description
= f.text_area :description
.col-md2= f.label :description
.col-md10= f.text_area :description
.actions
= f.submit 'Save'
= f.submit 'Save', class: 'btn btn-default'

View File

@@ -2,6 +2,4 @@
= render 'form'
= link_to 'Show', @role
\|
= link_to 'Back', roles_path

View File

@@ -3,17 +3,16 @@
- if can? :create, Role
%p= link_to 'New Role', new_role_path, class: 'btn btn-primary'
%table
%table.table.table-striped
%tr
%th Name
%th Description
%th
%th
%th
- @roles.each do |role|
%tr
%td= link_to role.name, role
%td= role.name
%td= role.description
- if can? :edit, role
%td= link_to 'Edit', edit_role_path(role), class: 'btn btn-default btn-xs'

View File

@@ -0,0 +1,11 @@
- if can? :edit, @seed
= link_to edit_seed_path(@seed), class: 'btn btn-default btn-xs' do
%span.glyphicon.glyphicon-pencil{ title: "Edit" }
Edit
= link_to new_photo_path(id: seed.id, type: 'seed'), class: 'btn btn-default btn-xs' do
%span.glyphicon.glyphicon-camera{ title: "Add photo" }
Add photo
- if can? :destroy, @seed
= link_to @seed, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do
%span.glyphicon.glyphicon-trash{ title: "Delete" }
Delete

View File

@@ -58,15 +58,11 @@
subject: "Interested in your #{@seed.crop} seeds"),
class: 'btn btn-primary'
- else
= render partial: 'shared/signin_signup', locals: { to: 'request seeds' }
= render 'shared/signin_signup', to: 'request seeds'
- if can?(:edit, @seed) || can?(:destroy, @seed)
%p
- if can? :edit, @seed
= link_to 'Edit', edit_seed_path(@seed), class: 'btn btn-default btn-xs'
- if can? :destroy, @seed
= link_to 'Delete', @seed, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs'
= render 'actions', seed: @seed
.col-md-6
= render partial: "crops/index_card", locals: { crop: @seed.crop }
- if @seed.owner.location
@@ -79,3 +75,5 @@
Or
= link_to "purchase seeds via Ebay",
crop_ebay_seeds_url(@seed.crop), target: "_blank", rel: "noopener noreferrer"
= render 'photos/item_photos', item: @seed, type: 'seed', photos: @photos

View File

@@ -43,7 +43,7 @@ Devise.setup do |config|
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
config.strip_whitespace_keys = [:email, :login_name]
config.strip_whitespace_keys = %i(email login_name)
# Tell if authentication through request.params is enabled. True by default.
# It can be set to an array that will enable params authentication only for the

View File

@@ -11,6 +11,4 @@ Geocoder.configure(
)
# This configuration takes precedence over environment/test.rb
# Reported as https://github.com/alexreisner/geocoder/issues/509
if Geocoder.config.lookup != :test
Geocoder.configure(lookup: :nominatim)
end
Geocoder.configure(lookup: :nominatim) if Geocoder.config.lookup != :test

View File

@@ -10,44 +10,44 @@ Growstuff::Application.routes.draw do
omniauth_callbacks: "omniauth_callbacks"
}
devise_scope :member do
get '/members/unsubscribe/:message' => 'members#unsubscribe', :as => 'unsubscribe_member'
get '/members/unsubscribe/:message' => 'members#unsubscribe', as: 'unsubscribe_member'
end
match '/members/:id/finish_signup' => 'members#finish_signup', via: [:get, :patch], :as => :finish_signup
match '/members/:id/finish_signup' => 'members#finish_signup', via: %i(get patch), as: :finish_signup
resources :members
resources :photos
delete 'photo_associations' => 'photo_associations#destroy'
resources :authentications, only: [:create, :destroy]
resources :authentications, only: %i(create destroy)
resources :plantings do
resources :harvests
end
get '/plantings/owner/:owner' => 'plantings#index', :as => 'plantings_by_owner'
get '/plantings/crop/:crop' => 'plantings#index', :as => 'plantings_by_crop'
get '/plantings/owner/:owner' => 'plantings#index', as: 'plantings_by_owner'
get '/plantings/crop/:crop' => 'plantings#index', as: 'plantings_by_crop'
resources :gardens
get '/gardens/owner/:owner' => 'gardens#index', :as => 'gardens_by_owner'
get '/gardens/owner/:owner' => 'gardens#index', as: 'gardens_by_owner'
resources :seeds
get '/seeds/owner/:owner' => 'seeds#index', :as => 'seeds_by_owner'
get '/seeds/crop/:crop' => 'seeds#index', :as => 'seeds_by_crop'
get '/seeds/owner/:owner' => 'seeds#index', as: 'seeds_by_owner'
get '/seeds/crop/:crop' => 'seeds#index', as: 'seeds_by_crop'
resources :harvests
get '/harvests/owner/:owner' => 'harvests#index', :as => 'harvests_by_owner'
get '/harvests/crop/:crop' => 'harvests#index', :as => 'harvests_by_crop'
get '/harvests/owner/:owner' => 'harvests#index', as: 'harvests_by_owner'
get '/harvests/crop/:crop' => 'harvests#index', as: 'harvests_by_crop'
resources :posts
get '/posts/author/:author' => 'posts#index', :as => 'posts_by_author'
get '/posts/author/:author' => 'posts#index', as: 'posts_by_author'
resources :scientific_names
resources :alternate_names
get 'crops/requested' => 'crops#requested', :as => 'requested_crops'
get 'crops/wrangle' => 'crops#wrangle', :as => 'wrangle_crops'
get 'crops/hierarchy' => 'crops#hierarchy', :as => 'crops_hierarchy'
get 'crops/search' => 'crops#search', :as => 'crops_search'
get 'crops/requested' => 'crops#requested', as: 'requested_crops'
get 'crops/wrangle' => 'crops#wrangle', as: 'wrangle_crops'
get 'crops/hierarchy' => 'crops#hierarchy', as: 'crops_hierarchy'
get 'crops/search' => 'crops#search', as: 'crops_search'
resources :crops do
get 'photos' => 'photos#index'
end
@@ -59,26 +59,26 @@ Growstuff::Application.routes.draw do
get 'reply', on: :member
end
resources :follows, only: [:create, :destroy]
get '/members/:login_name/follows' => 'members#view_follows', :as => 'member_follows'
get '/members/:login_name/followers' => 'members#view_followers', :as => 'member_followers'
resources :follows, only: %i(create destroy)
get '/members/:login_name/follows' => 'members#view_follows', as: 'member_follows'
get '/members/:login_name/followers' => 'members#view_followers', as: 'member_followers'
get '/places' => 'places#index'
get '/places/search' => 'places#search', :as => 'search_places'
get '/places/:place' => 'places#show', :as => 'place'
get '/places/search' => 'places#search', as: 'search_places'
get '/places/:place' => 'places#show', as: 'place'
# everything for paid accounts etc
resources :account_types
resources :accounts
resources :orders
get 'orders/:id/checkout' => 'orders#checkout', :as => 'checkout_order'
get 'orders/:id/complete' => 'orders#complete', :as => 'complete_order'
get 'orders/:id/cancel' => 'orders#cancel', :as => 'cancel_order'
get 'orders/:id/checkout' => 'orders#checkout', as: 'checkout_order'
get 'orders/:id/complete' => 'orders#complete', as: 'complete_order'
get 'orders/:id/cancel' => 'orders#cancel', as: 'cancel_order'
resources :order_items
resources :products
resources :likes, only: [:create, :destroy]
resources :likes, only: %i(create destroy)
get "home/index"
root to: 'home#index'
@@ -90,10 +90,13 @@ Growstuff::Application.routes.draw do
get '/shop/:action' => 'shop#:action'
comfy_route :cms_admin, path: '/admin/cms'
namespace :admin do
resources :members
end
get '/admin/orders' => 'admin/orders#index'
get '/admin/orders/:action' => 'admin/orders#:action'
get '/admin' => 'admin#index'
get '/admin/newsletter' => 'admin#newsletter', :as => :admin_newsletter
get '/admin/newsletter' => 'admin#newsletter', as: :admin_newsletter
get '/admin/:action' => 'admin#:action'
namespace :api do

View File

@@ -1,5 +1,5 @@
class AddCreationIndexToUpdates < ActiveRecord::Migration
def change
add_index :updates, [:created_at, :user_id]
add_index :updates, %i(created_at user_id)
end
end

View File

@@ -1,6 +1,6 @@
class RenameNotificationFields < ActiveRecord::Migration
def change
change_table :notifications do |t| # rubocop:disable Rails/ReversibleMigration
change_table :notifications do |t|
t.rename :to_id, :recipient_id
t.rename :from_id, :sender_id
end

View File

@@ -4,7 +4,7 @@ class AddCropsPostsTable < ActiveRecord::Migration
t.integer :crop_id
t.integer :post_id
end
add_index :crops_posts, [:crop_id, :post_id]
add_index :crops_posts, %i(crop_id post_id)
add_index :crops_posts, :crop_id
end
end

View File

@@ -1,5 +1,5 @@
class CreateIndexHarvestPhotos < ActiveRecord::Migration
def change
add_index(:harvests_photos, [:harvest_id, :photo_id])
add_index(:harvests_photos, %i(harvest_id photo_id))
end
end

View File

@@ -4,6 +4,6 @@ class AddGardensPhotosTable < ActiveRecord::Migration
t.integer :photo_id
t.integer :garden_id
end
add_index(:gardens_photos, [:garden_id, :photo_id])
add_index(:gardens_photos, %i(garden_id photo_id))
end
end

View File

@@ -33,8 +33,8 @@ class CreateCms < ActiveRecord::Migration
t.boolean :is_shared, null: false, default: false
t.timestamps null: true
end
add_index :comfy_cms_layouts, [:parent_id, :position]
add_index :comfy_cms_layouts, [:site_id, :identifier], unique: true
add_index :comfy_cms_layouts, %i(parent_id position)
add_index :comfy_cms_layouts, %i(site_id identifier), unique: true
# -- Pages --------------------------------------------------------------
create_table :comfy_cms_pages do |t|
@@ -52,8 +52,8 @@ class CreateCms < ActiveRecord::Migration
t.boolean :is_shared, null: false, default: false
t.timestamps null: true
end
add_index :comfy_cms_pages, [:site_id, :full_path]
add_index :comfy_cms_pages, [:parent_id, :position]
add_index :comfy_cms_pages, %i(site_id full_path)
add_index :comfy_cms_pages, %i(parent_id position)
# -- Page Blocks --------------------------------------------------------
create_table :comfy_cms_blocks do |t|
@@ -63,7 +63,7 @@ class CreateCms < ActiveRecord::Migration
t.timestamps null: true
end
add_index :comfy_cms_blocks, [:identifier]
add_index :comfy_cms_blocks, [:blockable_id, :blockable_type]
add_index :comfy_cms_blocks, %i(blockable_id blockable_type)
# -- Snippets -----------------------------------------------------------
create_table :comfy_cms_snippets do |t|
@@ -75,8 +75,8 @@ class CreateCms < ActiveRecord::Migration
t.boolean :is_shared, null: false, default: false
t.timestamps null: true
end
add_index :comfy_cms_snippets, [:site_id, :identifier], unique: true
add_index :comfy_cms_snippets, [:site_id, :position]
add_index :comfy_cms_snippets, %i(site_id identifier), unique: true
add_index :comfy_cms_snippets, %i(site_id position)
# -- Files --------------------------------------------------------------
create_table :comfy_cms_files do |t|
@@ -90,10 +90,10 @@ class CreateCms < ActiveRecord::Migration
t.integer :position, null: false, default: 0
t.timestamps null: true
end
add_index :comfy_cms_files, [:site_id, :label]
add_index :comfy_cms_files, [:site_id, :file_file_name]
add_index :comfy_cms_files, [:site_id, :position]
add_index :comfy_cms_files, [:site_id, :block_id]
add_index :comfy_cms_files, %i(site_id label)
add_index :comfy_cms_files, %i(site_id file_file_name)
add_index :comfy_cms_files, %i(site_id position)
add_index :comfy_cms_files, %i(site_id block_id)
# -- Revisions -----------------------------------------------------------
create_table :comfy_cms_revisions, force: true do |t|
@@ -102,7 +102,7 @@ class CreateCms < ActiveRecord::Migration
t.text :data, text_limit
t.datetime :created_at
end
add_index :comfy_cms_revisions, [:record_type, :record_id, :created_at],
add_index :comfy_cms_revisions, %i(record_type record_id created_at),
name: 'index_cms_revisions_on_rtype_and_rid_and_created_at'
# -- Categories ---------------------------------------------------------
@@ -111,7 +111,7 @@ class CreateCms < ActiveRecord::Migration
t.string :label, null: false
t.string :categorized_type, null: false
end
add_index :comfy_cms_categories, [:site_id, :categorized_type, :label],
add_index :comfy_cms_categories, %i(site_id categorized_type label),
unique: true,
name: 'index_cms_categories_on_site_id_and_cat_type_and_label'
@@ -120,7 +120,7 @@ class CreateCms < ActiveRecord::Migration
t.string :categorized_type, null: false
t.integer :categorized_id, null: false
end
add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id],
add_index :comfy_cms_categorizations, %i(category_id categorized_type categorized_id),
unique: true,
name: 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id'
end

View File

@@ -4,6 +4,6 @@ class AddPhotosSeedsTable < ActiveRecord::Migration
t.integer :photo_id
t.integer :seed_id
end
add_index(:photos_seeds, [:seed_id, :photo_id])
add_index(:photos_seeds, %i(seed_id photo_id))
end
end

View File

@@ -0,0 +1,54 @@
class CreatePhotographings < ActiveRecord::Migration
def change
create_table :photographings do |t|
t.integer :photo_id, null: false
t.integer :photographable_id, null: false
t.string :photographable_type, null: false
t.timestamps null: false
end
add_foreign_key :photographings, :photos
add_index :photographings, %i(photographable_id photographable_type photo_id),
unique: true, name: 'items_to_photos_idx'
add_index :photographings, %i(photographable_id photographable_type),
name: 'photographable_idx'
migrate_data
end
def migrate_data
say "migrating garden photos"
GardensPhoto.all.each do |g|
Photographing.create! photo_id: g.photo_id, photographable_id: g.garden_id, photographable_type: 'Garden'
end
say "migrating planting photos"
PhotosPlanting.all.each do |p|
Photographing.create! photo_id: p.photo_id, photographable_id: p.planting_id, photographable_type: 'Planting'
end
say "migrating harvest photos"
HarvestsPhoto.all.each do |h|
Photographing.create! photo_id: h.photo_id, photographable_id: h.harvest_id, photographable_type: 'Harvest'
end
say "migrating seed photos"
PhotosSeed.all.each do |s|
Photographing.create! photo_id: s.photo_id, photographable_id: s.seed_id, photographable_type: 'Seed'
end
end
class GardensPhoto < ActiveRecord::Base
belongs_to :photo
belongs_to :garden
end
class PhotosPlanting < ActiveRecord::Base
belongs_to :photo
belongs_to :planting
end
class HarvestsPhoto < ActiveRecord::Base
belongs_to :photo
belongs_to :harvest
end
class PhotosSeed < ActiveRecord::Base
belongs_to :photo
belongs_to :seed
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171105011017) do
ActiveRecord::Schema.define(version: 20171129041341) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -383,6 +383,17 @@ ActiveRecord::Schema.define(version: 20171105011017) do
t.integer "product_id"
end
create_table "photographings", force: :cascade do |t|
t.integer "photo_id", null: false
t.integer "photographable_id", null: false
t.string "photographable_type", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "photographings", ["photographable_id", "photographable_type", "photo_id"], name: "items_to_photos_idx", unique: true, using: :btree
add_index "photographings", ["photographable_id", "photographable_type"], name: "photographable_idx", using: :btree
create_table "photos", force: :cascade do |t|
t.integer "owner_id", null: false
t.string "thumbnail_url", null: false
@@ -498,4 +509,5 @@ ActiveRecord::Schema.define(version: 20171105011017) do
add_index "seeds", ["slug"], name: "index_seeds_on_slug", unique: true, using: :btree
add_foreign_key "harvests", "plantings"
add_foreign_key "photographings", "photos"
end

View File

@@ -6,7 +6,7 @@ module Geocodable
private
def empty_unwanted_geocodes
return unless location.blank?
return if location.present?
self.latitude = nil
self.longitude = nil
end

View File

@@ -62,7 +62,7 @@ namespace :growstuff do
# this fixes up anyone who has erroneously wound up with a 0,0 lat/long
task depopulate_null_island: :environment do
Member.find_each do |m|
if m.location and (m.latitude == nil and m.longitude == nil)
if m.location and (m.latitude.nil? and m.longitude.nil?)
m.geocode
m.save
end
@@ -140,9 +140,7 @@ namespace :growstuff do
puts "Giving each member an account record..."
Member.all.each do |m|
unless m.account
Account.create(member_id: m.id)
end
Account.create(member_id: m.id) unless m.account
end
puts "Making Skud a staff account..."
@@ -224,12 +222,11 @@ namespace :growstuff do
task initialize_garden_locations: :environment do
Member.located.find_each do |m|
m.gardens.each do |g|
if g.location.blank?
g.location = m.location
g.latitude = m.latitude
g.longitude = m.longitude
g.save
end
next if g.location.present?
g.location = m.location
g.latitude = m.latitude
g.longitude = m.longitude
g.save
end
end
end
@@ -277,16 +274,12 @@ namespace :growstuff do
desc "October 2014: remove unused photos"
task remove_unused_photos: :environment do
Photo.find_each do |p|
p.destroy_if_unused
end
Photo.find_each(&:destroy_if_unused)
end
desc "October 2014: generate crops_posts records for existing posts"
task generate_crops_posts_records: :environment do
Post.find_each do |p|
p.save
end
Post.find_each(&:save)
end
desc "October 2014: add alternate names for crops"

20
package-lock.json generated
View File

@@ -195,19 +195,13 @@
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
"dev": true
},
"coffee-script": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.11.1.tgz",
"integrity": "sha1-vxxHrWREOg2V0S3ysUfMCk2q1uk=",
"dev": true
},
"coffeelint": {
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/coffeelint/-/coffeelint-1.16.0.tgz",
"integrity": "sha1-g9jtHa/eOmd95E57ihi+YHdh5tg=",
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/coffeelint/-/coffeelint-2.0.7.tgz",
"integrity": "sha1-lg/VuXVrhFGU6fl6R1bmKGEha3Q=",
"dev": true,
"requires": {
"coffee-script": "1.11.1",
"coffeescript": "2.0.3",
"glob": "7.1.2",
"ignore": "3.3.7",
"optimist": "0.6.1",
@@ -215,6 +209,12 @@
"strip-json-comments": "1.0.4"
}
},
"coffeescript": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-2.0.3.tgz",
"integrity": "sha512-iIfUN+71IyI2FQABXh1luzZeQgqwUPeWh6lDovJatQQs+30bvyGnBY0r4BnD0hoMAasNuZVHlL1U09Oy1ZfSeg==",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",

View File

@@ -5,7 +5,7 @@
"main": "index.js",
"dependencies": {},
"devDependencies": {
"coffeelint": "^1.16.0",
"coffeelint": "^2.0.7",
"csslint": "^1.0.5",
"eslint": "^3.17.1",
"jshint": "^2.9.4"

View File

@@ -18,7 +18,7 @@ if ENV['TRAVIS']
end
else
author = `git config github.user`.chomp
if $?.exitstatus.positive?
if $CHILD_STATUS.exitstatus.positive?
abort %(
Couldn't determine your GitHub username, and not in a Travis PR build
Please set it using

View File

@@ -18,7 +18,7 @@ when "on"
when "off"
maintenance_state = false
else
abort "usage: #{$0} (on|off)"
abort "usage: #{$PROGRAM_NAME} (on|off)"
end
puts "Turning #{maintenance_state} maintenance mode on app #{app}"

View File

@@ -33,7 +33,7 @@ describe PhotoAssociationsController do
rescue
nil
end
end.not_to change { photo.harvests.count }
end.not_to change(photo.harvests, :count)
end
it { expect { delete :destroy, valid_params }.to raise_error(ActiveRecord::RecordNotFound) }
end

View File

@@ -2,7 +2,7 @@ FactoryBot.define do
sequence(:email) { |n| "member#{n}@example.com" }
sequence(:login_name) { |n| "member#{n}" }
factory :member, aliases: [:author, :owner, :sender, :recipient, :creator] do
factory :member, aliases: %i(author owner sender recipient creator) do
login_name { generate(:login_name) }
password 'password1'
email { generate(:email) }

View File

@@ -4,12 +4,12 @@ FactoryBot.define do
factory :photo do
owner
flickr_photo_id 1
title "Still life with chillies"
title { Faker::HarryPotter.quote }
license_name "CC-BY"
license_url "http://example.com/license.html"
thumbnail_url "http://example.com/thumb.jpg"
fullsize_url "http://example.com/full.jpg"
link_url "http://example.com/"
thumbnail_url { "http://example.com/#{Faker::File.file_name}.jpg" }
fullsize_url { "http://example.com/#{Faker::File.file_name}.jpg" }
link_url { Faker::Internet.url }
factory :unlicensed_photo do
license_name "All rights reserved"

View File

@@ -13,7 +13,7 @@ feature "forums", js: true do
visit root_path
click_link "Admin"
expect(current_path).to eq admin_path
within 'ul#admin_links' do
within 'ul#site_admin' do
click_link "Forums"
end
expect(current_path).to eq forums_path
@@ -25,7 +25,7 @@ feature "forums", js: true do
click_link member.login_name
click_link "Admin"
expect(current_path).to eq admin_path
within 'ul#admin_links' do
within 'ul#site_admin' do
click_link "Forums"
end
expect(current_path).to eq forums_path

View File

@@ -2,27 +2,31 @@ require 'rails_helper'
feature "crop detail page", js: true do
let(:member) { create :member }
let(:crop) { create :crop, plantings: [planting], harvests: [harvest] }
let(:planting) { create :planting, owner: member, photos: [photo1, photo2] }
let(:harvest) { create :harvest, owner: member, photos: [photo3, photo4] }
let(:planting) { create :planting, owner: member }
let(:harvest) { create :harvest, owner: member }
let(:photo1) do
create(:photo, owner: member, title: 'photo 1',
fullsize_url: 'photo1.jpg', thumbnail_url: 'thumb1.jpg')
create(:photo, owner: member, title: 'photo 1', fullsize_url: 'photo1.jpg', thumbnail_url: 'thumb1.jpg')
end
let(:photo2) do
create(:photo, owner: member, title: 'photo 2',
fullsize_url: 'photo2.jpg', thumbnail_url: 'thumb2.jpg')
create(:photo, owner: member, title: 'photo 2', fullsize_url: 'photo2.jpg', thumbnail_url: 'thumb2.jpg')
end
let(:photo3) do
create(:photo, owner: member, title: 'photo 3',
fullsize_url: 'photo3.jpg', thumbnail_url: 'thumb3.jpg')
create(:photo, owner: member, title: 'photo 3', fullsize_url: 'photo3.jpg', thumbnail_url: 'thumb3.jpg')
end
let(:photo4) do
create(:photo, owner: member, title: 'photo 4',
fullsize_url: 'photo4.jpg', thumbnail_url: 'thumb4.jpg')
create(:photo, owner: member, title: 'photo 4', fullsize_url: 'photo4.jpg', thumbnail_url: 'thumb4.jpg')
end
before { visit crop_path(crop) }
before do
planting.photos << photo1
planting.photos << photo2
harvest.photos << photo3
harvest.photos << photo4
visit crop_path(crop)
end
subject { page }
shared_examples "shows photos" do

View File

@@ -5,13 +5,13 @@ feature "Notifications", :js do
let(:recipient) { create :member }
context "On existing notification" do
let!(:notification) {
let!(:notification) do
create :notification,
sender: sender,
recipient: recipient,
body: "Notification body",
post_id: nil
}
end
background do
login_as recipient

View File

@@ -0,0 +1,41 @@
require 'rails_helper'
require 'custom_matchers'
feature "Seeds", :js do
let(:member) { FactoryBot.create :member }
let!(:seed) { FactoryBot.create :seed, owner: member }
subject do
login_as member
visit seed_path(seed)
page
end
it { is_expected.to have_content 'Add photo' }
# context 'no photos' do
# it { is_expected.to have_content 'no photos' }
# end
context 'has one photo' do
before { seed.photos = [photo] }
let!(:photo) { FactoryBot.create :photo, title: 'hello photo' }
it { is_expected.to have_xpath("//img[contains(@src,'#{photo.thumbnail_url}')]") }
it { is_expected.to have_xpath("//a[contains(@href,'#{photo_path(photo)}')]") }
end
context 'has 50 photos' do
before { seed.photos = photos }
let!(:photos) { FactoryBot.create_list :photo, 50 }
it "shows newest photo" do
is_expected.to have_xpath("//img[contains(@src,'#{photos.last.thumbnail_url}')]")
end
it "links to newest photo" do
is_expected.to have_xpath("//a[contains(@href,'#{photo_path(photos.last)}')]")
end
it "does not show oldest photo" do
is_expected.not_to have_xpath("//img[contains(@src,'#{photos.first.thumbnail_url}')]")
end
it "does not link to oldest photo" do
is_expected.not_to have_xpath("//a[contains(@href,'#{photo_path(photos.first)}')]")
end
end
end

View File

@@ -48,7 +48,7 @@ feature "signin", js: true do
end
describe "redirects to what you were trying to do" do
%w[plantings harvests posts photos gardens seeds].each do |m|
%w(plantings harvests posts photos gardens seeds).each do |m|
it_behaves_like "redirects to what you were trying to do" do
let(:model_name) { m }
end

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
describe ApplicationHelper do
it "formats prices" do
price_in_dollars(999).should eq '9.99'
price_with_currency(999).should eq '9.99 %s' % Growstuff::Application.config.currency
price_with_currency(999).should eq format('9.99 %s', Growstuff::Application.config.currency)
end
it "parses dates" do

View File

@@ -5,7 +5,7 @@ require 'haml/helpers'
describe 'Haml::Filters::Escaped_Markdown' do
it 'is registered as the handler for :escaped_markdown' do
Haml::Filters::defined['escaped_markdown'].should ==
Haml::Filters.defined['escaped_markdown'].should ==
Haml::Filters::EscapedMarkdown
end

View File

@@ -24,7 +24,7 @@ end
describe 'Haml::Filters::Growstuff_Markdown' do
it 'is registered as the handler for :growstuff_markdown' do
Haml::Filters::defined['growstuff_markdown'].should ==
Haml::Filters.defined['growstuff_markdown'].should ==
Haml::Filters::GrowstuffMarkdown
end

View File

@@ -111,19 +111,23 @@ describe Ability do
context "orders" do
let(:order) { FactoryBot.create(:order, member: member) }
let(:strangers_order) {
let(:strangers_order) do
FactoryBot.create(:order,
member: FactoryBot.create(:member)) }
let(:completed_order) {
member: FactoryBot.create(:member))
end
let(:completed_order) do
FactoryBot.create(:completed_order,
member: member) }
member: member)
end
let(:order_item) { FactoryBot.create(:order_item, order: order) }
let(:strangers_order_item) {
let(:strangers_order_item) do
FactoryBot.create(:order_item,
order: strangers_order) }
let(:completed_order_item) {
order: strangers_order)
end
let(:completed_order_item) do
FactoryBot.create(:order_item,
order: completed_order) }
order: completed_order)
end
context "standard member" do
it "can read their own orders" do

View File

@@ -17,9 +17,9 @@ describe Comment do
let(:comment) { FactoryBot.create(:comment) }
it "sends a notification when a comment is posted" do
expect {
expect do
FactoryBot.create(:comment)
}.to change(Notification, :count).by(1)
end.to change(Notification, :count).by(1)
end
it "sets the notification fields" do
@@ -35,9 +35,9 @@ describe Comment do
it "doesn't send notifications to yourself" do
@m = FactoryBot.create(:member)
@p = FactoryBot.create(:post, author: @m)
expect {
expect do
FactoryBot.create(:comment, post: @p, author: @m)
}.to change(Notification, :count).by(0)
end.to change(Notification, :count).by(0)
end
end

View File

@@ -269,78 +269,55 @@ describe Crop do
end
context 'interesting' do
it 'lists interesting crops' do
# first, a couple of candidate crops
@crop1 = FactoryBot.create(:crop)
@crop2 = FactoryBot.create(:crop)
let(:photo) { FactoryBot.create :photo }
# first, a couple of candidate crops
let(:crop1) { FactoryBot.create(:crop) }
let(:crop2) { FactoryBot.create(:crop) }
# they need 3+ plantings each to be interesting
(1..3).each do
FactoryBot.create(:planting, crop: @crop1)
end
(1..3).each do
FactoryBot.create(:planting, crop: @crop2)
let(:crop1_planting) { crop1.plantings.first }
let(:crop2_planting) { crop2.plantings.first }
subject { Crop.interesting }
describe 'lists interesting crops' do
before do
# they need 3+ plantings each to be interesting
FactoryBot.create_list(:planting, 3, crop: crop1)
FactoryBot.create_list(:planting, 3, crop: crop2)
# crops need 3+ photos to be interesting
crop1_planting.photos = FactoryBot.create_list :photo, 3
crop2_planting.photos = FactoryBot.create_list :photo, 3
end
# crops need 3+ photos to be interesting
@photo = FactoryBot.create(:photo)
[@crop1, @crop2].each do |c|
(1..3).each do
c.plantings.first.photos << @photo
c.plantings.first.save
end
end
Crop.interesting.should include @crop1
Crop.interesting.should include @crop2
Crop.interesting.size.should == 2
it { is_expected.to include crop1 }
it { is_expected.to include crop2 }
it { expect(subject.size).to eq 2 }
end
it 'ignores crops without plantings' do
# first, a couple of candidate crops
@crop1 = FactoryBot.create(:crop)
@crop2 = FactoryBot.create(:crop)
# only crop1 has plantings
(1..3).each do
FactoryBot.create(:planting, crop: @crop1)
describe 'crops without plantings are not interesting' do
before do
# only crop1 has plantings
FactoryBot.create_list(:planting, 3, crop: crop1)
# ... and photos
crop1_planting.photos = FactoryBot.create_list(:photo, 3)
end
# ... and photos
@photo = FactoryBot.create(:photo)
(1..3).each do
@crop1.plantings.first.photos << @photo
@crop1.plantings.first.save
end
Crop.interesting.should include @crop1
Crop.interesting.should_not include @crop2
Crop.interesting.size.should == 1
it { is_expected.to include crop1 }
it { is_expected.not_to include crop2 }
it { expect(subject.size).to eq 1 }
end
it 'ignores crops without photos' do
# first, a couple of candidate crops
@crop1 = FactoryBot.create(:crop)
@crop2 = FactoryBot.create(:crop)
describe 'crops without photos are not interesting' do
before do
# both crops have plantings
FactoryBot.create_list(:planting, 3, crop: crop1)
FactoryBot.create_list(:planting, 3, crop: crop2)
# both crops have plantings
(1..3).each do
FactoryBot.create(:planting, crop: @crop1)
# but only crop1 has photos
crop1_planting.photos = FactoryBot.create_list(:photo, 3)
end
(1..3).each do
FactoryBot.create(:planting, crop: @crop2)
end
# but only crop1 has photos
@photo = FactoryBot.create(:photo)
(1..3).each do
@crop1.plantings.first.photos << @photo
@crop1.plantings.first.save
end
Crop.interesting.should include @crop1
Crop.interesting.should_not include @crop2
Crop.interesting.size.should == 1
it { is_expected.to include crop1 }
it { is_expected.not_to include crop2 }
it { expect(subject.size).to eq 1 }
end
end
@@ -349,34 +326,20 @@ describe Crop do
let(:pp2) { FactoryBot.create(:plant_part) }
context "harvests" do
let(:h1) do
FactoryBot.create(:harvest,
crop: maize,
plant_part: pp1)
end
let(:h2) do
FactoryBot.create(:harvest,
crop: maize,
plant_part: pp2)
end
let(:h1) { FactoryBot.create(:harvest, crop: maize, plant_part: pp1) }
let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) }
let!(:crop) { FactoryBot.create(:crop) }
let!(:harvest) { FactoryBot.create(:harvest, crop: crop) }
it "has harvests" do
crop = FactoryBot.create(:crop)
harvest = FactoryBot.create(:harvest, crop: crop)
crop.harvests.should eq [harvest]
expect(crop.harvests).to eq [harvest]
end
end
it "doesn't duplicate plant_parts" do
@maize = FactoryBot.create(:maize)
@pp1 = FactoryBot.create(:plant_part)
@h1 = FactoryBot.create(:harvest,
crop: @maize,
plant_part: @pp1)
@h2 = FactoryBot.create(:harvest,
crop: @maize,
plant_part: @pp1)
@h1 = FactoryBot.create(:harvest, crop: @maize, plant_part: @pp1)
@h2 = FactoryBot.create(:harvest, crop: @maize, plant_part: @pp1)
@maize.plant_parts.should eq [@pp1]
end

View File

@@ -7,16 +7,16 @@ describe Follow do
end
it "sends a notification when a follow is created" do
expect {
expect do
Follow.create(follower_id: @member1.id, followed_id: @member2.id)
}.to change(Notification, :count).by(1)
end.to change(Notification, :count).by(1)
end
it "does not delete any members when follow is deleted" do
expect {
expect do
follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id)
follow.destroy
}.not_to change(Member, :count)
end.not_to change(Member, :count)
end
context "when follow is created" do

View File

@@ -353,9 +353,10 @@ describe 'member' do
end
context "update account" do
let(:product) {
let(:product) do
FactoryBot.create(:product,
paid_months: 3)}
paid_months: 3)
end
let(:member) { FactoryBot.create(:member) }
it "sets account_type" do

View File

@@ -95,15 +95,15 @@ describe Post do
let(:member2) { FactoryBot.create(:member) }
it "sends a notification when a member is mentioned using @-syntax" do
expect {
expect do
FactoryBot.create(:post, author: member, body: "Hey @#{member2}")
}.to change(Notification, :count).by(1)
end.to change(Notification, :count).by(1)
end
it "sends a notification when a member is mentioned using [](member) syntax" do
expect {
expect do
FactoryBot.create(:post, author: member, body: "Hey [#{member2}](member)")
}.to change(Notification, :count).by(1)
end.to change(Notification, :count).by(1)
end
it "sets the notification field" do
@@ -117,15 +117,15 @@ describe Post do
it "sends notifications to all members mentioned" do
member3 = FactoryBot.create(:member)
expect {
expect do
FactoryBot.create(:post, author: member, body: "Hey @#{member2} & @#{member3}")
}.to change(Notification, :count).by(2)
end.to change(Notification, :count).by(2)
end
it "doesn't send notifications if you mention yourself" do
expect {
expect do
FactoryBot.create(:post, author: member, body: "@#{member}")
}.to change(Notification, :count).by(0)
end.to change(Notification, :count).by(0)
end
end

View File

@@ -112,7 +112,7 @@ describe Seed do
end
it 'should refuse invalid organic/GMO/heirloom values' do
[:organic, :gmo, :heirloom].each do |field|
%i(organic gmo heirloom).each do |field|
@seed = FactoryBot.build(:seed, field => 'not valid')
@seed.should_not be_valid
@seed.errors[field].should_not be_empty
@@ -120,7 +120,7 @@ describe Seed do
end
it 'should not allow nil or blank values' do
[:organic, :gmo, :heirloom].each do |field|
%i(organic gmo heirloom).each do |field|
@seed = FactoryBot.build(:seed, field => nil)
@seed.should_not be_valid
@seed = FactoryBot.build(:seed, field => '')

View File

@@ -37,7 +37,7 @@ if ENV['GROWSTUFF_CAPYBARA_DRIVER'].present?
end
Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
"screenshot_#{example.description.gsub(' ', '-').gsub(/^.*\/spec\//, '')}"
"screenshot_#{example.description.tr(' ', '-').gsub(/^.*\/spec\//, '')}"
end
Capybara.app_host = 'http://localhost'

View File

@@ -28,7 +28,7 @@ RSpec.configure do |config|
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.syntax = [:should, :expect]
expectations.syntax = %i(should expect)
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
@@ -39,7 +39,7 @@ RSpec.configure do |config|
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = false
mocks.syntax = [:should, :expect]
mocks.syntax = %i(should expect)
end
# The settings below are suggested to provide a good initial experience

View File

@@ -8,7 +8,7 @@ module FeatureHelpers
def select_from_autocomplete(select)
page.should have_selector('ul.ui-autocomplete li.ui-menu-item a')
selector = %Q{ul.ui-autocomplete li.ui-menu-item a:contains("#{select}")}
selector = %{ul.ui-autocomplete li.ui-menu-item a:contains("#{select}")}
page.execute_script " $('#{selector}').mouseenter().click() "
end
end

View File

@@ -2,9 +2,9 @@ require 'rails_helper'
describe "crops/edit" do
before(:each) do
controller.stub(:current_user) {
controller.stub(:current_user) do
FactoryBot.create(:crop_wrangling_member)
}
end
@crop = FactoryBot.create(:maize)
3.times do
@crop.scientific_names.build

View File

@@ -6,6 +6,7 @@ describe "harvests/show" do
before do
controller.stub(:current_user) { nil }
assign(:harvest, harvest)
assign(:photos, harvest.photos.paginate(page: 1))
render
end

Some files were not shown because too many files have changed in this diff Show More