From 9c4f011fbce8a0611f8ea9930f5bce72b238caee Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 19 Nov 2016 22:28:38 +1300 Subject: [PATCH 01/24] Reduced percieved complexity in photos_controller.rb --- .rubocop.yml | 2 +- app/controllers/photos_controller.rb | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e525bb5d6..f26396137 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,4 +45,4 @@ Metrics/LineLength: # Offense count: 8 Metrics/PerceivedComplexity: - Max: 12 \ No newline at end of file + Max: 11 \ No newline at end of file diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 2e2f44689..da3ebd659 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -47,11 +47,7 @@ class PhotosController < ApplicationController # POST /photos # POST /photos.json def create - @photo = Photo.find_by_flickr_photo_id(params[:photo][:flickr_photo_id]) || - Photo.new(photo_params) - @photo.owner_id = current_member.id - @photo.set_flickr_metadata - + @photo = find_or_create_from_flickr_photo params[:photo][:flickr_photo_id] collection = case params[:type] when 'garden' @@ -129,4 +125,12 @@ class PhotosController < ApplicationController params.require(:photo).permit(:flickr_photo_id, :owner_id, :title, :license_name, :license_url, :thumbnail_url, :fullsize_url, :link_url) end + + def find_or_create_from_flickr_photo(flickr_photo_id) + photo = Photo.find_by(flickr_photo_id: flickr_photo_id) + photo = Photo.new(photo_params) unless photo + photo.owner_id = current_member.id + photo.set_flickr_metadata + photo + end end From 0a54c2d98617ab4cc5f513ba35adb3dea9830621 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 09:05:29 +1300 Subject: [PATCH 02/24] Moved to method: collection to use for photos --- app/controllers/photos_controller.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index da3ebd659..fe0ab9bf5 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -48,17 +48,7 @@ class PhotosController < ApplicationController # POST /photos.json def create @photo = find_or_create_from_flickr_photo params[:photo][:flickr_photo_id] - - collection = case params[:type] - when 'garden' - @photo.gardens - when 'planting' - @photo.plantings - when 'harvest' - @photo.harvests - else - nil - end + collection = which_collection? if collection && has_item_id item = params[:type].camelcase.constantize.find_by_id(params[:id]) @@ -133,4 +123,15 @@ class PhotosController < ApplicationController photo.set_flickr_metadata photo end + + def which_collection? + case params[:type] + when 'garden' + @photo.gardens + when 'planting' + @photo.plantings + when 'harvest' + @photo.harvests + end + end end From f4a26d0580ecb86dc75ca0f9397cd434b9f62a75 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 09:06:04 +1300 Subject: [PATCH 03/24] has_item_id? renamed to item_id? --- app/controllers/photos_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index fe0ab9bf5..418f3c1cc 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -50,7 +50,7 @@ class PhotosController < ApplicationController @photo = find_or_create_from_flickr_photo params[:photo][:flickr_photo_id] collection = which_collection? - if collection && has_item_id + if collection && item_id? item = params[:type].camelcase.constantize.find_by_id(params[:id]) if item && member_owns_item(item) collection << item unless collection.include?(item) @@ -103,7 +103,7 @@ class PhotosController < ApplicationController private - def has_item_id + def item_id? params.key? :id end From 810fe14c692bdc22b9ad338d484206ef6279dd53 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 09:17:42 +1300 Subject: [PATCH 04/24] Highest percieved complexity is now 10 --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index f26396137..8665b83fa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,4 +45,4 @@ Metrics/LineLength: # Offense count: 8 Metrics/PerceivedComplexity: - Max: 11 \ No newline at end of file + Max: 10 \ No newline at end of file From 5fc1ab9c60e88a6c1ff133d3b0dba06902cd7264 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 19:35:17 +1300 Subject: [PATCH 05/24] Reduced code duplication in growstuff.rake --- lib/tasks/growstuff.rake | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake index 1e3a8188e..9ef918840 100644 --- a/lib/tasks/growstuff.rake +++ b/lib/tasks/growstuff.rake @@ -4,18 +4,20 @@ namespace :growstuff do # usage: rake growstuff:admin_user name=skud task admin_user: :environment do - member = Member.find_by_login_name(ENV['name']) or raise "Usage: rake growstuff:admin_user name=whoever (login name is case-sensitive)" - admin = Role.find('admin') - member.roles << admin + add_role_to_member! ENV['name'], 'admin' end desc "Add a crop wrangler user, by name" # usage: rake growstuff:cropwrangler_user name=skud task cropwrangler_user: :environment do - member = Member.find_by_login_name(ENV['name']) or raise "Usage: rake growstuff:cropwrangler_user name=whoever (login name is case-sensitive)" - cw = Role.find('crop-wrangler') - member.roles << cw + add_role_to_member! ENV['name'], 'crop-wrangler' + end + + def add_role_to_member!(login_name, role_name) + member = Member.find_by!(login_name: login_name) + role = Role.find_by!(name: role_name) + member.roles << role end desc "Upload crops from a CSV file" From cf70bfebe9fa911747d9e5ae54d37833114b2ec9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 20:13:51 +1300 Subject: [PATCH 06/24] Further simplified photos controller --- app/controllers/photos_controller.rb | 51 ++++++++++++++++------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 418f3c1cc..928dab228 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -47,23 +47,12 @@ class PhotosController < ApplicationController # POST /photos # POST /photos.json def create - @photo = find_or_create_from_flickr_photo params[:photo][:flickr_photo_id] - collection = which_collection? - - if collection && item_id? - item = params[:type].camelcase.constantize.find_by_id(params[:id]) - if item && member_owns_item(item) - collection << item unless collection.include?(item) - else - flash[:alert] = "Could not find this item owned by you" - end - else - flash[:alert] = "Missing or invalid type or id parameter" - end + find_or_create_photo_from_flickr_photo + add_photo_to_collection respond_to do |format| - if @photo.save - format.html { redirect_to @photo, notice: 'Photo was successfully added.' } + if @photo.present? && @photo.save + format.html { redirect_to photo_path(@photo), notice: 'Photo was successfully added.' } format.json { render json: @photo, status: :created, location: @photo } else format.html { render action: "new" } @@ -111,17 +100,21 @@ class PhotosController < ApplicationController item.owner.id == current_member.id end + def flickr_photo_id_param + params[:photo][:flickr_photo_id] + end + def photo_params params.require(:photo).permit(:flickr_photo_id, :owner_id, :title, :license_name, :license_url, :thumbnail_url, :fullsize_url, :link_url) end - def find_or_create_from_flickr_photo(flickr_photo_id) - photo = Photo.find_by(flickr_photo_id: flickr_photo_id) - photo = Photo.new(photo_params) unless photo - photo.owner_id = current_member.id - photo.set_flickr_metadata - photo + def find_or_create_photo_from_flickr_photo + @photo = Photo.find_by(flickr_photo_id: flickr_photo_id_param) + @photo = Photo.new(photo_params) unless @photo + @photo.owner_id = current_member.id + @photo.set_flickr_metadata + @photo end def which_collection? @@ -134,4 +127,20 @@ class PhotosController < ApplicationController @photo.harvests end end + + def add_photo_to_collection + collection = which_collection? + + unless collection && item_id? + flash[:alert] = "Missing or invalid type or id parameter" + return + end + + item = params[:type].camelcase.constantize.find(params[:id]) + if item && member_owns_item(item) + collection << item unless collection.include?(item) + else + flash[:alert] = "Could not find this item owned by you" + end + end end From 138080c4d4c5878bb040fff0a8a47c3a29e36207 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 20:18:20 +1300 Subject: [PATCH 07/24] Tabulation fix --- app/controllers/photos_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 928dab228..d63698f05 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -106,7 +106,7 @@ class PhotosController < ApplicationController def photo_params params.require(:photo).permit(:flickr_photo_id, :owner_id, :title, :license_name, - :license_url, :thumbnail_url, :fullsize_url, :link_url) + :license_url, :thumbnail_url, :fullsize_url, :link_url) end def find_or_create_photo_from_flickr_photo From 72f1d83af435b91704ca213398bd548b98b7b050 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 20:19:14 +1300 Subject: [PATCH 08/24] Removed a bunch of blank lines --- spec/controllers/photos_controller_spec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 0b1c3699e..ee8e3286a 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -10,14 +10,9 @@ ## If you submit a pull request containing new view or controller tests, it will not be ## merged. - - - - require 'rails_helper' describe PhotosController do - login_member def valid_attributes @@ -74,7 +69,6 @@ describe PhotosController do get :new, { set: 'foo' } assigns(:current_set).should eq "foo" end - end describe "POST create" do From f6aac07c3dc25067951a12f8918a174a9dc1182b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 20:27:59 +1300 Subject: [PATCH 09/24] Flatten params passed in photos controller spec --- spec/controllers/photos_controller_spec.rb | 48 +++++++--------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index ee8e3286a..8f3b9d973 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -48,25 +48,25 @@ describe PhotosController do end it "assigns a planting id" do - get :new, { type: "planting", id: 5 } + get :new, type: "planting", id: 5 assigns(:id).should eq "5" assigns(:type).should eq "planting" end it "assigns a harvest id" do - get :new, { type: "harvest", id: 5 } + get :new, type: "harvest", id: 5 assigns(:id).should eq "5" assigns(:type).should eq "harvest" end it "assigns a garden id" do - get :new, { type: "garden", id: 5 } + get :new, type: "garden", id: 5 assigns(:id).should eq "5" assigns(:type).should eq "garden" end it "assigns the current set as @current_set" do - get :new, { set: 'foo' } + get :new, set: 'foo' assigns(:current_set).should eq "foo" end end @@ -91,9 +91,7 @@ describe PhotosController do garden = FactoryGirl.create(:garden, owner: member) planting = FactoryGirl.create(:planting, garden: garden, owner: member) photo = FactoryGirl.create(:photo, owner: member) - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "planting", - id: planting.id } + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id Photo.last.plantings.first.should eq planting end @@ -103,12 +101,8 @@ describe PhotosController do garden = FactoryGirl.create(:garden, owner: member) planting = FactoryGirl.create(:planting, garden: garden, owner: member) photo = FactoryGirl.create(:photo, owner: member) - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "planting", - id: planting.id } - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "planting", - id: planting.id } + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id Photo.last.plantings.size.should eq 1 end @@ -117,9 +111,7 @@ describe PhotosController do controller.stub(:current_member) { member } harvest = FactoryGirl.create(:harvest, owner: member) photo = FactoryGirl.create(:photo, owner: member) - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "harvest", - id: harvest.id } + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id Photo.last.harvests.first.should eq harvest end @@ -128,12 +120,8 @@ describe PhotosController do controller.stub(:current_member) { member } harvest = FactoryGirl.create(:harvest, owner: member) photo = FactoryGirl.create(:photo, owner: member) - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "harvest", - id: harvest.id } - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "harvest", - id: harvest.id } + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id Photo.last.harvests.size.should eq 1 end end @@ -156,9 +144,7 @@ describe PhotosController do garden = FactoryGirl.create(:garden, owner: member) planting = FactoryGirl.create(:planting, garden: garden, owner: member) photo = FactoryGirl.create(:photo, owner: member) - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "planting", - id: planting.id } + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id Photo.last.plantings.first.should eq planting end @@ -167,9 +153,7 @@ describe PhotosController do controller.stub(:current_member) { member } harvest = FactoryGirl.create(:harvest, owner: member) photo = FactoryGirl.create(:photo, owner: member) - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "harvest", - id: harvest.id } + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id Photo.last.harvests.first.should eq harvest end end @@ -179,9 +163,7 @@ describe PhotosController do # members will be auto-created, and different planting = FactoryGirl.create(:planting) photo = FactoryGirl.create(:photo) - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "planting", - id: planting.id } + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id Photo.last.plantings.first.should_not eq planting end @@ -189,9 +171,7 @@ describe PhotosController do # members will be auto-created, and different harvest = FactoryGirl.create(:harvest) photo = FactoryGirl.create(:photo) - post :create, {photo: { flickr_photo_id: photo.flickr_photo_id }, - type: "harvest", - id: harvest.id } + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id Photo.last.harvests.first.should_not eq harvest end end From a8bffd3bcec2eefc0898be6aaa40911930d592a0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 20:28:34 +1300 Subject: [PATCH 10/24] White space fix in spec --- spec/controllers/photos_controller_spec.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 8f3b9d973..a46f4e419 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -73,18 +73,15 @@ describe PhotosController do describe "POST create" do before(:each) do - Photo.any_instance.stub(:flickr_metadata).and_return( { - title: "A Heartbreaking work of staggering genius", - license_name: "CC-BY", - license_url: "http://example.com/aybpl", - thumbnail_url: "http://example.com/thumb.jpg", - fullsize_url: "http://example.com/full.jpg", - link_url: "http://example.com" - }) + Photo.any_instance.stub(:flickr_metadata).and_return(title: "A Heartbreaking work of staggering genius", + license_name: "CC-BY", + license_url: "http://example.com/aybpl", + thumbnail_url: "http://example.com/thumb.jpg", + fullsize_url: "http://example.com/full.jpg", + link_url: "http://example.com") end describe "with valid params" do - it "attaches the photo to a planting" do member = FactoryGirl.create(:member) controller.stub(:current_member) { member } @@ -123,8 +120,8 @@ describe PhotosController do post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id Photo.last.harvests.size.should eq 1 + end end - end describe "for the second time" do it "does not add a photo twice" do From d0a1a113b603ecce21018df21ee1e8fc1b02a5ac Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 20:29:01 +1300 Subject: [PATCH 11/24] Multi-line block changed from {} to do end --- spec/controllers/photos_controller_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index a46f4e419..647a4aa87 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -125,12 +125,12 @@ describe PhotosController do describe "for the second time" do it "does not add a photo twice" do - expect { - post :create, {photo: { flickr_photo_id: 1 } } - }.to change(Photo, :count).by(1) - expect { - post :create, {photo: { flickr_photo_id: 1 } } - }.to change(Photo, :count).by(0) + expect do + post :create, photo: { flickr_photo_id: 1 } + end.to change(Photo, :count).by(1) + expect do + post :create, photo: { flickr_photo_id: 1 } + end.to change(Photo, :count).by(0) end end From 73a050df13e2cec053033a91683c69bfdd882278 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 20:29:45 +1300 Subject: [PATCH 12/24] before_filter becomes before_action in photos controller --- app/controllers/photos_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index d63698f05..6a6a29f07 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -1,5 +1,5 @@ class PhotosController < ApplicationController - before_filter :authenticate_member!, except: [:index, :show] + before_action :authenticate_member!, except: [:index, :show] load_and_authorize_resource # GET /photos From 8012d9f6a804658f07ae30c39243bc494fda78fb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:02:43 +1300 Subject: [PATCH 13/24] Whitelist which items can have photos --- app/controllers/photos_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 6a6a29f07..1409ba748 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -136,11 +136,17 @@ class PhotosController < ApplicationController return end - item = params[:type].camelcase.constantize.find(params[:id]) + item = which_item? if item && member_owns_item(item) collection << item unless collection.include?(item) else flash[:alert] = "Could not find this item owned by you" end end + + def which_item? + allowed_types = %w(planting garden harvest) + item_type = params[:type] + item_type.camelcase.constantize.find(params[:id]) if allowed_types.include? item_type + end end From a7e88a55b3a052675b8c218c65ac6176e23c6685 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:03:08 +1300 Subject: [PATCH 14/24] Spec for trying to attach photo when not allowed. --- spec/controllers/photos_controller_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 647a4aa87..dc09443fe 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -121,6 +121,15 @@ describe PhotosController do post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id Photo.last.harvests.size.should eq 1 end + + it "doesn't attach photo to a comment" do + member = FactoryGirl.create(:member) + controller.stub(:current_member) { member } + comment = FactoryGirl.create(:comment) + photo = FactoryGirl.create(:photo, owner: member) + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id + expect(flash[:alert]).to be_present + end end describe "for the second time" do From 50a0668c1d61cebdda5ca4ec99d8c7f21d7d2865 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:11:54 +1300 Subject: [PATCH 15/24] Check no alert message was generated --- spec/controllers/photos_controller_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index dc09443fe..22712f2e0 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -51,23 +51,27 @@ describe PhotosController do get :new, type: "planting", id: 5 assigns(:id).should eq "5" assigns(:type).should eq "planting" + expect(flash[:alert]).not_to be_present end it "assigns a harvest id" do get :new, type: "harvest", id: 5 assigns(:id).should eq "5" assigns(:type).should eq "harvest" + expect(flash[:alert]).not_to be_present end it "assigns a garden id" do get :new, type: "garden", id: 5 assigns(:id).should eq "5" assigns(:type).should eq "garden" + expect(flash[:alert]).not_to be_present end it "assigns the current set as @current_set" do get :new, set: 'foo' assigns(:current_set).should eq "foo" + expect(flash[:alert]).not_to be_present end end @@ -89,6 +93,7 @@ describe PhotosController do planting = FactoryGirl.create(:planting, garden: garden, owner: member) photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end @@ -100,6 +105,7 @@ describe PhotosController do photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + expect(flash[:alert]).not_to be_present Photo.last.plantings.size.should eq 1 end @@ -109,6 +115,7 @@ describe PhotosController do harvest = FactoryGirl.create(:harvest, owner: member) photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end @@ -119,6 +126,7 @@ describe PhotosController do photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + expect(flash[:alert]).not_to be_present Photo.last.harvests.size.should eq 1 end @@ -151,6 +159,7 @@ describe PhotosController do planting = FactoryGirl.create(:planting, garden: garden, owner: member) photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end @@ -170,6 +179,7 @@ describe PhotosController do planting = FactoryGirl.create(:planting) photo = FactoryGirl.create(:photo) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + expect(flash[:alert]).to be_present Photo.last.plantings.first.should_not eq planting end @@ -178,6 +188,7 @@ describe PhotosController do harvest = FactoryGirl.create(:harvest) photo = FactoryGirl.create(:photo) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + expect(flash[:alert]).to be_present Photo.last.harvests.first.should_not eq harvest end end From 6a8f48693bd89aa1a699cec483df7f36b777dc08 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:12:43 +1300 Subject: [PATCH 16/24] Reduce code duplication in photos cont spec --- spec/controllers/photos_controller_spec.rb | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 22712f2e0..2c507b611 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -86,23 +86,20 @@ describe PhotosController do end describe "with valid params" do + let(:member) { FactoryGirl.create(:member) } + let(:garden) { FactoryGirl.create(:garden, owner: member) } + let(:planting) { FactoryGirl.create(:planting, garden: garden, owner: member) } + let(:harvest) { FactoryGirl.create(:harvest, owner: member) } + let(:photo) { FactoryGirl.create(:photo, owner: member) } + + before { controller.stub(:current_member) { member } } it "attaches the photo to a planting" do - member = FactoryGirl.create(:member) - controller.stub(:current_member) { member } - garden = FactoryGirl.create(:garden, owner: member) - planting = FactoryGirl.create(:planting, garden: garden, owner: member) - photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id expect(flash[:alert]).not_to be_present Photo.last.plantings.first.should eq planting end it "doesn't attach a photo to a planting twice" do - member = FactoryGirl.create(:member) - controller.stub(:current_member) { member } - garden = FactoryGirl.create(:garden, owner: member) - planting = FactoryGirl.create(:planting, garden: garden, owner: member) - photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id expect(flash[:alert]).not_to be_present @@ -110,20 +107,12 @@ describe PhotosController do end it "attaches the photo to a harvest" do - member = FactoryGirl.create(:member) - controller.stub(:current_member) { member } - harvest = FactoryGirl.create(:harvest, owner: member) - photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end it "doesn't attach a photo to a harvest twice" do - member = FactoryGirl.create(:member) - controller.stub(:current_member) { member } - harvest = FactoryGirl.create(:harvest, owner: member) - photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present @@ -131,10 +120,7 @@ describe PhotosController do end it "doesn't attach photo to a comment" do - member = FactoryGirl.create(:member) - controller.stub(:current_member) { member } comment = FactoryGirl.create(:comment) - photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id expect(flash[:alert]).to be_present end From 12a9a0b97d6be7a578c819b57e1ca1779325abe1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:13:08 +1300 Subject: [PATCH 17/24] one more check no alert was generated --- spec/controllers/photos_controller_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 2c507b611..085870968 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -155,6 +155,7 @@ describe PhotosController do harvest = FactoryGirl.create(:harvest, owner: member) photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest end end From dddc7b020d626287cb38fdc17646f36f8d7015bf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:13:33 +1300 Subject: [PATCH 18/24] Corrected description in spec --- spec/controllers/photos_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 085870968..3f9f07d98 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -161,7 +161,7 @@ describe PhotosController do end describe "with mismatched owners" do - it "creates the planting/photo link" do + it "does not create the planting/photo link" do # members will be auto-created, and different planting = FactoryGirl.create(:planting) photo = FactoryGirl.create(:photo) @@ -170,7 +170,7 @@ describe PhotosController do Photo.last.plantings.first.should_not eq planting end - it "creates the harvest/photo link" do + it "does not create the harvest/photo link" do # members will be auto-created, and different harvest = FactoryGirl.create(:harvest) photo = FactoryGirl.create(:photo) From f24e02fd11d94d850d3ff98829f5ca4808869d04 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:13:57 +1300 Subject: [PATCH 19/24] reduced code duplication again in photos cont spec --- spec/controllers/photos_controller_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 3f9f07d98..82566501a 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -161,10 +161,10 @@ describe PhotosController do end describe "with mismatched owners" do + let(:photo) { FactoryGirl.create(:photo) } it "does not create the planting/photo link" do # members will be auto-created, and different planting = FactoryGirl.create(:planting) - photo = FactoryGirl.create(:photo) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id expect(flash[:alert]).to be_present Photo.last.plantings.first.should_not eq planting @@ -173,7 +173,6 @@ describe PhotosController do it "does not create the harvest/photo link" do # members will be auto-created, and different harvest = FactoryGirl.create(:harvest) - photo = FactoryGirl.create(:photo) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).to be_present Photo.last.harvests.first.should_not eq harvest From dac2343b68620ae57e85ad7ec0ffa62696969da0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:18:07 +1300 Subject: [PATCH 20/24] Further code duplication reduction --- spec/controllers/photos_controller_spec.rb | 32 +++++++++------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 82566501a..0197e2009 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true ## DEPRECATION NOTICE: Do not add new tests to this file! ## ## View and controller tests are deprecated in the Growstuff project. @@ -85,13 +86,12 @@ describe PhotosController do link_url: "http://example.com") end + let(:member) { FactoryGirl.create(:member) } + let(:garden) { FactoryGirl.create(:garden, owner: member) } + let(:planting) { FactoryGirl.create(:planting, garden: garden, owner: member) } + let(:harvest) { FactoryGirl.create(:harvest, owner: member) } + let(:photo) { FactoryGirl.create(:photo, owner: member) } describe "with valid params" do - let(:member) { FactoryGirl.create(:member) } - let(:garden) { FactoryGirl.create(:garden, owner: member) } - let(:planting) { FactoryGirl.create(:planting, garden: garden, owner: member) } - let(:harvest) { FactoryGirl.create(:harvest, owner: member) } - let(:photo) { FactoryGirl.create(:photo, owner: member) } - before { controller.stub(:current_member) { member } } it "attaches the photo to a planting" do post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id @@ -138,10 +138,8 @@ describe PhotosController do end describe "with matching owners" do + before { controller.stub(:current_member) { member } } it "creates the planting/photo link" do - member = FactoryGirl.create(:member) - controller.stub(:current_member) { member } - garden = FactoryGirl.create(:garden, owner: member) planting = FactoryGirl.create(:planting, garden: garden, owner: member) photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id @@ -150,10 +148,6 @@ describe PhotosController do end it "creates the harvest/photo link" do - member = FactoryGirl.create(:member) - controller.stub(:current_member) { member } - harvest = FactoryGirl.create(:harvest, owner: member) - photo = FactoryGirl.create(:photo, owner: member) post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id expect(flash[:alert]).not_to be_present Photo.last.harvests.first.should eq harvest @@ -164,18 +158,18 @@ describe PhotosController do let(:photo) { FactoryGirl.create(:photo) } it "does not create the planting/photo link" do # members will be auto-created, and different - planting = FactoryGirl.create(:planting) - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id + another_planting = FactoryGirl.create(:planting) + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id expect(flash[:alert]).to be_present - Photo.last.plantings.first.should_not eq planting + Photo.last.plantings.first.should_not eq another_planting end it "does not create the harvest/photo link" do # members will be auto-created, and different - harvest = FactoryGirl.create(:harvest) - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id + another_harvest = FactoryGirl.create(:harvest) + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id expect(flash[:alert]).to be_present - Photo.last.harvests.first.should_not eq harvest + Photo.last.harvests.first.should_not eq another_harvest end end end From 0d6680f574ce9abf3da3a7e872513313b7453278 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:37:10 +1300 Subject: [PATCH 21/24] Disabling rails-pos-args, and documentation in rubocop --- .rubocop.yml | 9 ++++++++- .rubocop_todo.yml | 21 --------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8665b83fa..23f203825 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,4 +45,11 @@ Metrics/LineLength: # Offense count: 8 Metrics/PerceivedComplexity: - Max: 10 \ No newline at end of file + Max: 10 + +# See https://github.com/bbatsov/rubocop/issues/3629 +Rails/HttpPositionalArguments: + Enabled: false + +Style/Documentation: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6a6829835..5bc6935ba 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -38,7 +38,6 @@ Lint/AssignmentInCondition: # SupportedStyles: either, start_of_block, start_of_line Lint/BlockAlignment: Exclude: - - 'spec/controllers/photos_controller_spec.rb' - 'spec/features/signin_spec.rb' - 'spec/models/seed_spec.rb' @@ -162,7 +161,6 @@ Rails/ActionFilter: - 'app/controllers/notifications_controller.rb' - 'app/controllers/order_items_controller.rb' - 'app/controllers/orders_controller.rb' - - 'app/controllers/photos_controller.rb' - 'app/controllers/plantings_controller.rb' - 'app/controllers/posts_controller.rb' - 'app/controllers/products_controller.rb' @@ -195,7 +193,6 @@ Rails/DynamicFindBy: - 'app/controllers/gardens_controller.rb' - 'app/controllers/harvests_controller.rb' - 'app/controllers/notifications_controller.rb' - - 'app/controllers/photos_controller.rb' - 'app/controllers/plantings_controller.rb' - 'app/controllers/posts_controller.rb' - 'app/controllers/scientific_names_controller.rb' @@ -247,7 +244,6 @@ Rails/HttpPositionalArguments: - 'spec/controllers/notifications_controller_spec.rb' - 'spec/controllers/order_items_controller_spec.rb' - 'spec/controllers/orders_controller_spec.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/controllers/places_controller_spec.rb' - 'spec/controllers/plantings_controller_spec.rb' - 'spec/controllers/posts_controller_spec.rb' @@ -335,7 +331,6 @@ Style/AlignHash: - 'app/models/planting.rb' - 'app/models/seed.rb' - 'db/migrate/20150201052245_create_cms.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/models/harvest_spec.rb' - 'spec/models/post_spec.rb' - 'spec/views/notifications/index.html.haml_spec.rb' @@ -354,7 +349,6 @@ Style/AlignParameters: - 'app/controllers/comments_controller.rb' - 'app/controllers/gardens_controller.rb' - 'app/controllers/harvests_controller.rb' - - 'app/controllers/photos_controller.rb' - 'app/controllers/plantings_controller.rb' - 'app/controllers/products_controller.rb' - 'app/helpers/application_helper.rb' @@ -451,7 +445,6 @@ Style/BlockDelimiters: - 'app/controllers/scientific_names_controller.rb' - 'spec/controllers/harvests_controller_spec.rb' - 'spec/controllers/order_items_controller_spec.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/features/notifications_spec.rb' - 'spec/models/ability_spec.rb' - 'spec/models/comment_spec.rb' @@ -492,7 +485,6 @@ Style/BracesAroundHashParameters: - 'spec/controllers/notifications_controller_spec.rb' - 'spec/controllers/order_items_controller_spec.rb' - 'spec/controllers/orders_controller_spec.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/controllers/places_controller_spec.rb' - 'spec/controllers/plantings_controller_spec.rb' - 'spec/controllers/posts_controller_spec.rb' @@ -508,7 +500,6 @@ Style/BracesAroundHashParameters: # SupportedStyles: case, end Style/CaseIndentation: Exclude: - - 'app/controllers/photos_controller.rb' - 'app/helpers/application_helper.rb' - 'app/models/order.rb' - 'db/migrate/20150201052245_create_cms.rb' @@ -834,7 +825,6 @@ Style/ElseAlignment: # SupportedStyles: empty, nil, both Style/EmptyElse: Exclude: - - 'app/controllers/photos_controller.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -849,7 +839,6 @@ Style/EmptyLineBetweenDefs: Style/EmptyLines: Exclude: - 'app/controllers/gardens_controller.rb' - - 'app/controllers/photos_controller.rb' - 'app/models/follow.rb' - 'app/models/member.rb' - 'app/models/post.rb' @@ -874,7 +863,6 @@ Style/EmptyLines: - 'spec/controllers/notifications_controller_spec.rb' - 'spec/controllers/order_items_controller_spec.rb' - 'spec/controllers/orders_controller_spec.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/controllers/places_controller_spec.rb' - 'spec/controllers/plant_parts_controller_spec.rb' - 'spec/controllers/plantings_controller_spec.rb' @@ -1030,7 +1018,6 @@ Style/EmptyLinesAroundBlockBody: - 'spec/controllers/notifications_controller_spec.rb' - 'spec/controllers/order_items_controller_spec.rb' - 'spec/controllers/orders_controller_spec.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/controllers/places_controller_spec.rb' - 'spec/controllers/plant_parts_controller_spec.rb' - 'spec/controllers/plantings_controller_spec.rb' @@ -1305,7 +1292,6 @@ Style/FrozenStringLiteralComment: - 'app/controllers/orders_controller.rb' - 'app/controllers/pages_controller.rb' - 'app/controllers/passwords_controller.rb' - - 'app/controllers/photos_controller.rb' - 'app/controllers/places_controller.rb' - 'app/controllers/plant_parts_controller.rb' - 'app/controllers/plantings_controller.rb' @@ -1513,7 +1499,6 @@ Style/FrozenStringLiteralComment: - 'spec/controllers/notifications_controller_spec.rb' - 'spec/controllers/order_items_controller_spec.rb' - 'spec/controllers/orders_controller_spec.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/controllers/places_controller_spec.rb' - 'spec/controllers/plant_parts_controller_spec.rb' - 'spec/controllers/plantings_controller_spec.rb' @@ -1845,7 +1830,6 @@ Style/IndentHash: - 'config/environments/production.rb' - 'config/environments/staging.rb' - 'config/environments/test.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/lib/actions/oauth_signup_action_spec.rb' # Offense count: 25 @@ -1880,7 +1864,6 @@ Style/IndentationWidth: - 'db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb' - 'lib/tasks/hooks.rake' - 'spec/controllers/harvests_controller_spec.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/features/signin_spec.rb' - 'spec/lib/haml/filters/growstuff_markdown_spec.rb' - 'spec/models/garden_spec.rb' @@ -2029,7 +2012,6 @@ Style/MultilineMethodCallIndentation: # SupportedStyles: aligned, indented Style/MultilineOperationIndentation: Exclude: - - 'app/controllers/photos_controller.rb' - 'app/controllers/registrations_controller.rb' # Offense count: 2 @@ -2159,7 +2141,6 @@ Style/PerlBackrefs: Style/PredicateName: Exclude: - 'spec/**/*' - - 'app/controllers/photos_controller.rb' - 'app/models/member.rb' # Offense count: 1 @@ -2368,7 +2349,6 @@ Style/SpaceInsideHashLiteralBraces: - 'spec/controllers/notifications_controller_spec.rb' - 'spec/controllers/order_items_controller_spec.rb' - 'spec/controllers/orders_controller_spec.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/controllers/plantings_controller_spec.rb' - 'spec/controllers/seeds_controller_spec.rb' - 'spec/views/notifications/show.html.haml_spec.rb' @@ -2382,7 +2362,6 @@ Style/SpaceInsideParens: Exclude: - 'app/models/crop.rb' - 'config/environments/test.rb' - - 'spec/controllers/photos_controller_spec.rb' - 'spec/lib/haml/filters/growstuff_markdown_spec.rb' - 'spec/views/posts/edit.html.haml_spec.rb' From 36d38fe624e86416f8160f4cb592957150684db3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:39:51 +1300 Subject: [PATCH 22/24] Turn off frozen literals requirement --- .rubocop.yml | 3 + .rubocop_todo.yml | 490 ---------------------------------------------- 2 files changed, 3 insertions(+), 490 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 23f203825..fb5297e0b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -53,3 +53,6 @@ Rails/HttpPositionalArguments: Style/Documentation: Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5bc6935ba..7f137a1b9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1264,496 +1264,6 @@ Style/FormatString: - 'spec/helpers/application_helper_spec.rb' - 'spec/views/shop/index_spec.rb' -# Offense count: 485 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: when_needed, always -Style/FrozenStringLiteralComment: - Exclude: - - 'Rakefile' - - 'app/controllers/account_types_controller.rb' - - 'app/controllers/accounts_controller.rb' - - 'app/controllers/admin/orders_controller.rb' - - 'app/controllers/admin_controller.rb' - - 'app/controllers/alternate_names_controller.rb' - - 'app/controllers/application_controller.rb' - - 'app/controllers/authentications_controller.rb' - - 'app/controllers/comments_controller.rb' - - 'app/controllers/crops_controller.rb' - - 'app/controllers/follows_controller.rb' - - 'app/controllers/forums_controller.rb' - - 'app/controllers/gardens_controller.rb' - - 'app/controllers/harvests_controller.rb' - - 'app/controllers/home_controller.rb' - - 'app/controllers/members_controller.rb' - - 'app/controllers/notifications_controller.rb' - - 'app/controllers/omniauth_callbacks_controller.rb' - - 'app/controllers/order_items_controller.rb' - - 'app/controllers/orders_controller.rb' - - 'app/controllers/pages_controller.rb' - - 'app/controllers/passwords_controller.rb' - - 'app/controllers/places_controller.rb' - - 'app/controllers/plant_parts_controller.rb' - - 'app/controllers/plantings_controller.rb' - - 'app/controllers/posts_controller.rb' - - 'app/controllers/products_controller.rb' - - 'app/controllers/registrations_controller.rb' - - 'app/controllers/robots_controller.rb' - - 'app/controllers/roles_controller.rb' - - 'app/controllers/scientific_names_controller.rb' - - 'app/controllers/seeds_controller.rb' - - 'app/controllers/sessions_controller.rb' - - 'app/controllers/shop_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/auto_suggest_helper.rb' - - 'app/helpers/crops_helper.rb' - - 'app/helpers/gardens_helper.rb' - - 'app/helpers/harvests_helper.rb' - - 'app/helpers/notifications_helper.rb' - - 'app/helpers/plantings_helper.rb' - - 'app/helpers/seeds_helper.rb' - - 'app/mailers/notifier.rb' - - 'app/models/ability.rb' - - 'app/models/account.rb' - - 'app/models/account_type.rb' - - 'app/models/alternate_name.rb' - - 'app/models/authentication.rb' - - 'app/models/comment.rb' - - 'app/models/crop.rb' - - 'app/models/follow.rb' - - 'app/models/forum.rb' - - 'app/models/garden.rb' - - 'app/models/harvest.rb' - - 'app/models/member.rb' - - 'app/models/notification.rb' - - 'app/models/order.rb' - - 'app/models/order_item.rb' - - 'app/models/photo.rb' - - 'app/models/plant_part.rb' - - 'app/models/planting.rb' - - 'app/models/post.rb' - - 'app/models/product.rb' - - 'app/models/role.rb' - - 'app/models/scientific_name.rb' - - 'app/models/seed.rb' - - 'app/validators/approved_validator.rb' - - 'bin/bundle' - - 'bin/rails' - - 'bin/rake' - - 'config.rb' - - 'config.ru' - - 'config/application.rb' - - 'config/boot.rb' - - 'config/compass.rb' - - 'config/environment.rb' - - 'config/environments/development.rb' - - 'config/environments/production.rb' - - 'config/environments/staging.rb' - - 'config/environments/test.rb' - - 'config/factory_girl.rb' - - 'config/initializers/backtrace_silencers.rb' - - 'config/initializers/comfortable_mexican_sofa.rb' - - 'config/initializers/devise.rb' - - 'config/initializers/escaped_markdown.rb' - - 'config/initializers/friendly_id.rb' - - 'config/initializers/geocoder.rb' - - 'config/initializers/growstuff_markdown.rb' - - 'config/initializers/inflections.rb' - - 'config/initializers/mime_types.rb' - - 'config/initializers/omniauth.rb' - - 'config/initializers/session_store.rb' - - 'config/initializers/sidekiq.rb' - - 'config/initializers/time_formats.rb' - - 'config/initializers/wrap_parameters.rb' - - 'config/routes.rb' - - 'config/setup_load_paths.rb' - - 'config/unicorn.rb' - - 'db/migrate/20120903092956_devise_create_users.rb' - - 'db/migrate/20120903112806_add_username_to_users.rb' - - 'db/migrate/20121001212604_create_crops.rb' - - 'db/migrate/20121003190731_require_system_name_for_crops.rb' - - 'db/migrate/20121027035231_add_slug_to_crops.rb' - - 'db/migrate/20121105032913_create_gardens.rb' - - 'db/migrate/20121106101718_add_slug_to_users.rb' - - 'db/migrate/20121107012827_create_scientific_names.rb' - - 'db/migrate/20121108105440_create_updates.rb' - - 'db/migrate/20121109130033_add_creation_index_to_updates.rb' - - 'db/migrate/20121203034745_add_tos_agreement_to_users.rb' - - 'db/migrate/20121214224227_add_slug_to_updates.rb' - - 'db/migrate/20121219022554_create_plantings.rb' - - 'db/migrate/20130113045802_rename_updates_to_posts.rb' - - 'db/migrate/20130113060852_rename_users_to_members.rb' - - 'db/migrate/20130113081521_rename_post_member_to_author.rb' - - 'db/migrate/20130113095802_rename_garden_member_to_owner.rb' - - 'db/migrate/20130118031942_add_description_to_gardens.rb' - - 'db/migrate/20130118043431_add_slug_to_plantings.rb' - - 'db/migrate/20130206033956_create_comments.rb' - - 'db/migrate/20130206051328_add_show_email_to_member.rb' - - 'db/migrate/20130208034248_require_fields_for_comments.rb' - - 'db/migrate/20130212001748_add_geo_to_members.rb' - - 'db/migrate/20130212123628_create_notifications.rb' - - 'db/migrate/20130213014511_create_forums.rb' - - 'db/migrate/20130213015708_add_forum_to_posts.rb' - - 'db/migrate/20130214024117_create_roles.rb' - - 'db/migrate/20130214034838_add_members_roles_table.rb' - - 'db/migrate/20130215131921_rename_notification_fields.rb' - - 'db/migrate/20130220044605_add_slug_to_forums.rb' - - 'db/migrate/20130220044642_add_slug_to_roles.rb' - - 'db/migrate/20130222060730_default_read_to_false.rb' - - 'db/migrate/20130326092227_change_planted_at_to_date.rb' - - 'db/migrate/20130327120024_add_send_email_to_member.rb' - - 'db/migrate/20130329045744_add_sunniness_to_planting.rb' - - 'db/migrate/20130404174459_create_authentications.rb' - - 'db/migrate/20130409103549_make_post_subject_non_null.rb' - - 'db/migrate/20130409162140_add_name_to_authentications.rb' - - 'db/migrate/20130507105357_create_products.rb' - - 'db/migrate/20130507110411_create_orders.rb' - - 'db/migrate/20130507113915_add_orders_products_table.rb' - - 'db/migrate/20130508050711_add_completed_to_order.rb' - - 'db/migrate/20130508104506_create_photos.rb' - - 'db/migrate/20130509123711_add_metadata_to_photos.rb' - - 'db/migrate/20130514124515_add_parent_to_crop.rb' - - 'db/migrate/20130515033842_create_order_items.rb' - - 'db/migrate/20130515054017_change_order_member_id_to_integer.rb' - - 'db/migrate/20130515122301_change_prices_to_integers.rb' - - 'db/migrate/20130517015920_create_account_details.rb' - - 'db/migrate/20130517051922_create_account_types.rb' - - 'db/migrate/20130517234458_require_account_type_name.rb' - - 'db/migrate/20130518000339_add_columns_to_product.rb' - - 'db/migrate/20130518002942_rename_account_detail_to_account.rb' - - 'db/migrate/20130529032813_add_express_token_to_orders.rb' - - 'db/migrate/20130531110729_add_photos_plantings_table.rb' - - 'db/migrate/20130601011725_change_flickr_photo_id_to_string.rb' - - 'db/migrate/20130606230333_change_product_description_to_text.rb' - - 'db/migrate/20130606233733_add_recommended_price_to_product.rb' - - 'db/migrate/20130705104238_add_planted_from_to_planting.rb' - - 'db/migrate/20130715110134_create_seeds.rb' - - 'db/migrate/20130718005600_change_use_by_to_plant_before_on_seed.rb' - - 'db/migrate/20130718011247_add_trading_to_seeds.rb' - - 'db/migrate/20130722050836_remove_tradable_from_seeds.rb' - - 'db/migrate/20130723103128_set_default_tradable_to_on_seed.rb' - - 'db/migrate/20130723110702_add_slug_to_seed.rb' - - 'db/migrate/20130809012511_add_bio_to_members.rb' - - 'db/migrate/20130819004549_add_planting_count_to_crop.rb' - - 'db/migrate/20130821011352_add_creator_to_crops.rb' - - 'db/migrate/20130821073736_add_creator_to_scientific_name.rb' - - 'db/migrate/20130826012139_add_owner_to_planting.rb' - - 'db/migrate/20130826023159_add_plantings_count_to_member.rb' - - 'db/migrate/20130827105823_add_newsletter_to_member.rb' - - 'db/migrate/20130913015118_add_referral_code_to_order.rb' - - 'db/migrate/20130917053547_create_harvests.rb' - - 'db/migrate/20130917060257_change_harvest_notes_to_description.rb' - - 'db/migrate/20130917071545_change_harvest_units_to_unit.rb' - - 'db/migrate/20130917075803_add_slug_to_harvests.rb' - - 'db/migrate/20130925050304_add_weight_to_harvests.rb' - - 'db/migrate/20131018101204_rename_system_name_to_name.rb' - - 'db/migrate/20131025104228_add_fields_to_gardens.rb' - - 'db/migrate/20131029053113_add_plant_part_to_harvests.rb' - - 'db/migrate/20131030230908_create_plant_parts.rb' - - 'db/migrate/20131030231202_change_plant_part_to_plant_part_id.rb' - - 'db/migrate/20131031000655_add_slug_to_plant_part.rb' - - 'db/migrate/20140718075753_default_plantings_count_to_zero.rb' - - 'db/migrate/20140829230600_add_finished_to_planting.rb' - - 'db/migrate/20140905001730_add_harvests_photos_table.rb' - - 'db/migrate/20140928044231_add_crops_posts_table.rb' - - 'db/migrate/20140928085713_add_send_planting_reminder_to_member.rb' - - 'db/migrate/20141002022459_create_index_harvest_photos.rb' - - 'db/migrate/20141018111015_create_alternate_names.rb' - - 'db/migrate/20141111130849_create_follows.rb' - - 'db/migrate/20141119130555_change_follows_member_id_to_follower_id.rb' - - 'db/migrate/20150124110540_add_properties_to_seeds.rb' - - 'db/migrate/20150127043022_add_gardens_photos_table.rb' - - 'db/migrate/20150129034206_add_si_weight_to_harvest.rb' - - 'db/migrate/20150130224814_add_requester_to_crops.rb' - - 'db/migrate/20150201052245_create_cms.rb' - - 'db/migrate/20150201053200_add_approval_status_to_crops.rb' - - 'db/migrate/20150201062506_add_reason_for_rejection_to_crops.rb' - - 'db/migrate/20150201064502_add_request_notes_to_crops.rb' - - 'db/migrate/20150209105410_add_rejection_notes_to_crops.rb' - - 'db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb' - - 'db/migrate/20150824145414_add_member_preferred_image.rb' - - 'db/seeds.rb' - - 'lib/actions/oauth_signup_action.rb' - - 'lib/geocodable.rb' - - 'lib/haml/filters/escaped_markdown.rb' - - 'lib/haml/filters/growstuff_markdown.rb' - - 'lib/tasks/growstuff.rake' - - 'lib/tasks/hooks.rake' - - 'lib/tasks/testing.rake' - - 'script/check_contributors_md' - - 'script/gemfile_check' - - 'script/heroku_maintenance.rb' - - 'script/rails' - - 'spec/controllers/account_types_controller_spec.rb' - - 'spec/controllers/accounts_controller_spec.rb' - - 'spec/controllers/admin/orders_controller_spec.rb' - - 'spec/controllers/admin_controller_spec.rb' - - 'spec/controllers/authentications_controller_spec.rb' - - 'spec/controllers/comments_controller_spec.rb' - - 'spec/controllers/crops_controller_spec.rb' - - 'spec/controllers/forums_controller_spec.rb' - - 'spec/controllers/gardens_controller_spec.rb' - - 'spec/controllers/harvests_controller_spec.rb' - - 'spec/controllers/home_controller_spec.rb' - - 'spec/controllers/member_controller_spec.rb' - - 'spec/controllers/notifications_controller_spec.rb' - - 'spec/controllers/order_items_controller_spec.rb' - - 'spec/controllers/orders_controller_spec.rb' - - 'spec/controllers/places_controller_spec.rb' - - 'spec/controllers/plant_parts_controller_spec.rb' - - 'spec/controllers/plantings_controller_spec.rb' - - 'spec/controllers/posts_controller_spec.rb' - - 'spec/controllers/products_controller_spec.rb' - - 'spec/controllers/registrations_controller_spec.rb' - - 'spec/controllers/robots_controller_spec.rb' - - 'spec/controllers/roles_controller_spec.rb' - - 'spec/controllers/scientific_names_controller_spec.rb' - - 'spec/controllers/seeds_controller_spec.rb' - - 'spec/controllers/shop_controller_spec.rb' - - 'spec/custom_matchers.rb' - - 'spec/factories/account_types.rb' - - 'spec/factories/accounts.rb' - - 'spec/factories/alternate_names.rb' - - 'spec/factories/authentications.rb' - - 'spec/factories/comments.rb' - - 'spec/factories/crop.rb' - - 'spec/factories/follows.rb' - - 'spec/factories/forums.rb' - - 'spec/factories/garden.rb' - - 'spec/factories/harvests.rb' - - 'spec/factories/member.rb' - - 'spec/factories/notifications.rb' - - 'spec/factories/order_items.rb' - - 'spec/factories/orders.rb' - - 'spec/factories/photos.rb' - - 'spec/factories/plant_parts.rb' - - 'spec/factories/planting.rb' - - 'spec/factories/post.rb' - - 'spec/factories/products.rb' - - 'spec/factories/roles.rb' - - 'spec/factories/scientific_name.rb' - - 'spec/factories/seeds.rb' - - 'spec/features/admin/account_types_spec.rb' - - 'spec/features/admin/forums_spec.rb' - - 'spec/features/admin/products_spec.rb' - - 'spec/features/cms_spec.rb' - - 'spec/features/comments/commenting_a_comment_spec.rb' - - 'spec/features/crops/alternate_name_spec.rb' - - 'spec/features/crops/browse_crops_spec.rb' - - 'spec/features/crops/creating_a_crop_spec.rb' - - 'spec/features/crops/crop_detail_page_spec.rb' - - 'spec/features/crops/crop_search_spec.rb' - - 'spec/features/crops/crop_wranglers_spec.rb' - - 'spec/features/crops/crop_wrangling_button_spec.rb' - - 'spec/features/crops/inflections_spec.rb' - - 'spec/features/crops/request_new_crop_spec.rb' - - 'spec/features/following_spec.rb' - - 'spec/features/footer_spec.rb' - - 'spec/features/gardens/adding_gardens_spec.rb' - - 'spec/features/gardens_spec.rb' - - 'spec/features/harvests/browse_harvests_spec.rb' - - 'spec/features/harvests/harvesting_a_crop_spec.rb' - - 'spec/features/locale_spec.rb' - - 'spec/features/member_profile_spec.rb' - - 'spec/features/members_list_spec.rb' - - 'spec/features/notifications_spec.rb' - - 'spec/features/photos/show_photo_spec.rb' - - 'spec/features/places/searching_a_place_spec.rb' - - 'spec/features/planting_reminder_spec.rb' - - 'spec/features/plantings/planting_a_crop_spec.rb' - - 'spec/features/posts/posting_a_post_spec.rb' - - 'spec/features/rss/comments_spec.rb' - - 'spec/features/rss/crops_spec.rb' - - 'spec/features/rss/members_spec.rb' - - 'spec/features/rss/plantings_spec.rb' - - 'spec/features/rss/posts_spec.rb' - - 'spec/features/rss/seeds_spec.rb' - - 'spec/features/scientific_name_spec.rb' - - 'spec/features/seeds/adding_seeds_spec.rb' - - 'spec/features/seeds/misc_seeds_spec.rb' - - 'spec/features/shared_examples/append_date.rb' - - 'spec/features/shared_examples/crop_suggest.rb' - - 'spec/features/signin_spec.rb' - - 'spec/features/signout_spec.rb' - - 'spec/features/signup_spec.rb' - - 'spec/features/unsubscribing_spec.rb' - - 'spec/helpers/application_helper_spec.rb' - - 'spec/helpers/crops_helper_spec.rb' - - 'spec/helpers/gardens_helper_spec.rb' - - 'spec/helpers/harvests_helper_spec.rb' - - 'spec/helpers/notifications_helper_spec.rb' - - 'spec/helpers/plantings_helper_spec.rb' - - 'spec/helpers/seeds_helper_spec.rb' - - 'spec/lib/actions/oauth_signup_action_spec.rb' - - 'spec/lib/haml/filters/escaped_markdown_spec.rb' - - 'spec/lib/haml/filters/growstuff_markdown_spec.rb' - - 'spec/mailers/notifier_spec.rb' - - 'spec/models/ability_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/account_type_spec.rb' - - 'spec/models/alternate_name_spec.rb' - - 'spec/models/authentication_spec.rb' - - 'spec/models/comment_spec.rb' - - 'spec/models/crop_spec.rb' - - 'spec/models/follow_spec.rb' - - 'spec/models/forum_spec.rb' - - 'spec/models/garden_spec.rb' - - 'spec/models/harvest_spec.rb' - - 'spec/models/member_spec.rb' - - 'spec/models/notification_spec.rb' - - 'spec/models/order_item_spec.rb' - - 'spec/models/order_spec.rb' - - 'spec/models/photo_spec.rb' - - 'spec/models/plant_part_spec.rb' - - 'spec/models/planting_spec.rb' - - 'spec/models/post_spec.rb' - - 'spec/models/product_spec.rb' - - 'spec/models/role_spec.rb' - - 'spec/models/scientific_name_spec.rb' - - 'spec/models/seed_spec.rb' - - 'spec/rails_helper.rb' - - 'spec/requests/authentications_spec.rb' - - 'spec/requests/comments_spec.rb' - - 'spec/requests/forums_spec.rb' - - 'spec/requests/gardens_spec.rb' - - 'spec/requests/harvests_spec.rb' - - 'spec/requests/notifications_spec.rb' - - 'spec/requests/photos_spec.rb' - - 'spec/requests/plant_parts_spec.rb' - - 'spec/requests/plantings_spec.rb' - - 'spec/requests/post_spec.rb' - - 'spec/requests/scientific_names_spec.rb' - - 'spec/requests/seeds_spec.rb' - - 'spec/routing/account_types_routing_spec.rb' - - 'spec/routing/authentications_routing_spec.rb' - - 'spec/routing/comments_routing_spec.rb' - - 'spec/routing/crops_routing_spec.rb' - - 'spec/routing/follows_routing_spec.rb' - - 'spec/routing/forums_routing_spec.rb' - - 'spec/routing/gardens_routing_spec.rb' - - 'spec/routing/harvests_routing_spec.rb' - - 'spec/routing/notifications_routing_spec.rb' - - 'spec/routing/order_items_routing_spec.rb' - - 'spec/routing/orders_routing_spec.rb' - - 'spec/routing/photos_routing_spec.rb' - - 'spec/routing/plant_parts_routing_spec.rb' - - 'spec/routing/plantings_routing_spec.rb' - - 'spec/routing/products_routing_spec.rb' - - 'spec/routing/roles_routing_spec.rb' - - 'spec/routing/scientific_names_routing_spec.rb' - - 'spec/routing/seeds_routing_spec.rb' - - 'spec/routing/updates_routing_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/support/controller_macros.rb' - - 'spec/support/database_cleaner.rb' - - 'spec/support/devise.rb' - - 'spec/support/elasticsearch_helpers.rb' - - 'spec/support/feature_helpers.rb' - - 'spec/views/account_types/edit.html.haml_spec.rb' - - 'spec/views/account_types/index.html.haml_spec.rb' - - 'spec/views/account_types/new.html.haml_spec.rb' - - 'spec/views/account_types/show.html.haml_spec.rb' - - 'spec/views/accounts/edit.html.haml_spec.rb' - - 'spec/views/accounts/index.html.haml_spec.rb' - - 'spec/views/accounts/new.html.haml_spec.rb' - - 'spec/views/accounts/show.html.haml_spec.rb' - - 'spec/views/admin/index_spec.rb' - - 'spec/views/admin/newsletter_spec.rb' - - 'spec/views/admin/orders/index_spec.rb' - - 'spec/views/comments/edit.html.haml_spec.rb' - - 'spec/views/comments/index.html.haml_spec.rb' - - 'spec/views/comments/index.rss.haml_spec.rb' - - 'spec/views/comments/new.html.haml_spec.rb' - - 'spec/views/comments/show.html.haml_spec.rb' - - 'spec/views/crops/_grown_for.html.haml_spec.rb' - - 'spec/views/crops/_planting_advice.html.haml_spec.rb' - - 'spec/views/crops/_popover.html.haml_spec.rb' - - 'spec/views/crops/edit.html.haml_spec.rb' - - 'spec/views/crops/hierarchy.html.haml_spec.rb' - - 'spec/views/crops/index.html.haml_spec.rb' - - 'spec/views/crops/index.rss.haml_spec.rb' - - 'spec/views/crops/new.html.haml_spec.rb' - - 'spec/views/crops/wrangle.html.haml_spec.rb' - - 'spec/views/devise/confirmations/new_spec.rb' - - 'spec/views/devise/mailer/confirmation_instructions_spec.rb' - - 'spec/views/devise/mailer/reset_password_instructions_spec.rb' - - 'spec/views/devise/mailer/unlock_instructions_spec.rb' - - 'spec/views/devise/registrations/edit_spec.rb' - - 'spec/views/devise/registrations/new_spec.rb' - - 'spec/views/devise/sessions/new_spec.rb' - - 'spec/views/devise/shared/_links_spec.rb' - - 'spec/views/devise/unlocks/new_spec.rb' - - 'spec/views/forums/edit.html.haml_spec.rb' - - 'spec/views/forums/index.html.haml_spec.rb' - - 'spec/views/forums/new.html.haml_spec.rb' - - 'spec/views/forums/show.html.haml_spec.rb' - - 'spec/views/gardens/edit.html.haml_spec.rb' - - 'spec/views/gardens/new.html.haml_spec.rb' - - 'spec/views/gardens/show.html.haml_spec.rb' - - 'spec/views/harvests/edit.html.haml_spec.rb' - - 'spec/views/harvests/index.html.haml_spec.rb' - - 'spec/views/harvests/new.html.haml_spec.rb' - - 'spec/views/harvests/show.html.haml_spec.rb' - - 'spec/views/home/_blurb.html.haml_spec.rb' - - 'spec/views/home/_crops.html.haml_spec.rb' - - 'spec/views/home/_members.html.haml_spec.rb' - - 'spec/views/home/_seeds.html.haml_spec.rb' - - 'spec/views/home/_stats.html.haml_spec.rb' - - 'spec/views/home/index_spec.rb' - - 'spec/views/layouts/_header_spec.rb' - - 'spec/views/layouts/_meta_spec.rb' - - 'spec/views/layouts/application_spec.rb' - - 'spec/views/members/_location.html.haml_spec.rb' - - 'spec/views/members/index.html.haml_spec.rb' - - 'spec/views/members/show.rss.haml_spec.rb' - - 'spec/views/notifications/index.html.haml_spec.rb' - - 'spec/views/notifications/new.html.haml_spec.rb' - - 'spec/views/notifications/show.html.haml_spec.rb' - - 'spec/views/notifier/notify.html.haml_spec.rb' - - 'spec/views/orders/index.html.haml_spec.rb' - - 'spec/views/orders/show.html.haml_spec.rb' - - 'spec/views/photos/edit.html.haml_spec.rb' - - 'spec/views/photos/index.html.haml_spec.rb' - - 'spec/views/photos/new.html.haml_spec.rb' - - 'spec/views/photos/show.html.haml_spec.rb' - - 'spec/views/places/_map_attribution.html.haml_spec.rb' - - 'spec/views/places/index.html.haml_spec.rb' - - 'spec/views/places/show.html.haml_spec.rb' - - 'spec/views/plant_parts/edit.html.haml_spec.rb' - - 'spec/views/plant_parts/index.html.haml_spec.rb' - - 'spec/views/plant_parts/new.html.haml_spec.rb' - - 'spec/views/plant_parts/show.html.haml_spec.rb' - - 'spec/views/plantings/_form.html.haml_spec.rb' - - 'spec/views/plantings/edit.html.haml_spec.rb' - - 'spec/views/plantings/index.html.haml_spec.rb' - - 'spec/views/plantings/index.rss.haml_spec.rb' - - 'spec/views/plantings/new.html.haml_spec.rb' - - 'spec/views/plantings/show.html.haml_spec.rb' - - 'spec/views/posts/_single.html.haml_spec.rb' - - 'spec/views/posts/edit.html.haml_spec.rb' - - 'spec/views/posts/index.html.haml_spec.rb' - - 'spec/views/posts/index.rss.haml_spec.rb' - - 'spec/views/posts/new.html.haml_spec.rb' - - 'spec/views/posts/show.html.haml_spec.rb' - - 'spec/views/posts/show.rss.haml_spec.rb' - - 'spec/views/products/edit.html.haml_spec.rb' - - 'spec/views/products/index.html.haml_spec.rb' - - 'spec/views/products/new.html.haml_spec.rb' - - 'spec/views/products/show.html.haml_spec.rb' - - 'spec/views/roles/edit.html.haml_spec.rb' - - 'spec/views/roles/index.html.haml_spec.rb' - - 'spec/views/roles/new.html.haml_spec.rb' - - 'spec/views/roles/show.html.haml_spec.rb' - - 'spec/views/scientific_names/edit.html.haml_spec.rb' - - 'spec/views/scientific_names/index.html.haml_spec.rb' - - 'spec/views/scientific_names/new.html.haml_spec.rb' - - 'spec/views/scientific_names/show.html.haml_spec.rb' - - 'spec/views/seeds/edit.html.haml_spec.rb' - - 'spec/views/seeds/index.rss.haml_spec.rb' - - 'spec/views/seeds/new.html.haml_spec.rb' - - 'spec/views/seeds/show.html.haml_spec.rb' - - 'spec/views/shop/index_spec.rb' - # Offense count: 35 # Configuration parameters: MinBodyLength. Style/GuardClause: From 069343803ee2c6a0e10cd438f855e0d04da9ba91 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 20 Nov 2016 21:46:58 +1300 Subject: [PATCH 23/24] List of types that can have photos in own method --- app/controllers/photos_controller.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 1409ba748..e7e8584d3 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -117,15 +117,13 @@ class PhotosController < ApplicationController @photo end + def allowed_types + %w(garden harvest planting) + end + def which_collection? - case params[:type] - when 'garden' - @photo.gardens - when 'planting' - @photo.plantings - when 'harvest' - @photo.harvests - end + return unless allowed_types.include?(params[:type]) + @photo.send(params[:type].pluralize.to_sym) end def add_photo_to_collection @@ -145,7 +143,6 @@ class PhotosController < ApplicationController end def which_item? - allowed_types = %w(planting garden harvest) item_type = params[:type] item_type.camelcase.constantize.find(params[:id]) if allowed_types.include? item_type end From fb6f1ac0a889852a5e3fa3cdab2351bdfdd93a70 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Nov 2016 09:52:43 +1300 Subject: [PATCH 24/24] Changed whitelisting of what can have photos --- app/controllers/photos_controller.rb | 37 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index e7e8584d3..64583a143 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -96,10 +96,6 @@ class PhotosController < ApplicationController params.key? :id end - def member_owns_item(item) - item.owner.id == current_member.id - end - def flickr_photo_id_param params[:photo][:flickr_photo_id] end @@ -117,13 +113,13 @@ class PhotosController < ApplicationController @photo end - def allowed_types - %w(garden harvest planting) - end - def which_collection? - return unless allowed_types.include?(params[:type]) - @photo.send(params[:type].pluralize.to_sym) + case params[:type] + when "garden" then @photo.gardens + when "harvest" then @photo.harvests + when "planting" then @photo.plantings + else raise "Invalid type" + end end def add_photo_to_collection @@ -134,16 +130,19 @@ class PhotosController < ApplicationController return end - item = which_item? - if item && member_owns_item(item) - collection << item unless collection.include?(item) - else - flash[:alert] = "Could not find this item owned by you" - end + item = find_item_for_photo! + collection << item unless collection.include?(item) + rescue + flash[:alert] = "Could not find this item owned by you" end - def which_item? - item_type = params[:type] - item_type.camelcase.constantize.find(params[:id]) if allowed_types.include? item_type + def find_item_for_photo! + item_class = case params[:type] + when "garden" then Garden + when "harvest" then Harvest + when "planting" then Planting + else raise "Invalid type" + end + item_class.find_by!(id: params[:id], owner_id: current_member.id) end end