Compare commits

...

34 Commits

Author SHA1 Message Date
Shiny
53eb171dfc Merge pull request #1317 from Growstuff/dev
release 22
2017-04-17 05:00:59 +00:00
deppbot
b0b6931678 Bundle Update on 2017-04-17 2017-04-17 03:45:39 +00:00
Daniel O'Connor
d515dba7f2 Merge pull request #1316 from Br3nda/garden-thumbnail
Garden thumbnail display cleanup
2017-04-16 15:50:52 +09:30
Shiny
4958330c9e Merge branch 'master' into dev 2017-04-16 02:42:38 +00:00
Brenda Wallace
17236a4a8a Garden thumbnail display cleanup 2017-04-16 13:48:22 +12:00
Daniel O'Connor
3ccab3f857 Merge pull request #1309 from Br3nda/fix_1305
Fix 1305
2017-04-15 17:11:02 +09:30
Daniel O'Connor
0201e873eb Merge branch 'dev' into fix_1305 2017-04-15 17:03:15 +09:30
Daniel O'Connor
20289e6566 Merge pull request #1310 from Br3nda/counter-caches
Adding counter caches
2017-04-15 17:01:20 +09:30
Shiny
85ded414ec Merge branch 'dev' into fix_1305 2017-04-15 06:50:16 +00:00
Shiny
299c95c5f5 Merge branch 'dev' into counter-caches 2017-04-14 07:40:19 +00:00
Taylor Griffin
8f51090098 make mentionbot settings file 2017-04-14 07:40:01 +00:00
deppbot
5551eeba24 Bundle Update on 2017-04-14 2017-04-14 07:10:10 +00:00
Shiny
7a5a68f511 Merge branch 'dev' into counter-caches 2017-04-14 01:44:44 +00:00
Shiny
6d4ec9ad34 Merge branch 'dev' into fix_1305 2017-04-14 01:44:35 +00:00
Brenda Wallace
fffef75813 Ignore ConsecutiveComments and IdNames in haml for now 2017-04-14 01:43:42 +00:00
Brenda Wallace
0e2d7b4393 Allow instance variables in partials for now 2017-04-14 01:43:42 +00:00
Brenda Wallace
f08068c289 Upgrade haml_lint 2017-04-14 01:43:42 +00:00
deppbot
ff653934ad Bundle Update on 2017-04-08 2017-04-14 01:43:42 +00:00
Brenda Wallace
c4bed2cf4d Merge branch 'haml-lint-fix' into counter-caches 2017-04-14 11:42:02 +12:00
Brenda Wallace
47c0f74f81 Ignore ConsecutiveComments and IdNames in haml for now 2017-04-14 11:40:52 +12:00
Brenda Wallace
171e34914b Allow instance variables in partials for now 2017-04-14 11:40:46 +12:00
Brenda Wallace
8010a8b56c Upgrade haml_lint 2017-04-14 11:40:40 +12:00
Brenda Wallace
ac165ce0cd Adding counter caches 2017-04-14 11:32:31 +12:00
Brenda Wallace
4925fde28f Ignore ConsecutiveComments and IdNames in haml for now 2017-04-14 09:43:16 +12:00
Brenda Wallace
6580cf38b0 Allow instance variables in partials for now 2017-04-13 23:02:16 +12:00
Brenda Wallace
fdf10202ba Upgrade haml_lint 2017-04-13 22:56:07 +12:00
Brenda Wallace
85a368999b we love rubocop 2017-04-13 14:30:51 +12:00
Daniel O'Connor
6ba4b4560e Fix #1305 by adding aggregation
Expand test coverage
member_id is owner_id on plantings
Argue with ActionView::Template::Error about what we can group on

Rename variable
2017-04-13 14:30:41 +12:00
Cesy
71aedb136a Merge pull request #1300 from Growstuff/bundle-update-2017-04-02-131809
Bundle Update on 2017-04-02
2017-04-08 15:06:16 +01:00
Shiny
65c988790b Merge branch 'dev' into bundle-update-2017-04-02-131809 2017-04-06 08:04:46 +12:00
Brenda Wallace
0372d3b9b0 Removing pre-commit.sh script 2017-04-06 08:04:09 +12:00
Shiny
3272ea1ca5 Merge branch 'dev' into bundle-update-2017-04-02-131809 2017-04-06 07:51:19 +12:00
Cesy
5392d7d900 Merge branch 'dev' into bundle-update-2017-04-02-131809 2017-04-03 08:47:32 +01:00
deppbot
45f2abeab5 Bundle Update on 2017-04-02 2017-04-02 13:18:11 +08:00
17 changed files with 99 additions and 69 deletions

View File

@@ -1,3 +1,9 @@
linters:
LineLength:
max: 120
InstanceVariables:
enabled: false
IdNames:
enabled: false
ConsecutiveComments:
enabled: false

3
.mention-bot Normal file
View File

@@ -0,0 +1,3 @@
{
"userBlacklist": ["tygriffin","oshiho3"]
}

View File

@@ -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

View File

@@ -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

View File

@@ -333,3 +333,6 @@ $state-success-bg: lighten($green, 50%)
overflow: hidden
text-overflow: ellipsis
white-space: nowrap
ul.plantings
list-style-type: none

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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") }

View File

@@ -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)

View 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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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