Skip to content

Commit

Permalink
Merge pull request #1423 from Growstuff/dev
Browse files Browse the repository at this point in the history
Release 31
  • Loading branch information
pozorvlak authored Nov 3, 2017
2 parents 494dd1d + fa600be commit fac24c5
Show file tree
Hide file tree
Showing 178 changed files with 2,587 additions and 1,084 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ Style/FileName:
Style/StringLiterals:
Enabled: false

# Stop hound and codeclimate fighting
Style/PercentLiteralDelimiters:
PreferredDelimiters:
default: ()
'%i': ()
'%w': ()

Style/MultilineMethodCallIndentation:
EnforcedStyle: indented

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ submit the change with your pull request.
- Arun Kumar / [arun1595](https://github.com/arun1595)
- Harry Brodsky / [hbrodsk1](https://github.com/hbrodsk1)
- Jeff Kingswood / [ancyentmariner](https://github.com/ancyentmariner)
- Logan Gingerich / [logangingerich](https://github.com/logangingerich)

## Bots

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ group :development, :test do
gem 'capybara-screenshot' # for test debugging
gem 'coveralls', require: false # coverage analysis
gem 'database_cleaner'
gem 'factory_girl_rails' # for creating test data
gem 'factory_bot_rails' # for creating test data
gem 'haml-i18n-extractor'
gem 'haml-rails' # HTML templating language
gem 'haml_lint' # Checks haml files for goodness
Expand Down
21 changes: 10 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GEM
activejob (4.2.10)
activesupport (= 4.2.10)
globalid (>= 0.3.0)
activemerchant (1.73.0)
activemerchant (1.74.0)
activesupport (>= 3.2.14, < 6.x)
builder (>= 2.1.2, < 4.0.0)
i18n (>= 0.6.9)
Expand Down Expand Up @@ -143,7 +143,7 @@ GEM
d3-rails (3.5.17)
railties (>= 3.1)
dalli (2.7.6)
database_cleaner (1.6.1)
database_cleaner (1.6.2)
debug_inspector (0.0.3)
devise (4.3.0)
bcrypt (~> 3.0)
Expand Down Expand Up @@ -173,10 +173,10 @@ GEM
erubis (2.7.0)
excon (0.59.0)
execjs (2.7.0)
factory_girl (4.8.1)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
Expand All @@ -193,7 +193,7 @@ GEM
gibbon (1.2.1)
httparty
multi_json (>= 1.9.0)
globalid (0.4.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
gravatar-ultimate (2.0.0)
activesupport (>= 2.3.14)
Expand Down Expand Up @@ -417,7 +417,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.1.0)
raindrops (0.19.0)
rake (12.1.0)
rake (12.2.1)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
Expand Down Expand Up @@ -462,7 +462,7 @@ GEM
ruby_parser (3.10.1)
sexp_processor (~> 4.9)
rubyzip (1.2.1)
sass (3.5.2)
sass (3.5.3)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand Down Expand Up @@ -510,7 +510,7 @@ GEM
timecop (0.9.1)
tins (1.15.0)
trollop (1.16.2)
tzinfo (1.2.3)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
Expand Down Expand Up @@ -567,7 +567,7 @@ DEPENDENCIES
elasticsearch-api (~> 2.0.0)
elasticsearch-model
elasticsearch-rails
factory_girl_rails
factory_bot_rails
figaro
flickraw
font-awesome-sass
Expand Down Expand Up @@ -622,7 +622,6 @@ DEPENDENCIES
will_paginate
xmlrpc


RUBY VERSION
ruby 2.4.1p111

Expand Down
8 changes: 7 additions & 1 deletion app/controllers/photos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ class PhotosController < ApplicationController
responders :flash

def index
@photos = Photo.paginate(page: params[:page])
if params[:crop_id]
@crop = Crop.find params[:crop_id]
@photos = @crop.photos
else
@photos = Photo.all
end
@photos = @photos.includes(:owner).order(:created_at).paginate(page: params[:page])
respond_with(@photos)
end

Expand Down
4 changes: 4 additions & 0 deletions app/models/crop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class Crop < ActiveRecord::Base
end
end

def harvest_photos
Photo.joins(:harvests).where("harvests.crop_id": id)
end

def as_indexed_json(_options = {})
as_json(
only: [:id, :name, :approval_status],
Expand Down
2 changes: 1 addition & 1 deletion app/models/garden.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Garden < ActiveRecord::Base

validates :name,
format: {
with: /\A\w+[\w ]+\z/
with: /\A\w+[\w ()]+\z/
},
length: { maximum: 255 }

Expand Down
2 changes: 1 addition & 1 deletion app/models/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Member < ActiveRecord::Base

# and an account record (for paid accounts etc)
# we use find_or_create to avoid accidentally creating a second one,
# which can happen sometimes especially with FactoryGirl associations
# which can happen sometimes especially with FactoryBot associations
after_create { |member| Account.find_or_create_by(member_id: member.id) }

after_save :update_newsletter_subscription
Expand Down
14 changes: 12 additions & 2 deletions app/views/crops/_photos.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
%h2 Photos of #{crop.name} harvests
.row
- unless crop.harvest_photos.empty?
- crop.harvest_photos.includes(:owner).first(3).each do |p|
.col-md-4
= render "photos/thumbnail", photo: p

%h2 Photos of #{crop.name} plants
.row
- unless crop.photos.empty?
- crop.photos.first(3).each do |p|
- crop.photos.includes(:owner).first(3).each do |p|
.col-md-4
= render partial: "photos/thumbnail", locals: { photo: p }
= render "photos/thumbnail", photo: p
.row
= link_to "more photos", crop_photos_path(crop_id: crop.id)
6 changes: 4 additions & 2 deletions app/views/photos/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
- content_for :title, "Photos"

- if @crop
%h2= @crop.name

%p Most recent photos added to #{ENV['GROWSTUFF_SITE_NAME']}.

.pagination
= page_entries_info @photos
= will_paginate @photos


.row
- @photos.each do |p|
.col-md-2.six-across
Expand All @@ -19,5 +23,3 @@
.pagination
= page_entries_info @photos
= will_paginate @photos


4 changes: 2 additions & 2 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# config.action_view.raise_on_missing_translations = true

# Growstuff config
config.action_mailer.default_url_options = { host: 'localhost:8080' }
config.action_mailer.default_url_options = { host: 'localhost:3000' }

config.action_mailer.delivery_method = :letter_opener
config.action_mailer.smtp_settings = {
Expand All @@ -55,7 +55,7 @@
authentication: :login
}

config.host = 'localhost:8080'
config.host = 'localhost:3000'
config.analytics_code = ''

# this config variable cannot be put in application.yml as it is needed
Expand Down
9 changes: 9 additions & 0 deletions config/factory_bot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ActionDispatch::Callbacks.after do
# Reload the factories
return unless Rails.env.development? || Rails.env.test?

if FactoryBot.factories.present? # first init will load factories, this should only run on subsequent reloads
FactoryBot.factories.clear
FactoryBot.find_definitions
end
end
9 changes: 0 additions & 9 deletions config/factory_girl.rb

This file was deleted.

4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
get 'crops/wrangle' => 'crops#wrangle', :as => 'wrangle_crops'
get 'crops/hierarchy' => 'crops#hierarchy', :as => 'crops_hierarchy'
get 'crops/search' => 'crops#search', :as => 'crops_search'
resources :crops
resources :crops do
get 'photos' => 'photos#index'
end

resources :comments
resources :roles
Expand Down
Loading

0 comments on commit fac24c5

Please sign in to comment.