mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 09:19:15 -04:00
Compare commits
112 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ad171f37b | ||
|
|
06896dacd5 | ||
|
|
ff90d6430d | ||
|
|
4dbdbc4285 | ||
|
|
0f1c8e0658 | ||
|
|
c9ec116c9b | ||
|
|
e61c3f619b | ||
|
|
93b25a5c32 | ||
|
|
f7ca32d888 | ||
|
|
d57c46066a | ||
|
|
1e6cb2cfe4 | ||
|
|
67ae80056a | ||
|
|
13fa3c69e8 | ||
|
|
caad557b2a | ||
|
|
0f030d2c27 | ||
|
|
66d548c9c1 | ||
|
|
c168bb4a2b | ||
|
|
811db2961a | ||
|
|
42cea2ebde | ||
|
|
ccc5eb3c9a | ||
|
|
0e71a4fcb3 | ||
|
|
4ea681984f | ||
|
|
dadc5b96c6 | ||
|
|
787fca138b | ||
|
|
b820615081 | ||
|
|
812a6f5ec2 | ||
|
|
f1b42ec699 | ||
|
|
26c17ea19c | ||
|
|
acc75f80bf | ||
|
|
a79a65363f | ||
|
|
dfeb4804e7 | ||
|
|
9d20fafd06 | ||
|
|
e9a5ef0058 | ||
|
|
d2378376e4 | ||
|
|
4b1b5d8a18 | ||
|
|
a0770e80e7 | ||
|
|
f08e740ac6 | ||
|
|
5f23bcfad6 | ||
|
|
3cd7b86c99 | ||
|
|
bd53d4a271 | ||
|
|
16d88730ec | ||
|
|
5ad88eb6bd | ||
|
|
b617eb3140 | ||
|
|
acc4d3ad84 | ||
|
|
beb3f7e2b8 | ||
|
|
ab46a8dd96 | ||
|
|
b6b578d7e6 | ||
|
|
4d07cf80fa | ||
|
|
93f6b65d8d | ||
|
|
b40a6723e1 | ||
|
|
2058d28b37 | ||
|
|
682c6d6f5e | ||
|
|
2be55acc92 | ||
|
|
a9a040182c | ||
|
|
f39fe94173 | ||
|
|
976bdbbd96 | ||
|
|
cff1d8bfb9 | ||
|
|
bbdc54cb69 | ||
|
|
36f1f7b71a | ||
|
|
e1731793dd | ||
|
|
8ea3b27612 | ||
|
|
9469a69078 | ||
|
|
cc46fe3336 | ||
|
|
52b4064a2d | ||
|
|
d367b9ef21 | ||
|
|
4711e4669f | ||
|
|
3e55024f98 | ||
|
|
ccf56bf944 | ||
|
|
42e51a9cf6 | ||
|
|
667e0cc0e3 | ||
|
|
339830b3bb | ||
|
|
7770164672 | ||
|
|
f333607572 | ||
|
|
87d3764eeb | ||
|
|
faf487b719 | ||
|
|
53eb171dfc | ||
|
|
3dbf0df19e | ||
|
|
b0b6931678 | ||
|
|
cd272a6443 | ||
|
|
d515dba7f2 | ||
|
|
4958330c9e | ||
|
|
17236a4a8a | ||
|
|
936a8778ed | ||
|
|
3ccab3f857 | ||
|
|
0201e873eb | ||
|
|
20289e6566 | ||
|
|
85ded414ec | ||
|
|
299c95c5f5 | ||
|
|
8f51090098 | ||
|
|
5551eeba24 | ||
|
|
7a5a68f511 | ||
|
|
6d4ec9ad34 | ||
|
|
fffef75813 | ||
|
|
0e2d7b4393 | ||
|
|
f08068c289 | ||
|
|
ff653934ad | ||
|
|
c4bed2cf4d | ||
|
|
47c0f74f81 | ||
|
|
171e34914b | ||
|
|
8010a8b56c | ||
|
|
ac165ce0cd | ||
|
|
4925fde28f | ||
|
|
6580cf38b0 | ||
|
|
fdf10202ba | ||
|
|
85a368999b | ||
|
|
6ba4b4560e | ||
|
|
71aedb136a | ||
|
|
65c988790b | ||
|
|
0372d3b9b0 | ||
|
|
3272ea1ca5 | ||
|
|
5392d7d900 | ||
|
|
45f2abeab5 |
@@ -1,3 +1,9 @@
|
||||
linters:
|
||||
LineLength:
|
||||
max: 120
|
||||
InstanceVariables:
|
||||
enabled: false
|
||||
IdNames:
|
||||
enabled: false
|
||||
ConsecutiveComments:
|
||||
enabled: false
|
||||
|
||||
3
.mention-bot
Normal file
3
.mention-bot
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"userBlacklist": ["tygriffin","oshiho3"]
|
||||
}
|
||||
@@ -44,8 +44,6 @@ PreCommit:
|
||||
command: ['npm', 'run', 'csslint']
|
||||
HamlLint:
|
||||
enabled: true
|
||||
requires_files: true
|
||||
on_warn: fail
|
||||
command: ['bundle', 'exec', 'haml-lint', 'app/views']
|
||||
JsonSyntax:
|
||||
enabled: true
|
||||
|
||||
@@ -68,7 +68,6 @@ Rails/OutputSafety:
|
||||
# update_counters
|
||||
Rails/SkipsModelValidations:
|
||||
Exclude:
|
||||
- 'app/controllers/plantings_controller.rb'
|
||||
- 'db/seeds.rb'
|
||||
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
@@ -109,7 +108,6 @@ Style/BarePercentLiterals:
|
||||
# IgnoredMethods: lambda, proc, it
|
||||
Style/BlockDelimiters:
|
||||
Exclude:
|
||||
- 'app/controllers/members_controller.rb'
|
||||
- 'spec/controllers/order_items_controller_spec.rb'
|
||||
- 'spec/features/notifications_spec.rb'
|
||||
- 'spec/models/ability_spec.rb'
|
||||
@@ -123,7 +121,6 @@ Style/BlockDelimiters:
|
||||
# Cop supports --auto-correct.
|
||||
Style/BlockEndNewline:
|
||||
Exclude:
|
||||
- 'app/controllers/members_controller.rb'
|
||||
- 'spec/models/ability_spec.rb'
|
||||
- 'spec/models/member_spec.rb'
|
||||
- 'spec/models/planting_spec.rb'
|
||||
@@ -223,7 +220,6 @@ Style/MultilineTernaryOperator:
|
||||
# Cop supports --auto-correct.
|
||||
Style/MutableConstant:
|
||||
Exclude:
|
||||
- 'app/controllers/members_controller.rb'
|
||||
- 'app/models/planting.rb'
|
||||
|
||||
# Cop supports --auto-correct.
|
||||
@@ -231,10 +227,6 @@ Style/NegatedIf:
|
||||
Exclude:
|
||||
- 'app/helpers/crops_helper.rb'
|
||||
|
||||
Style/NestedTernaryOperator:
|
||||
Exclude:
|
||||
- 'app/controllers/plantings_controller.rb'
|
||||
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
||||
# SupportedStyles: skip_modifier_ifs, always
|
||||
|
||||
8
Gemfile
8
Gemfile
@@ -8,7 +8,7 @@ gem 'rails', '~> 4.2.7'
|
||||
gem 'bundler', '>=1.1.5'
|
||||
|
||||
gem 'coffee-rails', '~> 4.1.0'
|
||||
gem 'haml'
|
||||
gem 'haml', '~> 4.0.7'
|
||||
gem 'sass-rails', '~> 5.0.4'
|
||||
|
||||
# CSS framework
|
||||
@@ -85,8 +85,8 @@ gem "hashie", ">= 3.5.3"
|
||||
|
||||
gem 'rake', '>= 10.0.0'
|
||||
|
||||
# # CMS
|
||||
# gem 'comfortable_mexican_sofa', '~> 1.12.0'
|
||||
# locale based flash notices for controllers
|
||||
gem "responders"
|
||||
|
||||
group :production, :staging do
|
||||
gem 'bonsai-elasticsearch-rails' # Integration with Bonsa-Elasticsearch on heroku
|
||||
@@ -122,7 +122,7 @@ group :development, :test do
|
||||
gem 'factory_girl_rails' # for creating test data
|
||||
gem 'haml-i18n-extractor'
|
||||
gem 'haml-rails' # HTML templating language
|
||||
gem 'haml_lint', '~> 0.20.0' # Checks haml files for goodness
|
||||
gem 'haml_lint' # Checks haml files for goodness
|
||||
gem 'i18n-tasks' # adds tests for finding missing and unused translations
|
||||
gem 'jasmine' # javascript unit testing
|
||||
gem 'poltergeist' # for headless JS testing
|
||||
|
||||
128
Gemfile.lock
128
Gemfile.lock
@@ -25,14 +25,14 @@ GEM
|
||||
addressable
|
||||
active_merchant-paypal-bogus-gateway (0.1.0)
|
||||
activemerchant
|
||||
active_utils (3.3.1)
|
||||
active_utils (3.3.4)
|
||||
activesupport (>= 3.2, < 5.2.0)
|
||||
i18n
|
||||
activejob (4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
globalid (>= 0.3.0)
|
||||
activemerchant (1.64.0)
|
||||
activesupport (>= 3.2.14, < 5.1)
|
||||
activemerchant (1.66.0)
|
||||
activesupport (>= 3.2.14, < 6.x)
|
||||
builder (>= 2.1.2, < 4.0.0)
|
||||
i18n (>= 0.6.9)
|
||||
nokogiri (~> 1.4)
|
||||
@@ -52,7 +52,7 @@ GEM
|
||||
public_suffix (~> 2.0, >= 2.0.2)
|
||||
arel (6.0.4)
|
||||
ast (2.3.0)
|
||||
autoprefixer-rails (6.7.7.1)
|
||||
autoprefixer-rails (7.0.1)
|
||||
execjs
|
||||
bcrypt (3.1.11)
|
||||
better_errors (2.1.1)
|
||||
@@ -73,14 +73,14 @@ GEM
|
||||
bootstrap-sass (3.3.7)
|
||||
autoprefixer-rails (>= 5.2.1)
|
||||
sass (>= 3.3.4)
|
||||
bootstrap_form (2.6.0)
|
||||
bootstrap_form (2.7.0)
|
||||
builder (3.2.3)
|
||||
bullet (5.5.1)
|
||||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.10.0)
|
||||
byebug (9.0.6)
|
||||
cancancan (1.16.0)
|
||||
capybara (2.13.0)
|
||||
capybara (2.14.0)
|
||||
addressable
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
@@ -93,9 +93,9 @@ GEM
|
||||
capybara-screenshot (1.0.14)
|
||||
capybara (>= 1.0, < 3)
|
||||
launchy
|
||||
childprocess (0.6.3)
|
||||
childprocess (0.7.0)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
climate_control (0.1.0)
|
||||
climate_control (0.2.0)
|
||||
cliver (0.3.2)
|
||||
cocaine (0.5.8)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
@@ -140,7 +140,7 @@ GEM
|
||||
railties (>= 3.1)
|
||||
dalli (2.7.6)
|
||||
database_cleaner (1.5.3)
|
||||
debug_inspector (0.0.2)
|
||||
debug_inspector (0.0.3)
|
||||
devise (4.2.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
@@ -153,17 +153,17 @@ GEM
|
||||
json
|
||||
thread
|
||||
thread_safe
|
||||
elasticsearch (2.0.1)
|
||||
elasticsearch-api (= 2.0.1)
|
||||
elasticsearch-transport (= 2.0.1)
|
||||
elasticsearch-api (2.0.1)
|
||||
elasticsearch (2.0.2)
|
||||
elasticsearch-api (= 2.0.2)
|
||||
elasticsearch-transport (= 2.0.2)
|
||||
elasticsearch-api (2.0.2)
|
||||
multi_json
|
||||
elasticsearch-model (0.1.9)
|
||||
activesupport (> 3)
|
||||
elasticsearch (> 0.4)
|
||||
hashie
|
||||
elasticsearch-rails (0.1.9)
|
||||
elasticsearch-transport (2.0.1)
|
||||
elasticsearch-transport (2.0.2)
|
||||
faraday
|
||||
multi_json
|
||||
erubis (2.7.0)
|
||||
@@ -189,8 +189,8 @@ GEM
|
||||
gibbon (1.2.1)
|
||||
httparty
|
||||
multi_json (>= 1.9.0)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
globalid (0.4.0)
|
||||
activesupport (>= 4.2.0)
|
||||
gravatar-ultimate (2.0.0)
|
||||
activesupport (>= 2.3.14)
|
||||
rack
|
||||
@@ -216,14 +216,15 @@ GEM
|
||||
highline
|
||||
tilt
|
||||
trollop (= 1.16.2)
|
||||
haml-rails (0.9.0)
|
||||
haml-rails (1.0.0)
|
||||
actionpack (>= 4.0.1)
|
||||
activesupport (>= 4.0.1)
|
||||
haml (>= 4.0.6, < 5.0)
|
||||
haml (>= 4.0.6, < 6.0)
|
||||
html2haml (>= 1.0.1)
|
||||
railties (>= 4.0.1)
|
||||
haml_lint (0.20.0)
|
||||
haml (~> 4.0)
|
||||
haml_lint (0.25.1)
|
||||
haml (>= 4.0, < 5.1)
|
||||
rainbow
|
||||
rake (>= 10, < 13)
|
||||
rubocop (>= 0.47.0)
|
||||
sysexits (~> 1.1)
|
||||
@@ -232,12 +233,12 @@ GEM
|
||||
excon (~> 0.45)
|
||||
multi_json (~> 1.8)
|
||||
highline (1.7.8)
|
||||
html2haml (2.1.0)
|
||||
html2haml (2.2.0)
|
||||
erubis (~> 2.7.0)
|
||||
haml (~> 4.0)
|
||||
haml (>= 4.0, < 6)
|
||||
nokogiri (>= 1.6.0)
|
||||
ruby_parser (~> 3.5)
|
||||
httparty (0.14.0)
|
||||
httparty (0.15.2)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (0.8.1)
|
||||
i18n-tasks (0.9.12)
|
||||
@@ -250,12 +251,12 @@ GEM
|
||||
parser (>= 2.2.3.0)
|
||||
term-ansicolor (>= 1.3.2)
|
||||
terminal-table (>= 1.5.1)
|
||||
jasmine (2.5.2)
|
||||
jasmine-core (>= 2.5.1, < 3.0.0)
|
||||
jasmine (2.6.0)
|
||||
jasmine-core (>= 2.6.0, < 3.0.0)
|
||||
phantomjs
|
||||
rack (>= 1.2.1)
|
||||
rake
|
||||
jasmine-core (2.5.2)
|
||||
jasmine-core (2.6.1)
|
||||
jquery-rails (4.3.1)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
@@ -265,7 +266,7 @@ GEM
|
||||
js-routes (1.3.3)
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
json (2.0.3)
|
||||
json (2.1.0)
|
||||
jwt (1.5.6)
|
||||
kaminari (0.17.0)
|
||||
actionpack (>= 3.0.0)
|
||||
@@ -285,8 +286,8 @@ GEM
|
||||
ruby_dep (~> 1.2)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
lumberjack (1.0.11)
|
||||
mail (2.6.4)
|
||||
lumberjack (1.0.12)
|
||||
mail (2.6.5)
|
||||
mime-types (>= 1.16, < 4)
|
||||
memcachier (0.0.2)
|
||||
method_source (0.8.2)
|
||||
@@ -295,13 +296,13 @@ GEM
|
||||
mime-types-data (3.2016.0521)
|
||||
mimemagic (0.3.2)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.10.1)
|
||||
minitest (5.10.2)
|
||||
multi_json (1.11.3)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nenv (0.3.0)
|
||||
newrelic_rpm (4.0.0.332)
|
||||
nokogiri (1.7.1)
|
||||
newrelic_rpm (4.1.0.333)
|
||||
nokogiri (1.7.2)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
notiffany (0.1.1)
|
||||
nenv (~> 0.1)
|
||||
@@ -343,7 +344,7 @@ GEM
|
||||
phantomjs (2.1.1.0)
|
||||
plupload-rails (1.2.1)
|
||||
rails (>= 3.1)
|
||||
poltergeist (1.14.0)
|
||||
poltergeist (1.15.0)
|
||||
capybara (~> 2.1)
|
||||
cliver (~> 0.3.1)
|
||||
websocket-driver (>= 0.2.0)
|
||||
@@ -355,8 +356,8 @@ GEM
|
||||
public_suffix (2.0.5)
|
||||
quiet_assets (1.1.0)
|
||||
railties (>= 3.1, < 5.0)
|
||||
rack (1.6.5)
|
||||
rack-protection (1.5.3)
|
||||
rack (1.6.6)
|
||||
rack-protection (2.0.0)
|
||||
rack
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
@@ -399,33 +400,34 @@ GEM
|
||||
rb-inotify (0.9.8)
|
||||
ffi (>= 0.5.0)
|
||||
redis (3.3.3)
|
||||
responders (2.3.0)
|
||||
railties (>= 4.2.0, < 5.1)
|
||||
rspec (3.5.0)
|
||||
rspec-core (~> 3.5.0)
|
||||
rspec-expectations (~> 3.5.0)
|
||||
rspec-mocks (~> 3.5.0)
|
||||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
railties (>= 4.2.0, < 5.3)
|
||||
rspec (3.6.0)
|
||||
rspec-core (~> 3.6.0)
|
||||
rspec-expectations (~> 3.6.0)
|
||||
rspec-mocks (~> 3.6.0)
|
||||
rspec-activemodel-mocks (1.0.3)
|
||||
activemodel (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
rspec-mocks (>= 2.99, < 4.0)
|
||||
rspec-core (3.5.4)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-expectations (3.5.0)
|
||||
rspec-core (3.6.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-expectations (3.6.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-mocks (3.5.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-mocks (3.6.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-rails (3.5.2)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-rails (3.6.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.5.0)
|
||||
rspec-expectations (~> 3.5.0)
|
||||
rspec-mocks (~> 3.5.0)
|
||||
rspec-support (~> 3.5.0)
|
||||
rspec-support (3.5.0)
|
||||
rspec-core (~> 3.6.0)
|
||||
rspec-expectations (~> 3.6.0)
|
||||
rspec-mocks (~> 3.6.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-support (3.6.0)
|
||||
rubocop (0.47.1)
|
||||
parser (>= 2.3.3.1, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
@@ -435,7 +437,7 @@ GEM
|
||||
ruby-progressbar (1.8.1)
|
||||
ruby-units (2.1.0)
|
||||
ruby_dep (1.5.0)
|
||||
ruby_parser (3.8.4)
|
||||
ruby_parser (3.9.0)
|
||||
sexp_processor (~> 4.1)
|
||||
rubyzip (1.2.1)
|
||||
sass (3.4.23)
|
||||
@@ -445,17 +447,17 @@ GEM
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
selenium-webdriver (3.3.0)
|
||||
selenium-webdriver (3.4.0)
|
||||
childprocess (~> 0.5)
|
||||
rubyzip (~> 1.0)
|
||||
websocket (~> 1.0)
|
||||
sexp_processor (4.8.0)
|
||||
sexp_processor (4.9.0)
|
||||
shellany (0.0.1)
|
||||
sidekiq (4.2.10)
|
||||
sidekiq (5.0.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
connection_pool (~> 2.2, >= 2.2.0)
|
||||
rack-protection (>= 1.5.0)
|
||||
redis (~> 3.2, >= 3.2.1)
|
||||
redis (~> 3.3, >= 3.3.3)
|
||||
simplecov (0.12.0)
|
||||
docile (~> 1.1.0)
|
||||
json (>= 1.8, < 3)
|
||||
@@ -472,7 +474,7 @@ GEM
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sysexits (1.2.0)
|
||||
term-ansicolor (1.5.0)
|
||||
term-ansicolor (1.6.0)
|
||||
tins (~> 1.0)
|
||||
terminal-table (1.7.3)
|
||||
unicode-display_width (~> 1.1.1)
|
||||
@@ -488,7 +490,7 @@ GEM
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
unicode-display_width (1.1.3)
|
||||
unicorn (5.2.0)
|
||||
unicorn (5.3.0)
|
||||
kgio (~> 2.6)
|
||||
raindrops (~> 0.7)
|
||||
uniform_notifier (1.10.0)
|
||||
@@ -549,10 +551,10 @@ DEPENDENCIES
|
||||
gravatar-ultimate
|
||||
guard
|
||||
guard-rspec
|
||||
haml
|
||||
haml (~> 4.0.7)
|
||||
haml-i18n-extractor
|
||||
haml-rails
|
||||
haml_lint (~> 0.20.0)
|
||||
haml_lint
|
||||
hashie (>= 3.5.3)
|
||||
heroku-api
|
||||
i18n-tasks
|
||||
@@ -578,6 +580,7 @@ DEPENDENCIES
|
||||
rails_12factor
|
||||
rainbow (< 2.2.0)
|
||||
rake (>= 10.0.0)
|
||||
responders
|
||||
rspec-activemodel-mocks
|
||||
rspec-rails
|
||||
rubocop (<= 0.47.1)
|
||||
@@ -591,6 +594,7 @@ DEPENDENCIES
|
||||
webrat
|
||||
will_paginate (~> 3.0)
|
||||
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.3.4p301
|
||||
|
||||
|
||||
@@ -108,8 +108,6 @@ p.stats
|
||||
|
||||
.planting
|
||||
dl.planting-attributes
|
||||
font-size: 85%
|
||||
|
||||
dt
|
||||
text-align: left
|
||||
dd
|
||||
@@ -118,14 +116,13 @@ p.stats
|
||||
@media (min-width: $screen-md-min)
|
||||
.planting-thumbnail
|
||||
dl.planting-attributes
|
||||
font-size: 85%
|
||||
width: 100%
|
||||
|
||||
dt
|
||||
text-align: left
|
||||
width: 80px
|
||||
width: 120px
|
||||
dd
|
||||
padding-left: 80px
|
||||
padding-left: 120px
|
||||
margin-left: auto
|
||||
|
||||
.navbar .navbar-form
|
||||
@@ -333,3 +330,10 @@ $state-success-bg: lighten($green, 50%)
|
||||
overflow: hidden
|
||||
text-overflow: ellipsis
|
||||
white-space: nowrap
|
||||
|
||||
ul.plantings
|
||||
list-style-type: none
|
||||
|
||||
ul.thumbnail-buttons
|
||||
list-style-type: none
|
||||
text-align: right
|
||||
|
||||
@@ -14,13 +14,13 @@ class MembersController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.haml
|
||||
format.json {
|
||||
format.json do
|
||||
render json: @members.to_json(only: [
|
||||
:id, :login_name,
|
||||
:slug, :bio, :created_at,
|
||||
:location, :latitude, :longitude
|
||||
])
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,18 +38,19 @@ class MembersController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.haml
|
||||
format.json {
|
||||
format.json do
|
||||
render json: @member.to_json(only: [
|
||||
:id, :login_name, :bio,
|
||||
:created_at, :slug, :location,
|
||||
:latitude, :longitude
|
||||
])
|
||||
}
|
||||
format.rss {
|
||||
end
|
||||
format.rss do
|
||||
render(
|
||||
layout: false,
|
||||
locals: { member: @member }
|
||||
)}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,7 +67,7 @@ class MembersController < ApplicationController
|
||||
EMAIL_TYPE_STRING = {
|
||||
send_notification_email: "direct message notifications",
|
||||
send_planting_reminder: "planting reminders"
|
||||
}
|
||||
}.freeze
|
||||
|
||||
def unsubscribe
|
||||
verifier = ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN'])
|
||||
|
||||
13
app/controllers/photo_associations_controller.rb
Normal file
13
app/controllers/photo_associations_controller.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class PhotoAssociationsController < ApplicationController
|
||||
before_action :authenticate_member!
|
||||
respond_to :json, :html
|
||||
|
||||
def destroy
|
||||
@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)
|
||||
respond_with(@photo)
|
||||
end
|
||||
end
|
||||
@@ -1,126 +1,81 @@
|
||||
class PlantingsController < ApplicationController
|
||||
before_action :authenticate_member!, except: [:index, :show]
|
||||
after_action :expire_homepage, only: [:create, :update, :destroy]
|
||||
load_and_authorize_resource
|
||||
|
||||
# GET /plantings
|
||||
# GET /plantings.json
|
||||
respond_to :html, :json
|
||||
respond_to :csv, :rss, only: [:index]
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@owner = Member.find_by(slug: params[:owner]) if params[:owner]
|
||||
@crop = Crop.find_by(slug: params[:crop]) if params[:crop]
|
||||
@show_all = params[:all] == '1'
|
||||
@plantings = plantings
|
||||
|
||||
respond_to do |format|
|
||||
format.html { @plantings = @plantings.paginate(page: params[:page]) }
|
||||
format.json { render json: @plantings }
|
||||
format.rss { render layout: false } # index.rss.builder
|
||||
format.csv do
|
||||
specifics = (@owner ? "#{@owner.login_name}-" : @crop ? "#{@crop.name}-" : nil)
|
||||
@filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv"
|
||||
render csv: @plantings
|
||||
end
|
||||
end
|
||||
@plantings = plantings.paginate(page: params[:page])
|
||||
|
||||
specifics = if @owner
|
||||
"#{@owner.login_name}-"
|
||||
elsif @crop
|
||||
"#{@crop.name}-"
|
||||
end
|
||||
|
||||
@filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv"
|
||||
|
||||
respond_with(@plantings)
|
||||
end
|
||||
|
||||
# GET /plantings/1
|
||||
# GET /plantings/1.json
|
||||
def show
|
||||
@planting = Planting.includes(:owner, :crop, :garden, :photos).friendly.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @planting }
|
||||
end
|
||||
@planting = Planting.includes(:owner, :crop, :garden, :photos)
|
||||
.friendly
|
||||
.find(params[:id])
|
||||
respond_with(@planting)
|
||||
end
|
||||
|
||||
# GET /plantings/new
|
||||
# GET /plantings/new.json
|
||||
def new
|
||||
@planting = Planting.new('planted_at' => Time.zone.today)
|
||||
@planting = Planting.new(planted_at: Time.zone.today)
|
||||
|
||||
# using find_by_id here because it returns nil, unlike find
|
||||
@crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new
|
||||
@garden = Garden.find_by(owner: current_member, id: params[:garden_id]) || Garden.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @planting }
|
||||
end
|
||||
respond_with(@planting)
|
||||
end
|
||||
|
||||
# GET /plantings/1/edit
|
||||
def edit
|
||||
# the following are needed to display the form but aren't used
|
||||
@crop = Crop.new
|
||||
@garden = Garden.new
|
||||
end
|
||||
|
||||
# POST /plantings
|
||||
# POST /plantings.json
|
||||
def create
|
||||
params[:planted_at] = parse_date(params[:planted_at])
|
||||
@planting = Planting.new(planting_params)
|
||||
@planting.owner = current_member
|
||||
|
||||
respond_to do |format|
|
||||
if @planting.save
|
||||
@planting.update_attribute(:days_before_maturity,
|
||||
update_days_before_maturity(@planting, planting_params[:crop_id]))
|
||||
format.html { redirect_to @planting, notice: 'Planting was successfully created.' }
|
||||
format.json { render json: @planting, status: :created, location: @planting }
|
||||
expire_fragment("homepage_stats")
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @planting.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
@planting.calc_and_set_days_before_maturity
|
||||
@planting.save
|
||||
respond_with(@planting)
|
||||
end
|
||||
|
||||
# PUT /plantings/1
|
||||
# PUT /plantings/1.json
|
||||
def update
|
||||
params[:planted_at] = parse_date(params[:planted_at])
|
||||
|
||||
respond_to do |format|
|
||||
if @planting.update(planting_params)
|
||||
@planting.update_attribute(:days_before_maturity,
|
||||
update_days_before_maturity(@planting, planting_params[:crop_id]))
|
||||
format.html { redirect_to @planting, notice: 'Planting was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @planting.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
@planting.calc_and_set_days_before_maturity
|
||||
@planting.update(planting_params)
|
||||
respond_with(@planting)
|
||||
end
|
||||
|
||||
# DELETE /plantings/1
|
||||
# DELETE /plantings/1.json
|
||||
def destroy
|
||||
@garden = @planting.garden
|
||||
@planting.destroy
|
||||
expire_fragment("homepage_stats")
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @garden }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
respond_with(@planting.garden)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def planting_params
|
||||
params.require(:planting).permit(:crop_id, :description, :garden_id, :planted_at,
|
||||
:quantity, :sunniness, :planted_from, :owner_id, :finished,
|
||||
:finished_at)
|
||||
end
|
||||
|
||||
def update_days_before_maturity(planting, crop_id)
|
||||
if planting.finished_at.nil?
|
||||
planting.calculate_days_before_maturity(planting, crop_id)
|
||||
else
|
||||
(planting.finished_at - planting.planted_at).to_i
|
||||
end
|
||||
params[:planted_at] = parse_date(params[:planted_at]) if params[:planted_at]
|
||||
params.require(:planting).permit(
|
||||
:crop_id, :description, :garden_id, :planted_at,
|
||||
:quantity, :sunniness, :planted_from, :finished,
|
||||
:finished_at
|
||||
)
|
||||
end
|
||||
|
||||
def plantings
|
||||
|
||||
@@ -21,13 +21,14 @@ module GardensHelper
|
||||
if plantings.blank?
|
||||
"None"
|
||||
else
|
||||
output = ""
|
||||
plantings.first(2).each do |planting|
|
||||
output = '<ul class="plantings">'
|
||||
plantings.each do |planting|
|
||||
output += "<li>"
|
||||
output += planting.quantity.nil? ? "0 " : "#{planting.quantity} "
|
||||
output += link_to planting.crop.name, planting.crop
|
||||
output += ", planted on #{planting.planted_at}</li>"
|
||||
end
|
||||
output += '</ul>'
|
||||
output.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Garden < ActiveRecord::Base
|
||||
include PhotoCapable
|
||||
friendly_id :garden_slug, use: [:slugged, :finders]
|
||||
|
||||
belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id'
|
||||
belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id', counter_cache: true
|
||||
has_many :plantings, -> { order(created_at: :desc) }, dependent: :destroy
|
||||
has_many :crops, through: :plantings
|
||||
|
||||
@@ -62,7 +62,7 @@ class Garden < ActiveRecord::Base
|
||||
unique_plantings = []
|
||||
seen_crops = []
|
||||
|
||||
plantings.each do |p|
|
||||
plantings.includes(:garden, :crop, :owner, :harvests).each do |p|
|
||||
unless seen_crops.include?(p.crop)
|
||||
unique_plantings.push(p)
|
||||
seen_crops.push(p.crop)
|
||||
|
||||
@@ -5,7 +5,7 @@ class Harvest < ActiveRecord::Base
|
||||
friendly_id :harvest_slug, use: [:slugged, :finders]
|
||||
|
||||
belongs_to :crop
|
||||
belongs_to :owner, class_name: 'Member'
|
||||
belongs_to :owner, class_name: 'Member', counter_cache: true
|
||||
belongs_to :plant_part
|
||||
belongs_to :planting
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class Member < ActiveRecord::Base
|
||||
.has_plantings
|
||||
}
|
||||
|
||||
scope :has_plantings, -> { joins(:plantings).where("plantings.id IS NOT NULL") }
|
||||
scope :has_plantings, -> { joins(:plantings).group("members.id") }
|
||||
|
||||
has_many :follows, class_name: "Follow", foreign_key: "follower_id"
|
||||
has_many :followed, through: :follows
|
||||
|
||||
@@ -10,6 +10,10 @@ class Photo < ActiveRecord::Base
|
||||
|
||||
default_scope { order("created_at desc") }
|
||||
|
||||
def associations?
|
||||
plantings.any? || harvests.any? || gardens.any? || seeds.any?
|
||||
end
|
||||
|
||||
def all_associations
|
||||
associations = []
|
||||
Growstuff::Constants::PhotoModels.relations.each do |association_name|
|
||||
@@ -30,7 +34,7 @@ class Photo < ActiveRecord::Base
|
||||
licenses = flickr.photos.licenses.getInfo
|
||||
license = licenses.find { |l| l.id == info.license }
|
||||
{
|
||||
title: info.title || "Untitled",
|
||||
title: calculate_title(info),
|
||||
license_name: license.name,
|
||||
license_url: license.url,
|
||||
thumbnail_url: FlickRaw.url_q(info),
|
||||
@@ -39,6 +43,16 @@ class Photo < ActiveRecord::Base
|
||||
}
|
||||
end
|
||||
|
||||
def calculate_title(info)
|
||||
if id && title # already has a title saved
|
||||
title
|
||||
elsif info.title # use title from flickr
|
||||
info.title
|
||||
else
|
||||
'untitled'
|
||||
end
|
||||
end
|
||||
|
||||
def set_flickr_metadata
|
||||
update_attributes(flickr_metadata)
|
||||
end
|
||||
|
||||
@@ -27,9 +27,9 @@ class Planting < ActiveRecord::Base
|
||||
to: :crop,
|
||||
prefix: true
|
||||
|
||||
validates :crop, approved: true
|
||||
|
||||
validates :crop, presence: { message: "must be present and exist in our database" }
|
||||
validates :garden, presence: true
|
||||
validates :crop, presence: true
|
||||
validates :crop, approved: { message: "must be present and exist in our database" }
|
||||
|
||||
validates :quantity,
|
||||
numericality: {
|
||||
@@ -92,21 +92,6 @@ class Planting < ActiveRecord::Base
|
||||
photos.first
|
||||
end
|
||||
|
||||
def calculate_days_before_maturity(planting, crop)
|
||||
p_crop = Planting.where(crop_id: crop).where.not(id: planting)
|
||||
differences = p_crop.collect do |p|
|
||||
if p.finished && !p.finished_at.nil?
|
||||
(p.finished_at - p.planted_at).to_i
|
||||
end
|
||||
end
|
||||
|
||||
if differences.compact.empty?
|
||||
nil
|
||||
else
|
||||
differences.compact.sum / differences.compact.size
|
||||
end
|
||||
end
|
||||
|
||||
def planted?(current_date = Date.current)
|
||||
planted_at.present? && current_date.to_date >= planted_at
|
||||
end
|
||||
@@ -137,4 +122,29 @@ class Planting < ActiveRecord::Base
|
||||
|
||||
percent
|
||||
end
|
||||
|
||||
def start_to_finish_diff
|
||||
(finished_at - planted_at).to_i
|
||||
end
|
||||
|
||||
def self.mean_days_until_maturity(plantings)
|
||||
## Given a set of finished plantings, calculate the average/mean time from start to finish
|
||||
differences = plantings.collect(&:start_to_finish_diff)
|
||||
differences.compact.sum / differences.compact.size unless differences.compact.empty?
|
||||
end
|
||||
|
||||
def calc_and_set_days_before_maturity
|
||||
# calculate the number of days, from planted_at, until maturity
|
||||
if planted_at && finished_at
|
||||
self.days_before_maturity = start_to_finish_diff
|
||||
else
|
||||
self.days_before_maturity = Planting.mean_days_until_maturity other_finished_plantings_same_crop
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def other_finished_plantings_same_crop
|
||||
Planting.where(crop_id: crop).where.not(id: id).where.not(finished_at: nil)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Seed < ActiveRecord::Base
|
||||
friendly_id :seed_slug, use: [:slugged, :finders]
|
||||
|
||||
belongs_to :crop
|
||||
belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id'
|
||||
belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id', counter_cache: true
|
||||
|
||||
default_scope { order("created_at desc") }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.panel.panel-success
|
||||
.panel-heading
|
||||
%h3.panel-title
|
||||
= link_to display_garden_name(garden), garden
|
||||
= link_to display_garden_name(garden), garden_path(garden)
|
||||
- if can? :edit, garden
|
||||
%a.pull-right{ href: edit_garden_path(garden), role: "button", id: "edit_garden_glyphicon" }
|
||||
%span.glyphicon.glyphicon-pencil{ title: "Edit" }
|
||||
@@ -14,7 +14,7 @@
|
||||
.col-md-8
|
||||
%dl.dl-horizontal
|
||||
%dt Name :
|
||||
%dd= link_to display_garden_name(garden), garden
|
||||
%dd= link_to display_garden_name(garden), garden_path(garden)
|
||||
%dt Location :
|
||||
%dd
|
||||
- if garden.location.blank?
|
||||
@@ -29,11 +29,9 @@
|
||||
%b
|
||||
= localize_plural(garden.plantings, Planting)
|
||||
= ":"
|
||||
= display_garden_plantings(garden.plantings.current)
|
||||
= display_garden_plantings(garden.plantings.current.includes(:crop).first(2))
|
||||
- if garden.plantings.size > 2
|
||||
%br
|
||||
= link_to "See more plantings >>", garden_path(garden)
|
||||
.panel-footer
|
||||
%dt Description
|
||||
%dd
|
||||
= display_garden_description(garden)
|
||||
%dd= display_garden_description(garden)
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
%p.btn-group
|
||||
- if can? :edit, @garden
|
||||
- if @garden.active
|
||||
= link_to "Plant something", new_planting_path(garden_id: @garden.id), class: 'btn btn-primary'
|
||||
= link_to new_planting_path(garden_id: @garden.id), class: 'btn btn-primary' do
|
||||
%span.glyphicon.glyphicon-grain{ title: "Plant" }
|
||||
Plant something
|
||||
= link_to "Mark as inactive", garden_path(@garden, garden: { active: 0 }),
|
||||
method: :put, class: 'btn btn-default',
|
||||
data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' }
|
||||
@@ -23,12 +25,14 @@
|
||||
= link_to "Mark as active", garden_path(@garden, garden: { active: 1 }),
|
||||
method: :put,
|
||||
class: 'btn btn-default'
|
||||
= link_to 'Edit garden', edit_garden_path(@garden), class: 'btn btn-default'
|
||||
= link_to edit_garden_path(@garden), class: 'btn btn-default', id: 'edit_garden_link' do
|
||||
%span.glyphicon.glyphicon-pencil{ title: "Edit garden" }
|
||||
- if can?(:destroy, @garden)
|
||||
= link_to 'Delete garden', @garden,
|
||||
= link_to @garden,
|
||||
method: :delete,
|
||||
data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' },
|
||||
class: 'btn btn-default'
|
||||
class: 'btn btn-default', id: 'delete_garden_link' do
|
||||
%span.glyphicon.glyphicon-trash{ title: "Delete" }
|
||||
|
||||
- unless @garden.active
|
||||
.alert.alert-warning
|
||||
@@ -49,35 +53,23 @@
|
||||
Why not
|
||||
= link_to 'tell us more.', edit_garden_path(@garden)
|
||||
|
||||
- if !@garden.photos.empty? || (can?(:edit, @garden) && can?(:create, Photo))
|
||||
.row-fluid
|
||||
%h3 Photos
|
||||
%p= localize_plural(@garden.photos, Photo)
|
||||
.row-fluid
|
||||
%ul.thumbnails
|
||||
- @garden.photos.each do |p|
|
||||
.col-md-2.six-across
|
||||
= render partial: 'photos/thumbnail', locals: { photo: p }
|
||||
.row-fluid
|
||||
- if can?(:create, Photo) && can?(:edit, @garden)
|
||||
%p
|
||||
= link_to "Add photo", new_photo_path(type: "garden", id: @garden.id), class: 'btn btn-primary'
|
||||
|
||||
.row-fluid
|
||||
%h3 What's planted here?
|
||||
- if @garden.plantings.current.empty?
|
||||
%p Nothing is currently planted here.
|
||||
%h3 What's planted here?
|
||||
.row
|
||||
- if @garden.plantings.size.positive?
|
||||
- @garden.plantings.current.includes(:crop, :owner, :garden).each do |planting|
|
||||
.col-xs-12.col-md-6
|
||||
= render partial: "plantings/thumbnail", locals: { planting: planting }
|
||||
- else
|
||||
- @garden.plantings.current.each.with_index do |planting_current, _|
|
||||
= render partial: "plantings/thumbnail", locals: { planting: planting_current }
|
||||
|
||||
.row-fluid
|
||||
%h3 Previously planted in this garden
|
||||
- if @garden.plantings.finished.empty?
|
||||
%p Nothing has been planted here.
|
||||
- else
|
||||
- @garden.plantings.finished.each.with_index do |planting_finished|
|
||||
= render partial: "plantings/thumbnail", locals: { planting: planting_finished }
|
||||
.col-md-12
|
||||
%p Nothing is currently planted here.
|
||||
%h3 Previously planted in this garden
|
||||
- if @garden.plantings.finished.size.positive?
|
||||
.row
|
||||
- @garden.plantings.finished.includes(:crop, :owner, :garden).each do |planting|
|
||||
.col-xs-12.col-md-6
|
||||
= render partial: "plantings/thumbnail", locals: { planting: planting }
|
||||
- else
|
||||
%p Nothing has been planted here.
|
||||
.col-md-3
|
||||
%h4 About this garden
|
||||
%p
|
||||
@@ -107,9 +99,24 @@
|
||||
- @garden.owner.gardens.inactive.each do |othergarden|
|
||||
%li
|
||||
- if @garden == othergarden
|
||||
= @garden
|
||||
= @garden.name
|
||||
- else
|
||||
= link_to othergarden, garden_path(othergarden)
|
||||
|
||||
- if @garden.owner == current_member
|
||||
= link_to 'Add New Garden', new_garden_path, class: 'btn btn-default btn-xs'
|
||||
%p
|
||||
= link_to new_garden_path, class: 'btn btn-default btn-xs' do
|
||||
Add New Garden
|
||||
|
||||
- if can?(:edit, @garden) && can?(:create, Photo)
|
||||
%p
|
||||
= link_to new_photo_path(type: "garden", id: @garden.id),
|
||||
class: 'btn btn-primary' do
|
||||
%span.glyphicon.glyphicon-camera{ title: "Add Photo" }
|
||||
Add Photo
|
||||
- if @garden.photos.size.positive?
|
||||
%h3= localize_plural(@garden.photos, Photo)
|
||||
.row
|
||||
- @garden.photos.includes(:owner).each do |photo|
|
||||
.col-xs-6
|
||||
= render partial: 'photos/thumbnail', locals: { photo: photo }
|
||||
@@ -36,7 +36,7 @@
|
||||
%p= localize_plural(g.photos, Photo)
|
||||
.row
|
||||
%ul.thumbnails
|
||||
- g.photos.each do |p|
|
||||
- g.photos.includes(:owner).each do |p|
|
||||
.col-md-2.six-across
|
||||
= render partial: 'photos/thumbnail', locals: { photo: p }
|
||||
.row
|
||||
|
||||
4
app/views/photos/_photo_association_delete.haml
Normal file
4
app/views/photos/_photo_association_delete.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
- if can? :edit, photo
|
||||
= link_to photo_associations_path(photo_id: photo.id, type: type, id: thing.id),
|
||||
method: 'delete', class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-remove{ title: "Remove link" }
|
||||
21
app/views/photos/_photo_associations.html.haml
Normal file
21
app/views/photos/_photo_associations.html.haml
Normal file
@@ -0,0 +1,21 @@
|
||||
%h4 This photo depicts:
|
||||
%ul
|
||||
- @photo.plantings.each do |planting|
|
||||
%li
|
||||
= link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting)
|
||||
= render partial: "photo_association_delete", locals: { photo: @photo, type: 'planting', thing: planting }
|
||||
|
||||
- @photo.harvests.each do |harvest|
|
||||
%li
|
||||
= link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest)
|
||||
= render partial: "photo_association_delete", locals: { photo: @photo, type: 'harvest', thing: harvest }
|
||||
|
||||
- @photo.gardens.each do |garden|
|
||||
%li
|
||||
= link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden)
|
||||
= render partial: "photo_association_delete", locals: { photo: @photo, type: 'garden', thing: garden }
|
||||
|
||||
- @photo.seeds.each do |seed|
|
||||
%li
|
||||
= link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed)
|
||||
= render partial: "photo_association_delete", locals: { photo: @photo, type: 'seed', thing: seed }
|
||||
@@ -1,2 +1,5 @@
|
||||
- content_for :title, "Edit Photo"
|
||||
|
||||
= form_for(@photo) do |f|
|
||||
= f.label :title
|
||||
= f.text_field :title, placeholder: "title"
|
||||
= f.submit
|
||||
|
||||
@@ -36,5 +36,5 @@
|
||||
- else
|
||||
.alert
|
||||
You must
|
||||
= link_to "connect your account to Flickr", '/auth/flickr'
|
||||
= link_to "connect your account to Flickr", '/members/auth/flickr'
|
||||
to add photos.
|
||||
|
||||
@@ -8,7 +8,19 @@
|
||||
= tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
|
||||
|
||||
.row
|
||||
.col-md-6
|
||||
.col-md-8
|
||||
%p= image_tag(@photo.fullsize_url, alt: @photo.title, class: 'img img-responsive')
|
||||
|
||||
.col-md-4
|
||||
%p
|
||||
- if can? :destroy, @photo
|
||||
= link_to @photo, method: :delete,
|
||||
data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-trash{ title: "Delete" }
|
||||
|
||||
- if can? :edit, @photo
|
||||
= link_to edit_photo_path(@photo), class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-pencil{ title: "Edit" }
|
||||
%p
|
||||
%strong Posted by:
|
||||
= link_to @photo.owner, @photo.owner
|
||||
@@ -19,30 +31,7 @@
|
||||
- else
|
||||
= succeed "." do
|
||||
= @photo.license_name
|
||||
%p
|
||||
= link_to "View on Flickr", @photo.link_url
|
||||
|
||||
- if can? :destroy, @photo
|
||||
%p= link_to 'Delete Photo',
|
||||
@photo,
|
||||
method: :delete,
|
||||
data: { confirm: 'Are you sure?' },
|
||||
class: 'btn btn-default btn-xs'
|
||||
|
||||
.col-md-6
|
||||
- unless @photo.plantings.empty? && @photo.harvests.empty? && @photo.gardens.empty? && @photo.seeds.empty?
|
||||
%p This photo depicts:
|
||||
%ul
|
||||
- @photo.plantings.each do |p|
|
||||
%li= link_to t('.planting', planting: p.to_s, owner: p.owner.to_s), planting_path(p)
|
||||
- @photo.harvests.each do |h|
|
||||
%li= link_to t('.harvest', crop: h.crop.name, owner: h.owner.to_s), harvest_path(h)
|
||||
- @photo.gardens.each do |g|
|
||||
%li= link_to t('.garden', garden: g.to_s, owner: g.owner.to_s), garden_path(g)
|
||||
- @photo.seeds.each do |s|
|
||||
%li= link_to t('.seed', seed: s.to_s, owner: s.owner.to_s), seed_path(s)
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
%p= image_tag(@photo.fullsize_url, alt: @photo.title, class: 'img')
|
||||
|
||||
%p= link_to "View on Flickr", @photo.link_url
|
||||
- if @photo.associations?
|
||||
= render "photo_associations", locals: { photo: @photo }
|
||||
|
||||
@@ -45,10 +45,8 @@
|
||||
- plantings.first(10).each.with_index do |planting, index|
|
||||
.col-xs-12.col-lg-6
|
||||
= render partial: "plantings/thumbnail", locals: { planting: planting, index: index }
|
||||
.row
|
||||
= link_to "View all plantings >>", plantings_path
|
||||
= link_to "View all plantings >>", plantings_path
|
||||
- else
|
||||
.row
|
||||
%p No nearby plantings found
|
||||
%p No nearby plantings found
|
||||
- else
|
||||
%p No results found
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- if planting.harvests
|
||||
- unless planting.harvests.empty?
|
||||
Harvests:
|
||||
%ul
|
||||
- planting.harvests.each do |harvest|
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
.panel.panel-success.planting-thumbnail
|
||||
.panel-heading
|
||||
%h3.panel-title= link_to planting.crop.name, planting.crop
|
||||
%h3.panel-title= link_to planting.crop.name, planting_path(planting)
|
||||
.panel-body
|
||||
.row
|
||||
.col-xs-12.col-md-4
|
||||
.col-xs-12.col-md-5
|
||||
= link_to image_tag((planting.default_photo ? planting.default_photo.thumbnail_url : 'placeholder_150.png'),
|
||||
alt: planting.crop_id, class: 'img'),
|
||||
alt: planting.crop_id, class: 'img img-responsive'),
|
||||
planting
|
||||
.col-xs-7.col-md-5
|
||||
.col-xs-12.col-md-7
|
||||
%dl.dl-horizontal.planting-attributes
|
||||
%dt Owner:
|
||||
%dd= link_to planting.owner.login_name, planting.owner
|
||||
@@ -15,10 +15,12 @@
|
||||
%dd= link_to planting.garden.name, planting.garden
|
||||
%dt Planted on:
|
||||
%dd= planting.planted_at
|
||||
%dt Quantity:
|
||||
%dd= display_planting_quantity(planting)
|
||||
%dt Finished on:
|
||||
%dd= display_finished(planting)
|
||||
- if planting.quantity
|
||||
%dt Quantity:
|
||||
%dd= display_planting_quantity(planting)
|
||||
- if planting.finished?
|
||||
%dt Finished on:
|
||||
%dd= display_finished(planting)
|
||||
%dt Sun/shade?:
|
||||
%dd
|
||||
- sunniness = planting.sunniness.blank? ? "not specified" : planting.sunniness
|
||||
@@ -26,32 +28,35 @@
|
||||
= " (#{sunniness})"
|
||||
%dt Planted from:
|
||||
%dd= display_planted_from(planting)
|
||||
.col-xs-1.col-md-3
|
||||
%ul{ style: "list-style-type:none; text-align:right" }
|
||||
%li= link_to 'Details', planting, class: 'btn btn-default btn-xs'
|
||||
- if can? :edit, planting
|
||||
%li= link_to 'Edit', edit_planting_path(planting), class: 'btn btn-default btn-xs'
|
||||
- if can? :create, Harvest
|
||||
%li= link_to 'Harvest', new_planting_harvest_path(planting), class: 'btn btn-default btn-xs'
|
||||
- unless planting.finished
|
||||
%li
|
||||
= link_to "Mark as finished",
|
||||
planting_path(planting, planting: { finished: 1 }),
|
||||
method: :put,
|
||||
class: 'btn btn-default btn-xs append-date'
|
||||
- if can? :destroy, planting
|
||||
%li
|
||||
= link_to 'Delete',
|
||||
planting, method: :delete,
|
||||
data: { confirm: 'Are you sure?' },
|
||||
class: 'btn btn-default btn-xs'
|
||||
.row
|
||||
.col-xs-12.col-md-4
|
||||
%dl
|
||||
%dt Days until maturity:
|
||||
%dd= display_days_before_maturity(planting)
|
||||
|
||||
.col-xs-12.col-md-8
|
||||
= render partial: 'plantings/planting_progress', locals: { planting: planting }
|
||||
.col-xs-12.col-md-8
|
||||
= render partial: 'plantings/planting_harvest', locals: { planting: planting }
|
||||
%dt Mature in:
|
||||
%dd
|
||||
= display_days_before_maturity(planting)
|
||||
days
|
||||
|
||||
%p= render partial: 'plantings/planting_progress', locals: { planting: planting }
|
||||
|
||||
= link_to 'Details', planting_path(planting),
|
||||
class: 'btn btn-default btn-xs'
|
||||
|
||||
- if can? :edit, planting
|
||||
= link_to edit_planting_path(planting),
|
||||
class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-pencil{ title: "Edit" }
|
||||
|
||||
- if can?(:edit, planting) && can?(:create, Harvest)
|
||||
= link_to 'Harvest', new_planting_harvest_path(planting),
|
||||
class: 'btn btn-default btn-xs'
|
||||
|
||||
- if can?(:edit, planting) && !planting.finished
|
||||
= link_to "Mark as finished",
|
||||
planting_path(planting, planting: { finished: 1 }),
|
||||
method: :put,
|
||||
class: 'btn btn-default btn-xs append-date'
|
||||
|
||||
- if can? :destroy, planting
|
||||
= link_to planting, method: :delete,
|
||||
data: { confirm: 'Are you sure?' },
|
||||
class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-trash{ title: "Delete" }
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ Growstuff::Application.routes.draw do
|
||||
resources :members
|
||||
|
||||
resources :photos
|
||||
delete 'photo_associations' => 'photo_associations#destroy'
|
||||
|
||||
resources :authentications, only: [:create, :destroy]
|
||||
|
||||
@@ -81,6 +82,7 @@ Growstuff::Application.routes.draw do
|
||||
root to: 'home#index'
|
||||
|
||||
get 'auth/:provider/callback' => 'authentications#create'
|
||||
get 'members/auth/:provider/callback' => 'authentications#create'
|
||||
|
||||
get '/shop' => 'shop#index'
|
||||
get '/shop/:action' => 'shop#:action'
|
||||
|
||||
15
db/migrate/20170413221549_counter_caches.rb
Normal file
15
db/migrate/20170413221549_counter_caches.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class CounterCaches < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :members, :gardens_count, :integer
|
||||
add_column :members, :harvests_count, :integer
|
||||
add_column :members, :seeds_count, :integer
|
||||
|
||||
Member.find_each do |member|
|
||||
Member.reset_counters(member.id, :gardens)
|
||||
Member.reset_counters(member.id, :harvests)
|
||||
Member.reset_counters(member.id, :seeds)
|
||||
Member.reset_counters(member.id, :plantings)
|
||||
say "Member #{member.login_name} counter caches updated"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170104035248) do
|
||||
ActiveRecord::Schema.define(version: 20170413221549) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -323,6 +323,9 @@ ActiveRecord::Schema.define(version: 20170104035248) do
|
||||
t.boolean "newsletter"
|
||||
t.boolean "send_planting_reminder", default: true
|
||||
t.string "preferred_avatar_uri"
|
||||
t.integer "gardens_count"
|
||||
t.integer "harvests_count"
|
||||
t.integer "seeds_count"
|
||||
end
|
||||
|
||||
add_index "members", ["confirmation_token"], name: "index_members_on_confirmation_token", unique: true, using: :btree
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -euv
|
||||
|
||||
gem install overcommit rubocop haml-lint bundler-audit
|
||||
gem install --update overcommit rubocop haml-lint bundler-audit
|
||||
npm install
|
||||
pip install yamllint --user
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
# Git pre-commit hook
|
||||
# To install, run "rake hooks"
|
||||
|
||||
if git diff-index --quiet HEAD --; then
|
||||
# no changes between index and working copy; just run tests
|
||||
rspec spec
|
||||
else
|
||||
# Test the version that's about to be committed,
|
||||
# stashing all unindexed changes
|
||||
git stash -q --keep-index
|
||||
rspec spec
|
||||
git stash pop -q
|
||||
fi
|
||||
41
spec/controllers/photo_associations_controller_spec.rb
Normal file
41
spec/controllers/photo_associations_controller_spec.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe PhotoAssociationsController do
|
||||
login_member
|
||||
|
||||
describe "destroy" do
|
||||
let(:valid_params) do
|
||||
{
|
||||
id: harvest.id,
|
||||
type: 'harvest',
|
||||
photo_id: photo.id
|
||||
}
|
||||
end
|
||||
|
||||
before { photo.harvests << harvest }
|
||||
|
||||
describe "my harvest my photo" do
|
||||
let(:harvest) { FactoryGirl.create :harvest, owner: member }
|
||||
let(:photo) { FactoryGirl.create :photo, owner: member }
|
||||
|
||||
it "removes link" do
|
||||
expect { delete :destroy, valid_params }.to change { photo.harvests.count }.by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "another member's harvest from another member's photo" do
|
||||
let(:harvest) { FactoryGirl.create :harvest }
|
||||
let(:photo) { FactoryGirl.create :photo }
|
||||
it do
|
||||
expect do
|
||||
begin
|
||||
delete :destroy, valid_params
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end.not_to change { photo.harvests.count }
|
||||
end
|
||||
it { expect { delete :destroy, valid_params }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,7 +67,7 @@ feature "Planting a crop", js: true do
|
||||
visit new_garden_path
|
||||
fill_in "Name", with: "New garden"
|
||||
click_button "Save"
|
||||
click_link "Edit garden"
|
||||
click_link 'edit_garden_link'
|
||||
fill_in "Name", with: "Different name"
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Garden was successfully updated"
|
||||
@@ -79,7 +79,7 @@ feature "Planting a crop", js: true do
|
||||
fill_in "Name", with: "New garden"
|
||||
click_button "Save"
|
||||
visit garden_path(Garden.last)
|
||||
click_link "Delete garden"
|
||||
click_link 'delete_garden_link'
|
||||
expect(page).to have_content "Garden was successfully deleted"
|
||||
expect(page).to have_content "#{garden.owner}'s gardens"
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "Progress: Not calculated, days before maturity unknown"
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "Progress: 0% - not planted yet"
|
||||
end
|
||||
|
||||
@@ -90,7 +90,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "Progress: Not calculated, days before maturity unknown"
|
||||
expect(page).to have_content "Days until maturity: unknown"
|
||||
end
|
||||
@@ -108,7 +108,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to_not have_content "Progress: 0% - not planted yet"
|
||||
expect(page).to_not have_content "Progress: Not calculated, days before maturity unknown"
|
||||
end
|
||||
@@ -126,7 +126,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "Progress: 100%"
|
||||
expect(page).to have_content "Yes (no date specified)"
|
||||
expect(page).to have_content "Days until maturity: 0"
|
||||
@@ -145,7 +145,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "Progress: 100%"
|
||||
expect(page).to have_content "Days until maturity: 0"
|
||||
end
|
||||
@@ -159,7 +159,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "maize"
|
||||
end
|
||||
|
||||
@@ -168,7 +168,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_link "Edit"
|
||||
fill_in "Tell us more about it", with: "Some extra notes"
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Planting was successfully updated"
|
||||
expect(page).to have_content "planting was successfully updated"
|
||||
end
|
||||
|
||||
scenario "Editing a planting to fill in the finished date" do
|
||||
@@ -178,7 +178,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
check "finished"
|
||||
fill_in "Finished date", with: "2015-06-25"
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Planting was successfully updated"
|
||||
expect(page).to have_content "planting was successfully updated"
|
||||
expect(page).to_not have_content "Progress: Not calculated, days before maturity unknown"
|
||||
end
|
||||
|
||||
@@ -211,7 +211,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
within "form#new_planting" do
|
||||
click_button "Save"
|
||||
end
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "Finished: August 30, 2014"
|
||||
|
||||
# shouldn't be on the page
|
||||
@@ -230,7 +230,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
check "Mark as finished"
|
||||
click_button "Save"
|
||||
end
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "Finished: Yes (no date specified)"
|
||||
expect(page).to have_content "Progress: 100%"
|
||||
end
|
||||
|
||||
@@ -42,10 +42,10 @@ describe GardensHelper do
|
||||
plantings = [FactoryGirl.create(:planting, quantity: 10, crop: crop)]
|
||||
result = helper.display_garden_plantings(plantings)
|
||||
|
||||
output = "<li>"
|
||||
output = '<ul class="plantings"><li>'
|
||||
output += "10 " + link_to(crop.name, crop)
|
||||
output += ", planted on #{plantings.first.planted_at}"
|
||||
output += "</li>"
|
||||
output += "</li></ul>"
|
||||
expect(result).to eq output
|
||||
end
|
||||
|
||||
@@ -58,16 +58,16 @@ describe GardensHelper do
|
||||
crop2 = FactoryGirl.create(:crop)
|
||||
plantings << FactoryGirl.create(:planting, quantity: 10, crop: crop2)
|
||||
|
||||
result = helper.display_garden_plantings(plantings)
|
||||
result = helper.display_garden_plantings(plantings.first(2))
|
||||
|
||||
output = "<li>"
|
||||
output = '<ul class="plantings"><li>'
|
||||
output += "10 " + link_to(crop1.name, crop1)
|
||||
output += ", planted on #{plantings.first.planted_at}"
|
||||
output += "</li>"
|
||||
output += "<li>"
|
||||
output += "10 " + link_to(crop2.name, crop2)
|
||||
output += ", planted on #{plantings.first.planted_at}"
|
||||
output += "</li>"
|
||||
output += "</li></ul>"
|
||||
expect(result).to eq output
|
||||
end
|
||||
|
||||
@@ -83,16 +83,16 @@ describe GardensHelper do
|
||||
crop3 = FactoryGirl.create(:crop)
|
||||
plantings << FactoryGirl.create(:planting, quantity: 10, crop: crop3)
|
||||
|
||||
result = helper.display_garden_plantings(plantings)
|
||||
result = helper.display_garden_plantings(plantings.first(2))
|
||||
|
||||
output = "<li>"
|
||||
output = '<ul class="plantings"><li>'
|
||||
output += "10 " + link_to(crop1.name, crop1)
|
||||
output += ", planted on #{plantings.first.planted_at}"
|
||||
output += "</li>"
|
||||
output += "<li>"
|
||||
output += "10 " + link_to(crop2.name, crop2)
|
||||
output += ", planted on #{plantings.first.planted_at}"
|
||||
output += "</li>"
|
||||
output += "</li></ul>"
|
||||
expect(result).to eq output
|
||||
end
|
||||
end
|
||||
|
||||
@@ -264,30 +264,43 @@ describe 'member' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'interesting scope' do
|
||||
describe 'interesting scope' do
|
||||
# interesting members are defined as:
|
||||
# 1) confirmed
|
||||
# 2) have a location
|
||||
# 3) have at least one planting
|
||||
# 4) ordered by the most recent sign in
|
||||
|
||||
it 'finds interesting members' do
|
||||
members = [
|
||||
:london_member, :london_member, :london_member,
|
||||
:unconfirmed_member, # !1
|
||||
:london_member, # 1, 2, !3
|
||||
:member # 1, !2, 3
|
||||
].collect { |m| FactoryGirl.create(m) }
|
||||
context 'with a few members and plantings' do
|
||||
before :each do
|
||||
@members = [
|
||||
:london_member, :london_member, :london_member,
|
||||
:unconfirmed_member, # !1
|
||||
:london_member, # 1, 2, !3
|
||||
:member # 1, !2, 3
|
||||
].collect { |m| FactoryGirl.create(m) }
|
||||
|
||||
[0, 1, 2, 3, 5].each do |i|
|
||||
FactoryGirl.create(:planting, owner: members[i])
|
||||
[0, 1, 2, 3, 5].each do |i|
|
||||
FactoryGirl.create(:planting, owner: @members[i])
|
||||
end
|
||||
|
||||
@members[0].updated_at = 3.days.ago
|
||||
@members[1].updated_at = 2.days.ago
|
||||
@members[2].updated_at = 1.day.ago
|
||||
|
||||
# TODO: Shouldn't this save?
|
||||
|
||||
@result = Member.interesting
|
||||
|
||||
# Some members have multiple plantings, but should only appear once
|
||||
3.times do
|
||||
FactoryGirl.create(:planting, owner: @members[2])
|
||||
end
|
||||
end
|
||||
|
||||
members[0].updated_at = 3.days.ago
|
||||
members[1].updated_at = 2.days.ago
|
||||
members[2].updated_at = 1.day.ago
|
||||
|
||||
Member.interesting.should eq [members[2], members[1], members[0]]
|
||||
it 'finds interesting members without duplicates in the correct order' do
|
||||
@result.should eq [@members[2], @members[1], @members[0]]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -4,9 +4,41 @@ describe Planting do
|
||||
let(:crop) { FactoryGirl.create(:tomato) }
|
||||
let(:garden_owner) { FactoryGirl.create(:member) }
|
||||
let(:garden) { FactoryGirl.create(:garden, owner: garden_owner) }
|
||||
let(:planting) {
|
||||
FactoryGirl.create(:planting,
|
||||
crop: crop, garden: garden)}
|
||||
let(:planting) { FactoryGirl.create(:planting, crop: crop, garden: garden) }
|
||||
let(:finished_planting) { FactoryGirl.create :planting, planted_at: 4.days.ago, finished_at: 2.days.ago }
|
||||
|
||||
describe 'maturity calculations' do
|
||||
describe 'start_to_finish_diff' do
|
||||
it { expect(finished_planting.start_to_finish_diff).to eq(2) }
|
||||
end
|
||||
|
||||
describe 'other_finished_plantings_same_crop' do
|
||||
before do
|
||||
# eight finished plantings
|
||||
8.times { FactoryGirl.create :planting, crop: crop, planted_at: 10.days.ago, finished_at: 2.days.ago }
|
||||
# eight not finished plantings
|
||||
8.times { FactoryGirl.create :planting, crop: crop, finished_at: nil }
|
||||
end
|
||||
let!(:planting_with_diff_crop) { FactoryGirl.create :planting, planted_at: 10.days.ago, finished_at: 2.days.ago }
|
||||
it { expect(planting.send(:other_finished_plantings_same_crop).size).to eq(8) }
|
||||
it { expect(planting.send(:other_finished_plantings_same_crop)).not_to include(planting) }
|
||||
it { expect(planting.send(:other_finished_plantings_same_crop)).not_to include(planting_with_diff_crop) }
|
||||
end
|
||||
|
||||
describe 'mean_days_until_maturity' do
|
||||
let(:plantings) do
|
||||
FactoryGirl.create_list(:planting, 10, crop: crop, planted_at: 12.days.ago, finished_at: 2.days.ago)
|
||||
end
|
||||
it { expect(plantings.size).to eq(10) }
|
||||
it { expect(Planting.mean_days_until_maturity(plantings)).to eq(10) }
|
||||
end
|
||||
|
||||
describe 'saving planting calculates days_before_maturity' do
|
||||
before { 5.times { FactoryGirl.create :planting, planted_at: 30.days.ago, finished_at: 9.days.ago, crop: crop } }
|
||||
before { planting.calc_and_set_days_before_maturity }
|
||||
it { expect(planting.days_before_maturity).to eq(21) }
|
||||
end
|
||||
end
|
||||
|
||||
it 'has an owner' do
|
||||
planting.owner.should be_an_instance_of Member
|
||||
|
||||
@@ -53,7 +53,7 @@ describe "gardens/show" do
|
||||
end
|
||||
|
||||
it 'should have an edit button' do
|
||||
rendered.should have_content 'Edit'
|
||||
rendered.should have_link 'edit_garden_link'
|
||||
end
|
||||
|
||||
it "shows a 'plant something' button" do
|
||||
|
||||
@@ -13,17 +13,17 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "photos/show" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
controller.stub(:current_user) { @member }
|
||||
end
|
||||
let(:photo) { FactoryGirl.create :photo, owner: member }
|
||||
before { @photo = photo }
|
||||
|
||||
context "CC-licensed photo" do
|
||||
before(:each) do
|
||||
@photo = assign(:photo, FactoryGirl.create(:photo, owner: @member))
|
||||
render
|
||||
end
|
||||
let(:member) { FactoryGirl.create :member }
|
||||
|
||||
let(:harvest) { FactoryGirl.create :harvest, owner: member }
|
||||
let(:planting) { FactoryGirl.create :planting, owner: member }
|
||||
let(:seed) { FactoryGirl.create :seed, owner: member }
|
||||
let(:garden) { FactoryGirl.create :garden, owner: member }
|
||||
|
||||
shared_examples "photo data renders" do
|
||||
it "shows the image" do
|
||||
assert_select "img[src='#{@photo.fullsize_url}']"
|
||||
end
|
||||
@@ -32,22 +32,79 @@ describe "photos/show" do
|
||||
assert_select "a", href: @photo.owner
|
||||
end
|
||||
|
||||
it "links to the CC license" do
|
||||
assert_select "a", href: @photo.license_url,
|
||||
text: @photo.license_name
|
||||
end
|
||||
|
||||
it "shows a link to the original image" do
|
||||
assert_select "a", href: @photo.link_url, text: "View on Flickr"
|
||||
end
|
||||
|
||||
it "links to harvest" do
|
||||
assert_select "a", href: harvest_path(harvest)
|
||||
end
|
||||
it "links to planting" do
|
||||
assert_select "a", href: planting_path(planting)
|
||||
end
|
||||
it "links to garden" do
|
||||
assert_select "a", href: garden_path(garden)
|
||||
end
|
||||
it "links to seeds" do
|
||||
assert_select "a", href: seed_path(seed)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples "No links to change data" do
|
||||
it "does not have a delete button" do
|
||||
assert_select "a[href='#{photo_path(@photo)}']", false
|
||||
end
|
||||
end
|
||||
|
||||
context "signed in as owner" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { member }
|
||||
render
|
||||
end
|
||||
include_examples "photo data renders"
|
||||
|
||||
it "has a delete button" do
|
||||
assert_select "a[href='#{photo_path(@photo)}']", 'Delete Photo'
|
||||
assert_select "a[href='#{photo_path(@photo)}']"
|
||||
end
|
||||
end
|
||||
|
||||
context "signed in as another member" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { FactoryGirl.create :member }
|
||||
render
|
||||
end
|
||||
include_examples "photo data renders"
|
||||
include_examples "No links to change data"
|
||||
end
|
||||
|
||||
context "not signed in" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
render
|
||||
end
|
||||
include_examples "photo data renders"
|
||||
include_examples "No links to change data"
|
||||
end
|
||||
|
||||
context "CC-licensed photo" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
# @photo = assign(:photo, FactoryGirl.create(:photo, owner: @member))
|
||||
@photo.harvests << harvest
|
||||
@photo.plantings << planting
|
||||
@photo.seeds << seed
|
||||
@photo.gardens << garden
|
||||
render
|
||||
end
|
||||
it "links to the CC license" do
|
||||
assert_select "a", href: @photo.license_url,
|
||||
text: @photo.license_name
|
||||
end
|
||||
end
|
||||
|
||||
context "unlicensed photo" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@photo = assign(:photo, FactoryGirl.create(:unlicensed_photo))
|
||||
render
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user