mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 09:19:15 -04:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53eb171dfc | ||
|
|
b0b6931678 | ||
|
|
d515dba7f2 | ||
|
|
4958330c9e | ||
|
|
17236a4a8a | ||
|
|
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"]
|
||||
}
|
||||
2
Gemfile
2
Gemfile
@@ -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
|
||||
|
||||
37
Gemfile.lock
37
Gemfile.lock
@@ -25,7 +25,7 @@ GEM
|
||||
addressable
|
||||
active_merchant-paypal-bogus-gateway (0.1.0)
|
||||
activemerchant
|
||||
active_utils (3.3.1)
|
||||
active_utils (3.3.3)
|
||||
activesupport (>= 3.2, < 5.2.0)
|
||||
i18n
|
||||
activejob (4.2.8)
|
||||
@@ -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 (6.7.7.2)
|
||||
execjs
|
||||
bcrypt (3.1.11)
|
||||
better_errors (2.1.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
|
||||
@@ -222,8 +222,9 @@ GEM
|
||||
haml (>= 4.0.6, < 5.0)
|
||||
html2haml (>= 1.0.1)
|
||||
railties (>= 4.0.1)
|
||||
haml_lint (0.20.0)
|
||||
haml (~> 4.0)
|
||||
haml_lint (0.24.0)
|
||||
haml (>= 4.0, < 5.1)
|
||||
rainbow
|
||||
rake (>= 10, < 13)
|
||||
rubocop (>= 0.47.0)
|
||||
sysexits (~> 1.1)
|
||||
@@ -265,7 +266,7 @@ GEM
|
||||
js-routes (1.3.3)
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
json (2.0.3)
|
||||
json (2.0.4)
|
||||
jwt (1.5.6)
|
||||
kaminari (0.17.0)
|
||||
actionpack (>= 3.0.0)
|
||||
@@ -300,7 +301,7 @@ GEM
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nenv (0.3.0)
|
||||
newrelic_rpm (4.0.0.332)
|
||||
newrelic_rpm (4.1.0.333)
|
||||
nokogiri (1.7.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
notiffany (0.1.1)
|
||||
@@ -435,7 +436,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)
|
||||
@@ -449,7 +450,7 @@ GEM
|
||||
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)
|
||||
concurrent-ruby (~> 1.0)
|
||||
@@ -472,7 +473,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 +489,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)
|
||||
@@ -552,7 +553,7 @@ DEPENDENCIES
|
||||
haml
|
||||
haml-i18n-extractor
|
||||
haml-rails
|
||||
haml_lint (~> 0.20.0)
|
||||
haml_lint
|
||||
hashie (>= 3.5.3)
|
||||
heroku-api
|
||||
i18n-tasks
|
||||
|
||||
@@ -333,3 +333,6 @@ $state-success-bg: lighten($green, 50%)
|
||||
overflow: hidden
|
||||
text-overflow: ellipsis
|
||||
white-space: nowrap
|
||||
|
||||
ul.plantings
|
||||
list-style-type: none
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
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
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user