mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 09:19:15 -04:00
Compare commits
106 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c08beb5291 | ||
|
|
269f3164b7 | ||
|
|
9d47b2b029 | ||
|
|
81e26aaf02 | ||
|
|
d62322b498 | ||
|
|
ebb2f90294 | ||
|
|
72922a160d | ||
|
|
0699716c19 | ||
|
|
4c35987cb7 | ||
|
|
54e0806f38 | ||
|
|
99828c7c01 | ||
|
|
25d2773464 | ||
|
|
233a30a045 | ||
|
|
01a7463ae8 | ||
|
|
8a446ecbfc | ||
|
|
efc60e6313 | ||
|
|
406b2dbf04 | ||
|
|
ac056b4eb5 | ||
|
|
2394f4d237 | ||
|
|
2a4fd57050 | ||
|
|
5c885d675e | ||
|
|
0b08691160 | ||
|
|
b1052a2dbf | ||
|
|
95a923ff5f | ||
|
|
c8e34b640e | ||
|
|
6f2b4b13cd | ||
|
|
970da53873 | ||
|
|
3aa2f0bd3b | ||
|
|
8c1514bc04 | ||
|
|
d2e39f58d5 | ||
|
|
3d3a3b669e | ||
|
|
8697e56323 | ||
|
|
472b2eb192 | ||
|
|
1698157d8d | ||
|
|
ff652ae234 | ||
|
|
b4fcf004cd | ||
|
|
25e9ef892d | ||
|
|
82149d4565 | ||
|
|
fcd3e36e36 | ||
|
|
b783448ec3 | ||
|
|
e8b5850bfe | ||
|
|
bca72680c4 | ||
|
|
358eb96684 | ||
|
|
05807d41f4 | ||
|
|
96f1995768 | ||
|
|
deefbbce71 | ||
|
|
f8e51f4b45 | ||
|
|
1c8b75b7cb | ||
|
|
1f66df0743 | ||
|
|
72f52230a1 | ||
|
|
700fba58e8 | ||
|
|
acecbe93c1 | ||
|
|
bafe2b7fd1 | ||
|
|
3be1454a69 | ||
|
|
232e5d50ac | ||
|
|
7207a39039 | ||
|
|
291f865f7f | ||
|
|
47e82eb0a7 | ||
|
|
08dc2a0513 | ||
|
|
4f64698403 | ||
|
|
14551b6ec8 | ||
|
|
5d44196947 | ||
|
|
1c41cb7b66 | ||
|
|
c3c55eaa09 | ||
|
|
98aa9521fe | ||
|
|
96bb345ca9 | ||
|
|
9de991a075 | ||
|
|
f76619864c | ||
|
|
ec149997b0 | ||
|
|
ac07f18b2d | ||
|
|
4ce3e8968f | ||
|
|
cd35538b83 | ||
|
|
0f317f624e | ||
|
|
35d8461811 | ||
|
|
8d03a3ffa8 | ||
|
|
2b0f199329 | ||
|
|
24f18f78da | ||
|
|
3cc637017d | ||
|
|
37f9dcd7dd | ||
|
|
f516ef2e57 | ||
|
|
182c626226 | ||
|
|
ea2fcd09dc | ||
|
|
878fc7ebcd | ||
|
|
3fdc23098e | ||
|
|
515325c44e | ||
|
|
25b1836146 | ||
|
|
c925c95398 | ||
|
|
2d00206abf | ||
|
|
f499f245de | ||
|
|
35414391c3 | ||
|
|
1f7f4f52d1 | ||
|
|
b4efeee904 | ||
|
|
5b588bf9e9 | ||
|
|
07611e9a5d | ||
|
|
baa89a790f | ||
|
|
00395ae68b | ||
|
|
41e26a2c74 | ||
|
|
a6a7f789a3 | ||
|
|
c4c659f159 | ||
|
|
14b16b0d8c | ||
|
|
697779e67c | ||
|
|
35ce8b84db | ||
|
|
ccbdfe51f6 | ||
|
|
ff57176d60 | ||
|
|
12700d6268 | ||
|
|
17fd6f61a5 |
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
5
Gemfile
5
Gemfile
@@ -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
|
||||
|
||||
38
Gemfile.lock
38
Gemfile.lock
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
14
app/controllers/admin/members_controller.rb
Normal file
14
app/controllers/admin/members_controller.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
require './lib/actions/oauth_signup_action'
|
||||
class AuthenticationsController < ApplicationController
|
||||
before_action :authenticate_member!
|
||||
load_and_authorize_resource
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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] },
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
#
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
12
app/models/photographing.rb
Normal file
12
app/models/photographing.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
15
app/views/admin/members/index.html.haml
Normal file
15
app/views/admin/members/index.html.haml
Normal 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
|
||||
@@ -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'
|
||||
|
||||
29
app/views/harvests/_card.html.haml
Normal file
29
app/views/harvests/_card.html.haml
Normal 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)
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(", ")
|
||||
|
||||
|
||||
16
app/views/photos/_item_photos.haml
Normal file
16
app/views/photos/_item_photos.haml
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -2,6 +2,4 @@
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Show', @role
|
||||
\|
|
||||
= link_to 'Back', roles_path
|
||||
|
||||
@@ -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'
|
||||
|
||||
11
app/views/seeds/_actions.html.haml
Normal file
11
app/views/seeds/_actions.html.haml
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
54
db/migrate/20171129041341_create_photographings.rb
Normal file
54
db/migrate/20171129041341_create_photographings.rb
Normal 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
|
||||
14
db/schema.rb
14
db/schema.rb
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
20
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
41
spec/features/seeds/seed_photos.rb
Normal file
41
spec/features/seeds/seed_photos.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 => '')
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user