From c6824b126288a4788ea9640fa38e4f8da2b8d67b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 22:51:55 +1300 Subject: [PATCH 01/56] Planting's owner must be the same as its garden's owner --- app/models/planting.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/planting.rb b/app/models/planting.rb index f5f482a5d..4fe2ccc0a 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -50,6 +50,7 @@ class Planting < ActiveRecord::Base validates :garden, presence: true validates :crop, presence: true, approved: { message: "must be present and exist in our database" } validate :finished_must_be_after_planted + validate :owner_must_match_garden_owner validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } @@ -142,4 +143,8 @@ class Planting < ActiveRecord::Base return unless planted_at && finished_at # only check if we have both errors.add(:finished_at, "must be after the planting date") unless planted_at < finished_at end + + def owner_must_match_garden_owner + errors.add(:owner, "must be the same as garden") unless owner == garden.owner + end end From 7ca76e69cf1c187da4b1fe28be1f942248ebe519 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 22:52:40 +1300 Subject: [PATCH 02/56] Get planting factory's owner from its garden --- spec/factories/planting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index 2deb014c5..2bcfac397 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :planting do - garden owner + garden { FactoryBot.create :garden, owner: owner } crop planted_at Time.zone.local(2014, 7, 30) quantity 33 From a2ae429f6b1d17604a52f801209ef0195f0db056 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Nov 2017 15:51:29 +1300 Subject: [PATCH 03/56] If a harvest has a planting, it must have the same owner --- app/models/harvest.rb | 6 ++++++ spec/factories/harvests.rb | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 21339ab47..c2ad7eab1 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -58,6 +58,7 @@ class Harvest < ActiveRecord::Base in: WEIGHT_UNITS_VALUES.values, message: "%s is not a valid unit" } validate :crop_must_match_planting + validate :owner_must_match_planting validate :harvest_must_be_after_planting def time_from_planting_to_harvest @@ -131,6 +132,11 @@ class Harvest < ActiveRecord::Base errors.add(:planting, "must be the same crop") unless crop == planting.crop end + def owner_must_match_planting + return if planting.blank? # only check if we are linked to a planting + errors.add(:owner, "of harvest must be the same as planting") unless owner == planting.owner + end + def harvest_must_be_after_planting # only check if we are linked to a planting return unless harvested_at.present? && planting.present? && planting.planted_at.present? diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index e1ff04fb3..c910f49da 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -4,7 +4,8 @@ FactoryBot.define do factory :harvest do crop plant_part - owner + planting + owner { planting.owner } harvested_at Time.zone.local(2015, 9, 17) quantity "3" unit "individual" From 2fbba52bc8929b226627e20dbbe3126b847b9d24 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 22:53:07 +1300 Subject: [PATCH 04/56] Updating specs to use same owner for garden and planting --- spec/controllers/harvests_controller_spec.rb | 101 +++++++++--------- spec/factories/harvests.rb | 10 +- spec/features/gardens_spec.rb | 4 +- .../plantings/planting_a_crop_spec.rb | 4 +- spec/models/crop_spec.rb | 34 +++--- spec/models/garden_spec.rb | 40 +++---- spec/models/planting_spec.rb | 16 ++- spec/views/crops/_grown_for.html.haml_spec.rb | 18 ++-- .../crops/_planting_advice.html.haml_spec.rb | 82 +++++++------- spec/views/gardens/show.html.haml_spec.rb | 2 +- spec/views/harvests/show.html.haml_spec.rb | 17 +-- spec/views/plantings/_form.html.haml_spec.rb | 1 + spec/views/plantings/edit.html.haml_spec.rb | 2 +- spec/views/plantings/index.html.haml_spec.rb | 40 +++---- spec/views/plantings/new.html.haml_spec.rb | 3 +- spec/views/plantings/show.html.haml_spec.rb | 42 +++----- 16 files changed, 213 insertions(+), 203 deletions(-) diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index ff4972a7a..c0dea9f2e 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -25,63 +25,61 @@ describe HarvestsController do end describe "GET index" do - before do - @member1 = FactoryBot.create(:member) - @member2 = FactoryBot.create(:member) - @tomato = FactoryBot.create(:tomato) - @maize = FactoryBot.create(:maize) - @harvest1 = FactoryBot.create(:harvest, owner_id: @member1.id, crop_id: @tomato.id) - @harvest2 = FactoryBot.create(:harvest, owner_id: @member2.id, crop_id: @maize.id) + let(:member1) { FactoryBot.create(:member) } + let(:member2) { FactoryBot.create(:member) } + let(:tomato) { FactoryBot.create(:tomato) } + let(:maize) { FactoryBot.create(:maize) } + let(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } + let(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } + + describe "assigns all harvests as @harvests" do + before { get :index, {} } + it { assigns(:harvests).should =~ [harvest1, harvest2] } end - it "assigns all harvests as @harvests" do - get :index, {} - assigns(:harvests).should =~ [@harvest1, @harvest2] + describe "picks up owner from params and shows owner's harvests only" do + before { get :index, owner: member1.slug } + it { expect(assigns(:owner)).to eq member1 } + it { expect(assigns(:harvests)).to eq [harvest1] } end - it "picks up owner from params and shows owner's harvests only" do - get :index, owner: @member1.slug - assigns(:owner).should eq @member1 - assigns(:harvests).should eq [@harvest1] + describe "picks up crop from params and shows the harvests for the crop only" do + before { get :index, crop: maize.name } + it { expect(assigns(:crop)).to eq maize } + it { expect(assigns(:harvests)).to eq [harvest2] } end - it "picks up crop from params and shows the harvests for the crop only" do - get :index, crop: @maize.name - assigns(:crop).should eq @maize - assigns(:harvests).should eq [@harvest2] - end - - it "generates a csv" do - get :index, format: "csv" - response.status.should eq 200 + describe "generates a csv" do + before { get :index, format: "csv" } + it { expect(response.status).to eq 200 } end end describe "GET show" do - it "assigns the requested harvest as @harvest" do - harvest = Harvest.create! valid_attributes - get :show, id: harvest.to_param - assigns(:harvest).should eq(harvest) + let(:harvest) { Harvest.create! valid_attributes } + describe "assigns the requested harvest as @harvest" do + before { get :show, id: harvest.to_param } + it { expect(assigns(:harvest)).to eq(harvest) } end end describe "GET new" do - it "assigns a new harvest as @harvest" do - get :new, {} - assigns(:harvest).should be_a_new(Harvest) + before { get :new, {} } + + describe "assigns a new harvest as @harvest" do + it { expect(assigns(:harvest)).to be_a_new(Harvest) } end - it "sets the date of the harvest to today" do - get :new, {} - assigns(:harvest).harvested_at.should == Time.zone.today + describe "sets the date of the harvest to today" do + it { expect(assigns(:harvest).harvested_at).to eq(Time.zone.today) } end end describe "GET edit" do - it "assigns the requested harvest as @harvest" do - harvest = Harvest.create! valid_attributes - get :edit, id: harvest.to_param - assigns(:harvest).should eq(harvest) + let(:harvest) { Harvest.create! valid_attributes } + describe "assigns the requested harvest as @harvest" do + before { get :edit, id: harvest.to_param } + it { expect(assigns(:harvest)).to eq(harvest) } end end @@ -104,10 +102,10 @@ describe HarvestsController do response.should redirect_to(Harvest.last) end - it "links to planting" do - planting = FactoryBot.create(:planting, owner_id: member.id) - post :create, harvest: valid_attributes.merge(planting_id: planting.id) - expect(Harvest.last.planting.id).to eq(planting.id) + describe "links to planting" do + let(:planting) { FactoryBot.create(:planting, owner_id: member.id, garden: member.gardens.first) } + before { post :create, harvest: valid_attributes.merge(planting_id: planting.id) } + it { expect(Harvest.last.planting.id).to eq(planting.id) } end end @@ -129,10 +127,13 @@ describe HarvestsController do describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - it "does not save planting_id" do - allow(Harvest).to receive(:new).and_return(harvest) - post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) - expect(harvest.planting_id).to eq(nil) + + describe "does not save planting_id" do + before do + allow(Harvest).to receive(:new).and_return(harvest) + post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) + end + it { expect(harvest.planting_id).not_to eq(not_my_planting.id) } end end end @@ -181,10 +182,12 @@ describe HarvestsController do describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - it "does not save planting_id" do - put :update, id: harvest.to_param, - harvest: valid_attributes.merge(planting_id: not_my_planting.id) - expect(harvest.planting_id).to eq(nil) + describe "does not save planting_id" do + before do + put :update, id: harvest.to_param, + harvest: valid_attributes.merge(planting_id: not_my_planting.id) + end + it { expect(harvest.planting_id).to eq(nil) } end end end diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index c910f49da..c707a2e2c 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -2,16 +2,20 @@ FactoryBot.define do factory :harvest do - crop + crop { planting.present? ? planting.crop : FactoryBot.create(:crop) } plant_part - planting - owner { planting.owner } + planting nil + owner { planting.present? ? planting.owner : FactoryBot.create(:member) } harvested_at Time.zone.local(2015, 9, 17) quantity "3" unit "individual" weight_quantity 6 weight_unit "kg" description "A lovely harvest" + + factory :harvest_with_planting do + planting + end end trait :long_description do diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 3d78cbe5d..e9a20d060 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -2,9 +2,9 @@ require 'rails_helper' feature "Planting a crop", js: true do let!(:garden) { create :garden } - let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") } + let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse("2013-3-10") } let!(:tomato) { create :tomato } - let!(:finished_planting) { create :finished_planting, garden: garden, crop: tomato } + let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden: garden, crop: tomato } background do login_as garden.owner diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 177cf9942..0c984837b 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -5,7 +5,9 @@ feature "Planting a crop", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } - let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") } + let!(:planting) do + create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") + end background do login_as member diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 406a65eb0..860e2e935 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -348,7 +348,23 @@ describe Crop do end end + let(:maize) { FactoryBot.create(:maize) } + let(:pp1) { FactoryBot.create(:plant_part) } + let(:pp2) { FactoryBot.create(:plant_part) } + context "harvests" do + let(:h1) do + FactoryBot.create(:harvest, + crop: maize, + plant_part: pp1) + end + + let(:h2) do + FactoryBot.create(:harvest, + crop: maize, + plant_part: pp2) + end + it "has harvests" do crop = FactoryBot.create(:crop) harvest = FactoryBot.create(:harvest, crop: crop) @@ -356,20 +372,6 @@ describe Crop do end end - it 'has plant_parts' do - @maize = FactoryBot.create(:maize) - @pp1 = FactoryBot.create(:plant_part) - @pp2 = FactoryBot.create(:plant_part) - @h1 = FactoryBot.create(:harvest, - crop: @maize, - plant_part: @pp1) - @h2 = FactoryBot.create(:harvest, - crop: @maize, - plant_part: @pp2) - @maize.plant_parts.should include @pp1 - @maize.plant_parts.should include @pp2 - end - it "doesn't duplicate plant_parts" do @maize = FactoryBot.create(:maize) @pp1 = FactoryBot.create(:plant_part) @@ -385,9 +387,7 @@ describe Crop do context "search", :elasticsearch do let(:mushroom) { FactoryBot.create(:crop, name: 'mushroom') } - before do - sync_elasticsearch([mushroom]) - end + before { sync_elasticsearch([mushroom]) } it "finds exact matches" do Crop.search('mushroom').should eq [mushroom] diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index 867b333d1..cbb097d91 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -64,30 +64,30 @@ describe Garden do let(:walnut) { FactoryBot.create(:walnut) } it "should fetch < 4 featured plantings if insufficient exist" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p2, @p1] end it "should fetch most recent 4 featured plantings" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) - @p3 = FactoryBot.create(:planting, crop: chard, garden: garden) - @p4 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) + @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) + @p4 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end it "should skip repeated plantings" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) - @p3 = FactoryBot.create(:planting, crop: chard, garden: garden) - @p4 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden) - @p6 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p7 = FactoryBot.create(:planting, crop: pear, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) + @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) + @p4 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden, owner: garden.owner) + @p6 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p7 = FactoryBot.create(:planting, crop: pear, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p7, @p6, @p5, @p3] end @@ -103,8 +103,8 @@ describe Garden do it "destroys plantings when deleted" do garden = FactoryBot.create(:garden, owner: owner) - @planting1 = FactoryBot.create(:planting, garden: garden) - @planting2 = FactoryBot.create(:planting, garden: garden) + @planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) + @planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) garden.plantings.size.should eq(2) all = Planting.count garden.destroy @@ -185,8 +185,8 @@ describe Garden do it "marks plantings as finished when garden is inactive" do garden = FactoryBot.create(:garden) - p1 = FactoryBot.create(:planting, garden: garden) - p2 = FactoryBot.create(:planting, garden: garden) + p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) + p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) p1.finished.should eq false p2.finished.should eq false @@ -203,8 +203,8 @@ describe Garden do it "doesn't mark the wrong plantings as finished" do g1 = FactoryBot.create(:garden) g2 = FactoryBot.create(:garden) - p1 = FactoryBot.create(:planting, garden: g1) - p2 = FactoryBot.create(:planting, garden: g2) + p1 = FactoryBot.create(:planting, garden: g1, owner: g1.owner) + p2 = FactoryBot.create(:planting, garden: g2, owner: g2.owner) # mark the garden as inactive g1.active = false diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 462bee3e4..ec9eb0746 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -4,7 +4,7 @@ describe Planting do let(:crop) { FactoryBot.create(:tomato) } let(:garden_owner) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: garden_owner) } - let(:planting) { FactoryBot.create(:planting, crop: crop, garden: garden) } + let(:planting) { FactoryBot.create(:planting, crop: crop, garden: garden, owner: garden.owner) } let(:finished_planting) do FactoryBot.create :planting, planted_at: 4.days.ago, finished_at: 2.days.ago, finished: true end @@ -120,7 +120,10 @@ describe Planting do describe 'planting has first harvest' do let(:planting) { FactoryBot.create :planting, planted_at: 100.days.ago } before do - FactoryBot.create :harvest, planting: planting, crop: planting.crop, harvested_at: 10.days.ago + FactoryBot.create(:harvest, + planting: planting, + crop: planting.crop, + harvested_at: 10.days.ago) planting.update_harvest_days planting.crop.update_harvest_medians end @@ -148,12 +151,6 @@ describe Planting do planting.owner.should be_an_instance_of Member end - it "owner isn't necessarily the garden owner" do - # a new owner should be created automatically by FactoryBot - # note that formerly, the planting belonged to an owner through the garden - planting.owner.should_not eq garden_owner - end - it "generates a location" do planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}" end @@ -355,7 +352,8 @@ describe Planting do # this one is newer, and has the same owner, through the garden @planting2 = FactoryBot.create(:planting, created_at: 1.minute.ago, - owner_id: @planting1.owner.id) + garden: @planting1.garden, + owner: @planting1.owner) @planting2.photos << FactoryBot.create(:photo) @planting2.save diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index 290d5d8c6..183445346 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -13,17 +13,17 @@ require 'rails_helper' describe "crops/_grown_for" do - before(:each) do - @crop = FactoryBot.create(:crop) - @pp = FactoryBot.create(:plant_part) - @harvest = FactoryBot.create(:harvest, - crop: @crop, - plant_part: @pp) + let(:crop) { FactoryBot.create(:crop) } + let(:plant_path) { FactoryBot.create(:plant_part) } + let!(:harvest) do + FactoryBot.create(:harvest, + crop: crop, + plant_part: plant_path) end it 'shows plant parts' do - render partial: 'crops/grown_for', locals: { crop: @crop } - rendered.should have_content @pp.name - assert_select "a", href: plant_part_path(@pp) + render partial: 'crops/grown_for', locals: { crop: crop } + rendered.should have_content plant_path.name + assert_select "a", href: plant_part_path(plant_path) end end diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 58df0584d..2e6bf9e93 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -13,58 +13,62 @@ require 'rails_helper' describe "crops/_planting_advice" do - before(:each) do - @owner = FactoryBot.create(:member) - @crop = FactoryBot.create(:crop) - @garden = FactoryBot.create(:garden, owner: @owner) - @planting = FactoryBot.create(:planting, - garden: @garden, - crop: @crop) + let(:planting) { FactoryBot.create(:planting) } + subject { rendered } + + shared_examples "render planting_advice" do + before { render 'crops/planting_advice', crop: planting.crop } end - context "sunniness" do - it "doesn't show sunniness if none are set" do - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in: not known." + describe "sunniness" do + context "with no sunniness set" do + include_examples "render planting_advice" + it "doesn't show sunniness" do + is_expected.to have_content "Plant in: not known." + end end - it "shows sunniness frequencies" do - FactoryBot.create(:sunny_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in:" - rendered.should have_content "sun (1)" + context "with sunniness frequencies" do + before { FactoryBot.create(:sunny_planting, crop: planting.crop) } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (1)" } end - it "shows multiple sunniness frequencies" do - FactoryBot.create(:sunny_planting, crop: @crop) - FactoryBot.create(:sunny_planting, crop: @crop) - FactoryBot.create(:shady_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in:" - rendered.should have_content "sun (2), shade (1)" + context "with multiple sunniness frequencies" do + before do + FactoryBot.create_list(:sunny_planting, 2, crop: planting.crop) + FactoryBot.create(:shady_planting, crop: planting.crop) + end + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (2), shade (1)" } end end - context "planted from" do - it "doesn't show planted_from if none are set" do - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from: not known." + describe "planted from" do + context "when none are set" do + include_examples "render planting_advice" + it "doesn't show planted_from " do + is_expected.to have_content "Plant from: not known." + end end - it "shows planted_from frequencies" do - FactoryBot.create(:seed_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from:" - rendered.should have_content "seed (1)" + context "with planted_from frequencies" do + before { FactoryBot.create(:seed_planting, crop: planting.crop) } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (1)" } end - it "shows multiple planted_from frequencies" do - FactoryBot.create(:seed_planting, crop: @crop) - FactoryBot.create(:seed_planting, crop: @crop) - FactoryBot.create(:cutting_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from:" - rendered.should have_content "seed (2), cutting (1)" + context "with multiple planted_from frequencies" do + before do + FactoryBot.create_list(:seed_planting, 2, crop: planting.crop) + FactoryBot.create(:cutting_planting, crop: planting.crop) + end + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (2), cutting (1)" } end end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 83f993a16..b22ee0452 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -17,7 +17,7 @@ describe "gardens/show" do @owner = FactoryBot.create(:member) controller.stub(:current_user) { @owner } @garden = FactoryBot.create(:garden, owner: @owner) - @planting = FactoryBot.create(:planting, garden: @garden) + @planting = FactoryBot.create(:planting, garden: @garden, owner: @garden.owner) assign(:garden, @garden) assign(:current_plantings, [@planting]) assign(:finished_plantings, []) diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index 129648c71..b13d53ed6 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -13,16 +13,19 @@ require 'rails_helper' describe "harvests/show" do - before(:each) do + let!(:harvest) { FactoryBot.create(:harvest) } + + before do controller.stub(:current_user) { nil } - @crop = FactoryBot.create(:tomato) - @harvest = assign(:harvest, FactoryBot.create(:harvest, crop: @crop)) + assign(:harvest, harvest) render end - it "renders attributes" do - rendered.should have_content @crop.name - rendered.should have_content @harvest.harvested_at.to_s - rendered.should have_content @harvest.plant_part.to_s + subject { render } + + describe "renders attributes" do + it { is_expected.to have_content harvest.crop.name } + it { is_expected.to have_content harvest.harvested_at.to_s } + it { is_expected.to have_content harvest.plant_part.to_s } end end diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 59d4d832b..926150f73 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -24,6 +24,7 @@ describe "plantings/_form" do @planting = FactoryBot.create(:planting, garden: @garden, crop: @crop, + owner: @member, planted_at: Date.new(2013, 3, 1)) render end diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index c37f9947a..fc7ff7f30 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -28,7 +28,7 @@ describe "plantings/edit" do @garden2 = FactoryBot.create(:garden_a, owner: @member) @planting = assign(:planting, - FactoryBot.create(:planting, garden: @garden, crop: @tomato)) + FactoryBot.create(:planting, garden: @garden, crop: @tomato, owner: @member)) end context "logged in" do diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index e7831889f..10de32f81 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -13,29 +13,31 @@ require 'rails_helper' describe "plantings/index" do + let(:member) { FactoryBot.create(:member) } + let(:garden) { FactoryBot.create(:garden, owner: member) } + let(:tomato) { FactoryBot.create(:tomato) } + let(:maize) { FactoryBot.create(:maize) } before(:each) do controller.stub(:current_user) { nil } - @member = FactoryBot.create(:member) - @garden = FactoryBot.create(:garden, owner: @member) - @tomato = FactoryBot.create(:tomato) - @maize = FactoryBot.create(:maize) page = 1 per_page = 3 total_entries = 3 plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ FactoryBot.create(:planting, - garden: @garden, - crop: @tomato, - owner: @member), + garden: garden, + crop: tomato, + owner: member), FactoryBot.create(:planting, - garden: @garden, - crop: @maize, + garden: garden, + crop: maize, + owner: garden.owner, description: '', planted_at: Time.zone.local(2013, 1, 13)), FactoryBot.create(:planting, - garden: @garden, - crop: @tomato, + garden: garden, + owner: garden.owner, + crop: tomato, planted_at: Time.zone.local(2013, 1, 13), finished_at: Time.zone.local(2013, 1, 20), finished: true) @@ -46,10 +48,10 @@ describe "plantings/index" do end it "renders a list of plantings" do - rendered.should have_content @tomato.name - rendered.should have_content @maize.name - rendered.should have_content @member.login_name - rendered.should have_content @garden.name + rendered.should have_content tomato.name + rendered.should have_content maize.name + rendered.should have_content member.login_name + rendered.should have_content garden.name end it "displays planting time" do @@ -69,14 +71,14 @@ describe "plantings/index" do end it "displays member's name in title" do - assign(:owner, @member) + assign(:owner, member) render - view.content_for(:title).should have_content @member.login_name + view.content_for(:title).should have_content member.login_name end it "displays crop's name in title" do - assign(:crop, @tomato) + assign(:crop, tomato) render - view.content_for(:title).should have_content @tomato.name + view.content_for(:title).should have_content tomato.name end end diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 9eb941d1d..db1da2826 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -25,7 +25,8 @@ describe "plantings/new" do assign(:planting, FactoryBot.create(:planting, garden: @garden_a, - crop: @crop2)) + crop: @crop2, + owner: @member)) end context "logged in" do diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index f948ca394..b68ceb6c1 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -13,25 +13,22 @@ require 'rails_helper' describe "plantings/show" do - def create_planting_for(member) - @garden = FactoryBot.create(:garden, owner: @member) - @crop = FactoryBot.create(:tomato) - @planting = assign(:planting, - FactoryBot.create(:planting, garden: @garden, crop: @crop, - planted_from: 'cutting')) + let(:crop) { FactoryBot.create(:tomato) } + let(:member) { FactoryBot.create(:member) } + let(:garden) { FactoryBot.create(:garden, owner: member) } + let(:planting) do + FactoryBot.create(:planting, garden: garden, crop: crop, + owner: garden.owner, + planted_from: 'cutting') end before(:each) do - @member = FactoryBot.create(:member) - controller.stub(:current_user) { @member } - @p = create_planting_for(@member) + assign(:planting, planting) + controller.stub(:current_user) { member } end context 'sunniness' do - before(:each) do - @p = assign(:planting, - FactoryBot.create(:sunny_planting)) - end + let(:planting) { FactoryBot.create(:sunny_planting) } it "shows the sunniness" do render @@ -41,10 +38,7 @@ describe "plantings/show" do end context 'planted from' do - before(:each) do - @p = assign(:planting, FactoryBot.create(:cutting_planting)) - end - + let(:planting) { FactoryBot.create(:cutting_planting) } it "shows planted_from" do render rendered.should have_content 'Planted from:' @@ -52,8 +46,7 @@ describe "plantings/show" do end it "doesn't show planted_from if blank" do - @p.planted_from = '' - @p.save + planting.update(planted_from: '') render rendered.should_not have_content 'Planted from:' rendered.should_not have_content 'cutting' @@ -61,10 +54,10 @@ describe "plantings/show" do end it "shows photos" do - @photo = FactoryBot.create(:photo, owner: @member) - @p.photos << @photo + photo = FactoryBot.create(:photo, owner: member) + planting.photos << photo render - assert_select "img[src='#{@photo.thumbnail_url}']" + assert_select "img[src='#{photo.thumbnail_url}']" end it "shows a link to add photos" do @@ -96,13 +89,12 @@ describe "plantings/show" do context "location set" do before(:each) do - @p.owner.location = 'Greenwich, UK' - @p.owner.save + planting.owner.update(location: 'Greenwich, UK') render end it "shows the member's location in parentheses" do - rendered.should have_content "(#{@p.owner.location})" + rendered.should have_content "(#{planting.owner.location})" end end end From c96695258b041a74432af89a193a63b4c3bfc00a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Oct 2017 13:00:00 +1300 Subject: [PATCH 05/56] Basic read only api --- Gemfile | 3 +++ Gemfile.lock | 6 +++++- app/controllers/api/v1/base_controller.rb | 6 ++++++ app/controllers/api/v1/crops_controller.rb | 6 ++++++ app/controllers/api/v1/gardens_controller.rb | 6 ++++++ app/controllers/api/v1/members_controller.rb | 6 ++++++ app/controllers/api/v1/photos_controller.rb | 6 ++++++ .../api/v1/plantings_controller.rb | 6 ++++++ app/resources/api/v1/crop_resource.rb | 13 ++++++++++++ app/resources/api/v1/garden_resource.rb | 11 ++++++++++ app/resources/api/v1/member_resource.rb | 10 ++++++++++ app/resources/api/v1/photo_resource.rb | 8 ++++++++ app/resources/api/v1/planting_resource.rb | 20 +++++++++++++++++++ config/routes.rb | 11 +++++++++- 14 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 app/controllers/api/v1/base_controller.rb create mode 100644 app/controllers/api/v1/crops_controller.rb create mode 100644 app/controllers/api/v1/gardens_controller.rb create mode 100644 app/controllers/api/v1/members_controller.rb create mode 100644 app/controllers/api/v1/photos_controller.rb create mode 100644 app/controllers/api/v1/plantings_controller.rb create mode 100644 app/resources/api/v1/crop_resource.rb create mode 100644 app/resources/api/v1/garden_resource.rb create mode 100644 app/resources/api/v1/member_resource.rb create mode 100644 app/resources/api/v1/photo_resource.rb create mode 100644 app/resources/api/v1/planting_resource.rb diff --git a/Gemfile b/Gemfile index 824b6ca9f..8fe31bee1 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,9 @@ gem 'coffee-rails' gem 'haml' gem 'sass-rails' +# API data +gem 'jsonapi-resources' + # CSS framework gem 'bootstrap-sass' gem 'font-awesome-sass' diff --git a/Gemfile.lock b/Gemfile.lock index 5f8bcf612..c1f9e6b6b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -277,6 +277,10 @@ GEM railties (>= 3.2) sprockets-rails json (2.1.0) + jsonapi-resources (0.9.0) + activerecord (>= 4.1) + concurrent-ruby + railties (>= 4.1) jwt (1.5.6) kaminari (1.1.1) activesupport (>= 4.1.0) @@ -590,6 +594,7 @@ DEPENDENCIES jquery-rails jquery-ui-rails (~> 5.0.2) js-routes + jsonapi-resources kaminari leaflet-markercluster-rails leaflet-rails (~> 0.7.7) @@ -625,7 +630,6 @@ DEPENDENCIES will_paginate xmlrpc - RUBY VERSION ruby 2.4.1p111 diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb new file mode 100644 index 000000000..6f6efdaad --- /dev/null +++ b/app/controllers/api/v1/base_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class BaseController < JSONAPI::ResourceController + end + end +end diff --git a/app/controllers/api/v1/crops_controller.rb b/app/controllers/api/v1/crops_controller.rb new file mode 100644 index 000000000..9d4802df6 --- /dev/null +++ b/app/controllers/api/v1/crops_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class CropsController < Api::V1::BaseController + end + end +end diff --git a/app/controllers/api/v1/gardens_controller.rb b/app/controllers/api/v1/gardens_controller.rb new file mode 100644 index 000000000..f1af5fe2c --- /dev/null +++ b/app/controllers/api/v1/gardens_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class GardensController < Api::V1::BaseController + end + end +end diff --git a/app/controllers/api/v1/members_controller.rb b/app/controllers/api/v1/members_controller.rb new file mode 100644 index 000000000..288ed3318 --- /dev/null +++ b/app/controllers/api/v1/members_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class MembersController < Api::V1::BaseController + end + end +end diff --git a/app/controllers/api/v1/photos_controller.rb b/app/controllers/api/v1/photos_controller.rb new file mode 100644 index 000000000..89da2f708 --- /dev/null +++ b/app/controllers/api/v1/photos_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class PhotosController < Api::V1::BaseController + end + end +end diff --git a/app/controllers/api/v1/plantings_controller.rb b/app/controllers/api/v1/plantings_controller.rb new file mode 100644 index 000000000..30e1e54cf --- /dev/null +++ b/app/controllers/api/v1/plantings_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class PlantingsController < Api::V1::BaseController + end + end +end diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb new file mode 100644 index 000000000..525cb1458 --- /dev/null +++ b/app/resources/api/v1/crop_resource.rb @@ -0,0 +1,13 @@ +module Api + module V1 + class CropResource < JSONAPI::Resource + immutable + model_name 'Crop' + attribute :name + attribute :en_wikipedia_url + has_many :plantings + has_many :photos + has_one :parent + end + end +end diff --git a/app/resources/api/v1/garden_resource.rb b/app/resources/api/v1/garden_resource.rb new file mode 100644 index 000000000..95521a873 --- /dev/null +++ b/app/resources/api/v1/garden_resource.rb @@ -0,0 +1,11 @@ +module Api + module V1 + class GardenResource < JSONAPI::Resource + immutable + model_name 'Garden' + attribute :name + has_one :owner, class_name: 'Member' + has_many :plantings + end + end +end diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb new file mode 100644 index 000000000..cd0e3be01 --- /dev/null +++ b/app/resources/api/v1/member_resource.rb @@ -0,0 +1,10 @@ +module Api + module V1 + class MemberResource < JSONAPI::Resource + immutable + model_name 'Member' + attribute :login_name + has_many :gardens + end + end +end diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb new file mode 100644 index 000000000..270773b07 --- /dev/null +++ b/app/resources/api/v1/photo_resource.rb @@ -0,0 +1,8 @@ +module Api + module V1 + class PhotoResource < JSONAPI::Resource + immutable + model_name 'Photo' + end + end +end diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb new file mode 100644 index 000000000..5a9399b18 --- /dev/null +++ b/app/resources/api/v1/planting_resource.rb @@ -0,0 +1,20 @@ +module Api + module V1 + class PlantingResource < JSONAPI::Resource + immutable + model_name 'Planting' + has_one :garden + has_one :crop + has_one :owner + has_many :photos + + attribute :planted_at + attribute :finished_at + attribute :quantity + attribute :description + attribute :sunniness + attribute :planted_from + attribute :days_before_maturity + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 72a3d5e19..d8111b518 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,8 +96,17 @@ Growstuff::Application.routes.draw do get '/admin/newsletter' => 'admin#newsletter', :as => :admin_newsletter get '/admin/:action' => 'admin#:action' - get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt' + namespace :api do + namespace :v1 do + jsonapi_resources :photos + jsonapi_resources :crops + jsonapi_resources :plantings + jsonapi_resources :gardens + jsonapi_resources :members + end + end + get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt' # CMS stuff -- must remain LAST comfy_route :cms, path: '/', sitemap: false end From d07fd1a277db27186697003159d876317d50cd79 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Oct 2017 13:17:28 +1300 Subject: [PATCH 06/56] Added seeds and harvests to api, and tidied up resources --- app/controllers/api/v1/harvests_controller.rb | 6 ++++++ app/controllers/api/v1/seeds_controller.rb | 6 ++++++ app/resources/api/v1/crop_resource.rb | 7 ++++--- app/resources/api/v1/garden_resource.rb | 6 ++++-- app/resources/api/v1/harvest_resource.rb | 19 +++++++++++++++++++ app/resources/api/v1/member_resource.rb | 5 +++-- app/resources/api/v1/photo_resource.rb | 10 +++++++++- app/resources/api/v1/planting_resource.rb | 3 +-- app/resources/api/v1/seed_resource.rb | 19 +++++++++++++++++++ config/routes.rb | 2 ++ 10 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 app/controllers/api/v1/harvests_controller.rb create mode 100644 app/controllers/api/v1/seeds_controller.rb create mode 100644 app/resources/api/v1/harvest_resource.rb create mode 100644 app/resources/api/v1/seed_resource.rb diff --git a/app/controllers/api/v1/harvests_controller.rb b/app/controllers/api/v1/harvests_controller.rb new file mode 100644 index 000000000..ffb2d017e --- /dev/null +++ b/app/controllers/api/v1/harvests_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class HarvestsController < JSONAPI::ResourceController + end + end +end diff --git a/app/controllers/api/v1/seeds_controller.rb b/app/controllers/api/v1/seeds_controller.rb new file mode 100644 index 000000000..a02db0a0c --- /dev/null +++ b/app/controllers/api/v1/seeds_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class SeedsController < JSONAPI::ResourceController + end + end +end diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb index 525cb1458..61c77a983 100644 --- a/app/resources/api/v1/crop_resource.rb +++ b/app/resources/api/v1/crop_resource.rb @@ -2,12 +2,13 @@ module Api module V1 class CropResource < JSONAPI::Resource immutable - model_name 'Crop' - attribute :name - attribute :en_wikipedia_url + has_many :plantings has_many :photos has_one :parent + + attribute :name + attribute :en_wikipedia_url end end end diff --git a/app/resources/api/v1/garden_resource.rb b/app/resources/api/v1/garden_resource.rb index 95521a873..94de9b06a 100644 --- a/app/resources/api/v1/garden_resource.rb +++ b/app/resources/api/v1/garden_resource.rb @@ -2,10 +2,12 @@ module Api module V1 class GardenResource < JSONAPI::Resource immutable - model_name 'Garden' - attribute :name + has_one :owner, class_name: 'Member' has_many :plantings + has_many :photos + + attribute :name end end end diff --git a/app/resources/api/v1/harvest_resource.rb b/app/resources/api/v1/harvest_resource.rb new file mode 100644 index 000000000..067ec307c --- /dev/null +++ b/app/resources/api/v1/harvest_resource.rb @@ -0,0 +1,19 @@ +module Api + module V1 + class HarvestResource < JSONAPI::Resource + immutable + + has_one :crop + has_one :planting + has_one :owner, class_name: 'Member' + has_many :photos + + attribute :harvested_at + attribute :description + attribute :unit + attribute :weight_quantity + attribute :weight_unit + attribute :si_weight + end + end +end diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb index cd0e3be01..fb5645f2e 100644 --- a/app/resources/api/v1/member_resource.rb +++ b/app/resources/api/v1/member_resource.rb @@ -2,9 +2,10 @@ module Api module V1 class MemberResource < JSONAPI::Resource immutable - model_name 'Member' - attribute :login_name + has_many :gardens + + attribute :login_name end end end diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb index 270773b07..22db926ca 100644 --- a/app/resources/api/v1/photo_resource.rb +++ b/app/resources/api/v1/photo_resource.rb @@ -2,7 +2,15 @@ module Api module V1 class PhotoResource < JSONAPI::Resource immutable - model_name 'Photo' + + has_one :owner, class_name: 'Member' + + attribute :thumbnail_url + attribute :fullsize_url + attribute :link_url + attribute :license_name + attribute :link_url + attribute :title end end end diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb index 5a9399b18..99a0eeda1 100644 --- a/app/resources/api/v1/planting_resource.rb +++ b/app/resources/api/v1/planting_resource.rb @@ -2,10 +2,9 @@ module Api module V1 class PlantingResource < JSONAPI::Resource immutable - model_name 'Planting' has_one :garden has_one :crop - has_one :owner + has_one :owner, class_name: 'Member' has_many :photos attribute :planted_at diff --git a/app/resources/api/v1/seed_resource.rb b/app/resources/api/v1/seed_resource.rb new file mode 100644 index 000000000..3488ff767 --- /dev/null +++ b/app/resources/api/v1/seed_resource.rb @@ -0,0 +1,19 @@ +module Api + module V1 + class SeedResource < JSONAPI::Resource + immutable + has_one :owner, class_name: 'Member' + has_one :crop + + attribute :description + attribute :quantity + attribute :plant_before + attribute :tradable_to + attribute :days_until_maturity_min + attribute :days_until_maturity_max + attribute :organic + attribute :gmo + attribute :heirloom + end + end +end diff --git a/config/routes.rb b/config/routes.rb index d8111b518..30327901b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -102,6 +102,8 @@ Growstuff::Application.routes.draw do jsonapi_resources :crops jsonapi_resources :plantings jsonapi_resources :gardens + jsonapi_resources :harvests + jsonapi_resources :seeds jsonapi_resources :members end end From 88a119deacc40725d365a326f9ebca7ec88cdd4c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Oct 2017 13:42:30 +1300 Subject: [PATCH 07/56] Add a default paginator for api responses --- config/initializers/jsonapi_resources.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 config/initializers/jsonapi_resources.rb diff --git a/config/initializers/jsonapi_resources.rb b/config/initializers/jsonapi_resources.rb new file mode 100644 index 000000000..1a17dfc07 --- /dev/null +++ b/config/initializers/jsonapi_resources.rb @@ -0,0 +1,6 @@ +JSONAPI.configure do |config| + # built in paginators are :none, :offset, :paged + config.default_paginator = :offset + config.default_page_size = 10 + config.maximum_page_size = 20 +end From 5877da95a65398d7eb5cc3b5913d75aadda5bc76 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Oct 2017 13:45:43 +1300 Subject: [PATCH 08/56] Added a base resource, a little more DRY --- app/resources/api/v1/base_resource.rb | 8 ++++++++ app/resources/api/v1/crop_resource.rb | 4 +--- app/resources/api/v1/garden_resource.rb | 4 +--- app/resources/api/v1/harvest_resource.rb | 4 +--- app/resources/api/v1/member_resource.rb | 4 +--- app/resources/api/v1/photo_resource.rb | 4 +--- app/resources/api/v1/planting_resource.rb | 3 +-- app/resources/api/v1/seed_resource.rb | 3 +-- 8 files changed, 15 insertions(+), 19 deletions(-) create mode 100644 app/resources/api/v1/base_resource.rb diff --git a/app/resources/api/v1/base_resource.rb b/app/resources/api/v1/base_resource.rb new file mode 100644 index 000000000..f3014a8f4 --- /dev/null +++ b/app/resources/api/v1/base_resource.rb @@ -0,0 +1,8 @@ +module Api + module V1 + class BaseResource < JSONAPI::Resource + immutable + abstract + end + end +end diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb index 61c77a983..28675270d 100644 --- a/app/resources/api/v1/crop_resource.rb +++ b/app/resources/api/v1/crop_resource.rb @@ -1,8 +1,6 @@ module Api module V1 - class CropResource < JSONAPI::Resource - immutable - + class CropResource < BaseResource has_many :plantings has_many :photos has_one :parent diff --git a/app/resources/api/v1/garden_resource.rb b/app/resources/api/v1/garden_resource.rb index 94de9b06a..96697ab38 100644 --- a/app/resources/api/v1/garden_resource.rb +++ b/app/resources/api/v1/garden_resource.rb @@ -1,8 +1,6 @@ module Api module V1 - class GardenResource < JSONAPI::Resource - immutable - + class GardenResource < BaseResource has_one :owner, class_name: 'Member' has_many :plantings has_many :photos diff --git a/app/resources/api/v1/harvest_resource.rb b/app/resources/api/v1/harvest_resource.rb index 067ec307c..78603e028 100644 --- a/app/resources/api/v1/harvest_resource.rb +++ b/app/resources/api/v1/harvest_resource.rb @@ -1,8 +1,6 @@ module Api module V1 - class HarvestResource < JSONAPI::Resource - immutable - + class HarvestResource < BaseResource has_one :crop has_one :planting has_one :owner, class_name: 'Member' diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb index fb5645f2e..4ea8d4db6 100644 --- a/app/resources/api/v1/member_resource.rb +++ b/app/resources/api/v1/member_resource.rb @@ -1,8 +1,6 @@ module Api module V1 - class MemberResource < JSONAPI::Resource - immutable - + class MemberResource < BaseResource has_many :gardens attribute :login_name diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb index 22db926ca..6789f6737 100644 --- a/app/resources/api/v1/photo_resource.rb +++ b/app/resources/api/v1/photo_resource.rb @@ -1,8 +1,6 @@ module Api module V1 - class PhotoResource < JSONAPI::Resource - immutable - + class PhotoResource < BaseResource has_one :owner, class_name: 'Member' attribute :thumbnail_url diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb index 99a0eeda1..cdfa7399a 100644 --- a/app/resources/api/v1/planting_resource.rb +++ b/app/resources/api/v1/planting_resource.rb @@ -1,7 +1,6 @@ module Api module V1 - class PlantingResource < JSONAPI::Resource - immutable + class PlantingResource < BaseResource has_one :garden has_one :crop has_one :owner, class_name: 'Member' diff --git a/app/resources/api/v1/seed_resource.rb b/app/resources/api/v1/seed_resource.rb index 3488ff767..5703928b2 100644 --- a/app/resources/api/v1/seed_resource.rb +++ b/app/resources/api/v1/seed_resource.rb @@ -1,7 +1,6 @@ module Api module V1 - class SeedResource < JSONAPI::Resource - immutable + class SeedResource < BaseResource has_one :owner, class_name: 'Member' has_one :crop From 33822abf932bc7f226411ed20d49b6397ae25538 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Oct 2017 13:47:53 +1300 Subject: [PATCH 09/56] crops have harvests --- app/resources/api/v1/crop_resource.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb index 28675270d..8b6885844 100644 --- a/app/resources/api/v1/crop_resource.rb +++ b/app/resources/api/v1/crop_resource.rb @@ -3,6 +3,7 @@ module Api class CropResource < BaseResource has_many :plantings has_many :photos + has_many :harvests has_one :parent attribute :name From 41110f96d1728b26fe47b21eb71b4922098cb078 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Oct 2017 13:51:18 +1300 Subject: [PATCH 10/56] Put immutable on every resource --- app/resources/api/v1/crop_resource.rb | 2 ++ app/resources/api/v1/garden_resource.rb | 2 ++ app/resources/api/v1/harvest_resource.rb | 2 ++ app/resources/api/v1/member_resource.rb | 2 ++ app/resources/api/v1/photo_resource.rb | 2 ++ app/resources/api/v1/planting_resource.rb | 2 ++ app/resources/api/v1/seed_resource.rb | 2 ++ 7 files changed, 14 insertions(+) diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb index 8b6885844..6a6399943 100644 --- a/app/resources/api/v1/crop_resource.rb +++ b/app/resources/api/v1/crop_resource.rb @@ -1,6 +1,8 @@ module Api module V1 class CropResource < BaseResource + immutable + has_many :plantings has_many :photos has_many :harvests diff --git a/app/resources/api/v1/garden_resource.rb b/app/resources/api/v1/garden_resource.rb index 96697ab38..cffcb27fb 100644 --- a/app/resources/api/v1/garden_resource.rb +++ b/app/resources/api/v1/garden_resource.rb @@ -1,6 +1,8 @@ module Api module V1 class GardenResource < BaseResource + immutable + has_one :owner, class_name: 'Member' has_many :plantings has_many :photos diff --git a/app/resources/api/v1/harvest_resource.rb b/app/resources/api/v1/harvest_resource.rb index 78603e028..c1ce0ae0f 100644 --- a/app/resources/api/v1/harvest_resource.rb +++ b/app/resources/api/v1/harvest_resource.rb @@ -1,6 +1,8 @@ module Api module V1 class HarvestResource < BaseResource + immutable + has_one :crop has_one :planting has_one :owner, class_name: 'Member' diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb index 4ea8d4db6..6f703c9ce 100644 --- a/app/resources/api/v1/member_resource.rb +++ b/app/resources/api/v1/member_resource.rb @@ -1,6 +1,8 @@ module Api module V1 class MemberResource < BaseResource + immutable + has_many :gardens attribute :login_name diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb index 6789f6737..54ab48cc9 100644 --- a/app/resources/api/v1/photo_resource.rb +++ b/app/resources/api/v1/photo_resource.rb @@ -1,6 +1,8 @@ module Api module V1 class PhotoResource < BaseResource + immutable + has_one :owner, class_name: 'Member' attribute :thumbnail_url diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb index cdfa7399a..20c4b75a3 100644 --- a/app/resources/api/v1/planting_resource.rb +++ b/app/resources/api/v1/planting_resource.rb @@ -1,6 +1,8 @@ module Api module V1 class PlantingResource < BaseResource + immutable + has_one :garden has_one :crop has_one :owner, class_name: 'Member' diff --git a/app/resources/api/v1/seed_resource.rb b/app/resources/api/v1/seed_resource.rb index 5703928b2..e994ce1a0 100644 --- a/app/resources/api/v1/seed_resource.rb +++ b/app/resources/api/v1/seed_resource.rb @@ -1,6 +1,8 @@ module Api module V1 class SeedResource < BaseResource + immutable + has_one :owner, class_name: 'Member' has_one :crop From fc0058d677c9c29ead69fd2df9920c46e857ea8a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 22 Oct 2017 13:51:50 +1300 Subject: [PATCH 11/56] all our api controllers inheriting from base --- app/controllers/api/v1/base_controller.rb | 1 + app/controllers/api/v1/crops_controller.rb | 2 +- app/controllers/api/v1/gardens_controller.rb | 2 +- app/controllers/api/v1/harvests_controller.rb | 2 +- app/controllers/api/v1/members_controller.rb | 2 +- app/controllers/api/v1/photos_controller.rb | 2 +- app/controllers/api/v1/plantings_controller.rb | 2 +- app/controllers/api/v1/seeds_controller.rb | 2 +- 8 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index 6f6efdaad..4fbc4d806 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -1,6 +1,7 @@ module Api module V1 class BaseController < JSONAPI::ResourceController + abstract end end end diff --git a/app/controllers/api/v1/crops_controller.rb b/app/controllers/api/v1/crops_controller.rb index 9d4802df6..d67beaa1a 100644 --- a/app/controllers/api/v1/crops_controller.rb +++ b/app/controllers/api/v1/crops_controller.rb @@ -1,6 +1,6 @@ module Api module V1 - class CropsController < Api::V1::BaseController + class CropsController < BaseController end end end diff --git a/app/controllers/api/v1/gardens_controller.rb b/app/controllers/api/v1/gardens_controller.rb index f1af5fe2c..4343d8014 100644 --- a/app/controllers/api/v1/gardens_controller.rb +++ b/app/controllers/api/v1/gardens_controller.rb @@ -1,6 +1,6 @@ module Api module V1 - class GardensController < Api::V1::BaseController + class GardensController < BaseController end end end diff --git a/app/controllers/api/v1/harvests_controller.rb b/app/controllers/api/v1/harvests_controller.rb index ffb2d017e..bcf735dce 100644 --- a/app/controllers/api/v1/harvests_controller.rb +++ b/app/controllers/api/v1/harvests_controller.rb @@ -1,6 +1,6 @@ module Api module V1 - class HarvestsController < JSONAPI::ResourceController + class HarvestsController < BaseController end end end diff --git a/app/controllers/api/v1/members_controller.rb b/app/controllers/api/v1/members_controller.rb index 288ed3318..b9b99956d 100644 --- a/app/controllers/api/v1/members_controller.rb +++ b/app/controllers/api/v1/members_controller.rb @@ -1,6 +1,6 @@ module Api module V1 - class MembersController < Api::V1::BaseController + class MembersController < BaseController end end end diff --git a/app/controllers/api/v1/photos_controller.rb b/app/controllers/api/v1/photos_controller.rb index 89da2f708..a095d24cb 100644 --- a/app/controllers/api/v1/photos_controller.rb +++ b/app/controllers/api/v1/photos_controller.rb @@ -1,6 +1,6 @@ module Api module V1 - class PhotosController < Api::V1::BaseController + class PhotosController < BaseController end end end diff --git a/app/controllers/api/v1/plantings_controller.rb b/app/controllers/api/v1/plantings_controller.rb index 30e1e54cf..d143676ab 100644 --- a/app/controllers/api/v1/plantings_controller.rb +++ b/app/controllers/api/v1/plantings_controller.rb @@ -1,6 +1,6 @@ module Api module V1 - class PlantingsController < Api::V1::BaseController + class PlantingsController < BaseController end end end diff --git a/app/controllers/api/v1/seeds_controller.rb b/app/controllers/api/v1/seeds_controller.rb index a02db0a0c..43f5691c6 100644 --- a/app/controllers/api/v1/seeds_controller.rb +++ b/app/controllers/api/v1/seeds_controller.rb @@ -1,6 +1,6 @@ module Api module V1 - class SeedsController < JSONAPI::ResourceController + class SeedsController < BaseController end end end From d86e0af5ad6b961246a80375b4032fbba691e187 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Oct 2017 15:52:53 +1300 Subject: [PATCH 12/56] Request for for getting api gardens#index --- spec/requests/api/v1/gardens_request_spec.rb | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/requests/api/v1/gardens_request_spec.rb diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb new file mode 100644 index 000000000..18fca22c3 --- /dev/null +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +RSpec.describe 'Gardens', type: :request do + let!(:garden) { FactoryGirl.create :garden } + let(:garden_encoded_as_json_api) do + { "id" => garden.id.to_s, + "type" => "gardens", + "links" => { "self" => "http://www.example.com/api/v1/gardens/#{garden.id}" }, + "attributes" => { "name" => garden.name }, + "relationships" => + { "owner" => + { "links" => + { "self" => "http://www.example.com/api/v1/gardens/#{garden.id}/relationships/owner", + "related" => "http://www.example.com/api/v1/gardens/#{garden.id}/owner" } }, + "plantings" => + { "links" => + { "self" => + "http://www.example.com/api/v1/gardens/#{garden.id}/relationships/plantings", + "related" => "http://www.example.com/api/v1/gardens/#{garden.id}/plantings" } }, + "photos" => + { "links" => + { "self" => "http://www.example.com/api/v1/gardens/#{garden.id}/relationships/photos", + "related" => "http://www.example.com/api/v1/gardens/#{garden.id}/photos" } } } } + end + subject { JSON.parse response.body } + scenario '#index' do + get '/api/v1/gardens', {}, 'Accept' => 'application/vnd.api+json' + expect(subject['data']).to include(garden_encoded_as_json_api) + end +end From b60f47f50261d92067f9ccece96b395fb5eb2d45 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Oct 2017 15:55:27 +1300 Subject: [PATCH 13/56] Add more relationships to members on the api --- app/resources/api/v1/member_resource.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb index 6f703c9ce..b5b0a94a0 100644 --- a/app/resources/api/v1/member_resource.rb +++ b/app/resources/api/v1/member_resource.rb @@ -4,6 +4,10 @@ module Api immutable has_many :gardens + has_many :plantings + has_many :harvests + has_many :seeds + has_many :photos attribute :login_name end From c9d5c42814540efcc3c9f621faf6f958dd534a2f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Oct 2017 16:04:39 +1300 Subject: [PATCH 14/56] Plantings have many harvests --- app/resources/api/v1/planting_resource.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb index 20c4b75a3..34983d2e5 100644 --- a/app/resources/api/v1/planting_resource.rb +++ b/app/resources/api/v1/planting_resource.rb @@ -7,6 +7,7 @@ module Api has_one :crop has_one :owner, class_name: 'Member' has_many :photos + has_many :harvests attribute :planted_at attribute :finished_at From ae2cbf0bec6405485fc7bb4f8a1873cdc6c9771b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 23 Oct 2017 16:12:25 +1300 Subject: [PATCH 15/56] requests spec for modifying immutable gardens on api --- spec/requests/api/v1/gardens_request_spec.rb | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 18fca22c3..d38fc8ab1 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe 'Gardens', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let!(:garden) { FactoryGirl.create :garden } let(:garden_encoded_as_json_api) do { "id" => garden.id.to_s, @@ -22,9 +23,30 @@ RSpec.describe 'Gardens', type: :request do { "self" => "http://www.example.com/api/v1/gardens/#{garden.id}/relationships/photos", "related" => "http://www.example.com/api/v1/gardens/#{garden.id}/photos" } } } } end + subject { JSON.parse response.body } scenario '#index' do - get '/api/v1/gardens', {}, 'Accept' => 'application/vnd.api+json' + get '/api/v1/gardens', {}, headers expect(subject['data']).to include(garden_encoded_as_json_api) end + + scenario '#show' do + get "/api/v1/gardens/#{garden.id}", {}, headers + expect(subject['data']).to include(garden_encoded_as_json_api) + end + + scenario '#create' do + post '/api/v1/gardens', { 'garden' => { 'name' => 'can i make this' } }, headers + expect(response.code).to eq "404" + end + + scenario '#update' do + post "/api/v1/gardens/#{garden.id}", { 'garden' => { 'name' => 'can i modify this' } }, headers + expect(response.code).to eq "404" + end + + scenario '#delete' do + delete "/api/v1/gardens/#{garden.id}", {}, headers + expect(response.code).to eq "404" + end end From d8f5876518793477dfe70713e6c9f21d57d1fb35 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 13:51:55 +1300 Subject: [PATCH 16/56] Added predictions to planting api, and added specs --- app/models/planting.rb | 12 +-- app/resources/api/v1/planting_resource.rb | 9 +- .../requests/api/v1/plantings_request_spec.rb | 96 +++++++++++++++++++ 3 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 spec/requests/api/v1/plantings_request_spec.rb diff --git a/app/models/planting.rb b/app/models/planting.rb index f5f482a5d..7a16b8c84 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -123,12 +123,6 @@ class Planting < ActiveRecord::Base update(days_to_first_harvest: days_to_first_harvest, days_to_last_harvest: days_to_last_harvest) end - private - - def harvests_with_dates - harvests.where.not(harvested_at: nil) - end - def first_harvest_date harvests_with_dates.minimum(:harvested_at) end @@ -137,6 +131,12 @@ class Planting < ActiveRecord::Base harvests_with_dates.maximum(:harvested_at) end + private + + def harvests_with_dates + harvests.where.not(harvested_at: nil) + end + # check that any finished_at date occurs after planted_at def finished_must_be_after_planted return unless planted_at && finished_at # only check if we have both diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb index 34983d2e5..3a42f5d4b 100644 --- a/app/resources/api/v1/planting_resource.rb +++ b/app/resources/api/v1/planting_resource.rb @@ -11,11 +11,18 @@ module Api attribute :planted_at attribute :finished_at + attribute :finished attribute :quantity attribute :description attribute :sunniness attribute :planted_from - attribute :days_before_maturity + + # Predictions + attribute :expected_lifespan + attribute :finish_predicted_at + attribute :percentage_grown + attribute :first_harvest_date + attribute :last_harvest_date end end end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb new file mode 100644 index 000000000..e8b0d77d3 --- /dev/null +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -0,0 +1,96 @@ +require 'rails_helper' + +RSpec.describe 'Plantings', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:planting) { FactoryBot.create :planting } + let(:planting_encoded_as_json_api) do + { "id" => planting.id.to_s, + "type" => "plantings", + "links" => { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}" }, + "attributes" => attributes, + "relationships" => { + "garden" => garden_as_json_api, + "crop" => crop_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api + } } + end + + let(:harvests_as_json_api) do + { "links" => + { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/harvests", + "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/harvests" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/photos", + "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/photos" } } + end + + let(:owner_as_json_api) do + { "links" => + { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/owner", + "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/owner" } } + end + + let(:crop_as_json_api) do + { "links" => + { "self" => + "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/crop", + "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/crop" } } + end + let(:garden_as_json_api) do + { "links" => + { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/garden", + "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/garden" } } + end + + let(:attributes) do + { + "planted-at" => "2014-07-30", + "finished-at" => nil, + "finished" => false, + "quantity" => 33, + "description" => planting.description, + "sunniness" => nil, + "planted-from" => nil, + "expected-lifespan" => nil, + "finish-predicted-at" => nil, + "percentage-grown" => nil, + "first-harvest-date" => nil, + "last-harvest-date" => nil + } + end + + subject { JSON.parse response.body } + scenario '#index' do + get '/api/v1/plantings', {}, headers + expect(subject['data']).to include(planting_encoded_as_json_api) + end + + scenario '#show' do + get "/api/v1/plantings/#{planting.id}", {}, headers + expect(subject['data']['relationships']).to include("garden" => garden_as_json_api) + expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) + expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) + expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) + expect(subject['data']).to eq(planting_encoded_as_json_api) + end + + scenario '#create' do + post '/api/v1/plantings', { 'planting' => { 'description' => 'can i make this' } }, headers + expect(response.code).to eq "404" + end + + scenario '#update' do + post "/api/v1/plantings/#{planting.id}", { 'planting' => { 'description' => 'can i modify this' } }, headers + expect(response.code).to eq "404" + end + + scenario '#delete' do + delete "/api/v1/plantings/#{planting.id}", {}, headers + expect(response.code).to eq "404" + end +end From b6cbfe25d288531d9d972ba6071596c425c22abd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 13:52:54 +1300 Subject: [PATCH 17/56] Factory girl becomes factory bot --- spec/requests/api/v1/gardens_request_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index d38fc8ab1..0f952e3c7 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe 'Gardens', type: :request do let(:headers) { { 'Accept' => 'application/vnd.api+json' } } - let!(:garden) { FactoryGirl.create :garden } + let!(:garden) { FactoryBot.create :garden } let(:garden_encoded_as_json_api) do { "id" => garden.id.to_s, "type" => "gardens", From 2f0cb5c815dd4676f4897149f98f2819405144e7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 14:38:47 +1300 Subject: [PATCH 18/56] DRY the api specs --- spec/requests/api/v1/gardens_request_spec.rb | 40 ++++++++++++------- .../requests/api/v1/plantings_request_spec.rb | 24 ++++++----- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 0f952e3c7..65caf7044 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -6,22 +6,34 @@ RSpec.describe 'Gardens', type: :request do let(:garden_encoded_as_json_api) do { "id" => garden.id.to_s, "type" => "gardens", - "links" => { "self" => "http://www.example.com/api/v1/gardens/#{garden.id}" }, + "links" => { "self" => resource_url }, "attributes" => { "name" => garden.name }, "relationships" => - { "owner" => - { "links" => - { "self" => "http://www.example.com/api/v1/gardens/#{garden.id}/relationships/owner", - "related" => "http://www.example.com/api/v1/gardens/#{garden.id}/owner" } }, - "plantings" => - { "links" => - { "self" => - "http://www.example.com/api/v1/gardens/#{garden.id}/relationships/plantings", - "related" => "http://www.example.com/api/v1/gardens/#{garden.id}/plantings" } }, - "photos" => - { "links" => - { "self" => "http://www.example.com/api/v1/gardens/#{garden.id}/relationships/photos", - "related" => "http://www.example.com/api/v1/gardens/#{garden.id}/photos" } } } } + { + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "photos" => photos_as_json_api + } } + end + let(:resource_url) { "http://www.example.com/api/v1/gardens/#{garden.id}" } + + let(:plantings_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/plantings", + "related" => "#{resource_url}/plantings" } } + end + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end subject { JSON.parse response.body } diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index e8b0d77d3..3393c487e 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'Plantings', type: :request do let(:planting_encoded_as_json_api) do { "id" => planting.id.to_s, "type" => "plantings", - "links" => { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}" }, + "links" => { "self" => resource_url }, "attributes" => attributes, "relationships" => { "garden" => garden_as_json_api, @@ -17,34 +17,36 @@ RSpec.describe 'Plantings', type: :request do } } end + let(:resource_url) { "http://www.example.com/api/v1/plantings/#{planting.id}" } + let(:harvests_as_json_api) do { "links" => - { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/harvests", - "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/harvests" } } + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } end let(:photos_as_json_api) do { "links" => - { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/photos", - "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/photos" } } + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } end let(:owner_as_json_api) do { "links" => - { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/owner", - "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/owner" } } + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } end let(:crop_as_json_api) do { "links" => { "self" => - "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/crop", - "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/crop" } } + "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } end let(:garden_as_json_api) do { "links" => - { "self" => "http://www.example.com/api/v1/plantings/#{planting.id}/relationships/garden", - "related" => "http://www.example.com/api/v1/plantings/#{planting.id}/garden" } } + { "self" => "#{resource_url}/relationships/garden", + "related" => "#{resource_url}/garden" } } end let(:attributes) do From c29234c40cf4c2cb564a8f4794981605dc92faf4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 15:03:24 +1300 Subject: [PATCH 19/56] Request specs for crops api --- spec/requests/api/v1/crop_request_spec.rb | 83 +++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 spec/requests/api/v1/crop_request_spec.rb diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb new file mode 100644 index 000000000..e4c365fb3 --- /dev/null +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -0,0 +1,83 @@ +require 'rails_helper' + +RSpec.describe 'Plantings', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:crop) { FactoryBot.create :crop } + let(:crop_encoded_as_json_api) do + { "id" => crop.id.to_s, + "type" => "crops", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "plantings" => plantings_as_json_api, + "parent" => parent_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/crops/#{crop.id}" } + + let(:harvests_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } + end + + let(:parent_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/parent", + "related" => "#{resource_url}/parent" } } + end + + let(:plantings_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/plantings", + "related" => "#{resource_url}/plantings" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } + end + + let(:attributes) do + { + "name" => crop.name, + "en-wikipedia-url" => "http://en.wikipedia.org/wiki/Magic_bean" + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/crops', {}, headers } + it { expect(subject['data']).to include(crop_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/crops/#{crop.id}", {}, headers } + it { expect(subject['data']['attributes']).to eq(attributes) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("parent" => parent_as_json_api) } + it { expect(subject['data']).to eq(crop_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/crops', { 'crop' => { 'name' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/crops/#{crop.id}", { 'crop' => { 'name' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/crops/#{crop.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end From 5fec826c4152559736e45515781dbabfdce25598 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 16:58:24 +1300 Subject: [PATCH 20/56] Add more attributes to crops --- app/resources/api/v1/crop_resource.rb | 7 +++++++ spec/requests/api/v1/crop_request_spec.rb | 6 +++++- spec/requests/api/v1/plantings_request_spec.rb | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb index 6a6399943..86caf701a 100644 --- a/app/resources/api/v1/crop_resource.rb +++ b/app/resources/api/v1/crop_resource.rb @@ -3,6 +3,8 @@ module Api class CropResource < BaseResource immutable + filter :approval_status, default: 'approved' + has_many :plantings has_many :photos has_many :harvests @@ -10,6 +12,11 @@ module Api attribute :name attribute :en_wikipedia_url + + attribute :perennial + attribute :median_lifespan + attribute :median_days_to_first_harvest + attribute :median_days_to_last_harvest end end end diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb index e4c365fb3..cfac5fdb4 100644 --- a/spec/requests/api/v1/crop_request_spec.rb +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -46,7 +46,11 @@ RSpec.describe 'Plantings', type: :request do let(:attributes) do { "name" => crop.name, - "en-wikipedia-url" => "http://en.wikipedia.org/wiki/Magic_bean" + "en-wikipedia-url" => crop.en_wikipedia_url, + "perennial" => false, + "median-lifespan" => nil, + "median-days-to-first-harvest" => nil, + "median-days-to-last-harvest" => nil } end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 3393c487e..0591a28dc 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -78,6 +78,7 @@ RSpec.describe 'Plantings', type: :request do expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) + expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) expect(subject['data']).to eq(planting_encoded_as_json_api) end From 08e7c7dd29858f21b2813775a07a1584251deac2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 18:12:30 +1300 Subject: [PATCH 21/56] Request specs for harvests api --- spec/requests/api/v1/harvest_request_spec.rb | 88 ++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 spec/requests/api/v1/harvest_request_spec.rb diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb new file mode 100644 index 000000000..7d97dea08 --- /dev/null +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -0,0 +1,88 @@ +require 'rails_helper' + +RSpec.describe 'Harvests', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:harvest) { FactoryBot.create :harvest } + let(:harvest_encoded_as_json_api) do + { "id" => harvest.id.to_s, + "type" => "harvests", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "crop" => crop_as_json_api, + "planting" => planting_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/harvests/#{harvest.id}" } + + let(:crop_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } + end + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:planting_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/planting", + "related" => "#{resource_url}/planting" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } + end + + let(:attributes) do + { + "harvested-at" => "2015-09-17", + "description" => harvest.description, + "unit" => harvest.unit, + "weight-quantity" => harvest.weight_quantity.to_s, + "weight-unit" => harvest.weight_unit, + "si-weight" => harvest.si_weight + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/harvests', {}, headers } + it { expect(subject['data']).to include(harvest_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/harvests/#{harvest.id}", {}, headers } + it { expect(subject['data']['attributes']).to eq(attributes) } + it { expect(subject['data']['relationships']).to include("planting" => planting_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']).to eq(harvest_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/harvests', { 'harvest' => { 'description' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/harvests/#{harvest.id}", { 'harvest' => { 'description' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/harvests/#{harvest.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end From 1b4d77e0174ed8f21e091e6c3179b7b4e13cef03 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 Nov 2017 20:03:39 +1300 Subject: [PATCH 22/56] Requests spec for member api --- spec/requests/api/v1/member_request_spec.rb | 88 +++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 spec/requests/api/v1/member_request_spec.rb diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb new file mode 100644 index 000000000..0c74dc3cd --- /dev/null +++ b/spec/requests/api/v1/member_request_spec.rb @@ -0,0 +1,88 @@ +require 'rails_helper' + +RSpec.describe 'Members', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:member) { FactoryBot.create :member } + let(:member_encoded_as_json_api) do + { "id" => member.id.to_s, + "type" => "members", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "gardens" => gardens_as_json_api, + "harvests" => harvests_as_json_api, + "photos" => photos_as_json_api, + "plantings" => plantings_as_json_api, + "seeds" => seeds_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/members/#{member.id}" } + + let(:harvests_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } + end + + let(:seeds_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/seeds", + "related" => "#{resource_url}/seeds" } } + end + + let(:plantings_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/plantings", + "related" => "#{resource_url}/plantings" } } + end + let(:gardens_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } + end + + let(:attributes) do + { + "login-name" => member.login_name + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/members', {}, headers } + it { expect(subject['data']).to include(member_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/members/#{member.id}", {}, headers } + it { expect(subject['data']['relationships']).to include("gardens" => gardens_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("seeds" => seeds_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']).to eq(member_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/members', { 'member' => { 'login_name' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/members/#{member.id}", { 'member' => { 'login_name' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/members/#{member.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end From d01a5d7976dd0822a2f0cd8fffcead75486e6cb5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 Nov 2017 22:08:38 +1300 Subject: [PATCH 23/56] Don't show lifespan of perennials --- app/views/crops/_predictions.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 86aaf8f43..7d947db1c 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -10,19 +10,19 @@ an annual crop (living and reproducing in a single year or less) -- unless crop.median_lifespan.nil? +- if crop.annual? && crop.median_lifespan.present? %p Median lifespan of #{crop.name} plants is %b= crop.median_lifespan days -- unless crop.median_days_to_first_harvest.nil? +- if crop.median_days_to_first_harvest.present? %p First harvest expected %b= crop.median_days_to_first_harvest days after planting -- if crop.perennial == false && crop.median_days_to_last_harvest.present? +- if crop.annual? && crop.median_days_to_last_harvest.present? %p Last harvest expected %b= crop.median_days_to_last_harvest From 8884056ff30db99e41b04f10f810238141d179cc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 Nov 2017 23:13:55 +1300 Subject: [PATCH 24/56] Run existing crop specs with annual crop --- app/models/crop.rb | 8 ++- spec/features/crops/crop_detail_page_spec.rb | 60 +++++++++++++------- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 44251ec36..0b6a63bc1 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -170,7 +170,7 @@ class Crop < ActiveRecord::Base end def annual? - perennial != true + !perennial end def interesting? @@ -215,6 +215,12 @@ class Crop < ActiveRecord::Base where(["lower(crops.name) = :value", { value: name.downcase }]) end + def update_medians + plantings.each(&:update_harvest_days) + update_lifespan_medians + update_harvest_medians + end + def update_lifespan_medians # Median lifespan of plantings update(median_lifespan: Planting.where(crop: self).median(:lifespan)) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 45d855bc2..e33e2fe90 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -169,41 +169,54 @@ feature "crop detail page", js: true do end end - shared_examples "lots of harvests" do - def planting - FactoryBot.create :planting, crop: crop, planted_at: 100.days.ago, finished_at: 1.day.ago + shared_examples "predicts harvest" do + describe 'with harvest history data' do + before do + other_planting = FactoryBot.create :planting, crop: planting.crop, planted_at: 200.days.ago + # 50 days to harvest + FactoryBot.create(:harvest, planting: other_planting, harvested_at: 150.days.ago, crop: planting.crop) + # 20 days to harvest + FactoryBot.create(:harvest, planting: other_planting, harvested_at: 180.days.ago, crop: planting.crop) + # 10 days to harvest + FactoryBot.create(:harvest, planting: other_planting, harvested_at: 190.days.ago, crop: planting.crop) + end + # it "predicts harvest" do + # is_expected.to have_text("First harvest expected 20 days after planting") + # end end - before do - # 50 days to harvest - FactoryBot.create(:harvest, harvested_at: 50.days.ago, crop: crop, planting: planting) - # 20 days to harvest - FactoryBot.create(:harvest, harvested_at: 80.days.ago, crop: crop, planting: planting) - # 10 days to harvest - FactoryBot.create(:harvest, harvested_at: 90.days.ago, crop: crop, planting: planting) - planting.crop.plantings.each(&:update_harvest_days) - planting.crop.update_lifespan_medians - planting.crop.update_harvest_medians - end - it { is_expected.to have_text("First harvest expected 20 days after planting") } - it { is_expected.to have_text "Median lifespan of #{crop.name} plants is 99 days" } end subject do + # Update the medians after all the + # data has been loaded + crop.reload + crop.update_medians + visit crop_path(crop) page end context 'predictions' do + let!(:planting) do + FactoryBot.create(:planting, crop: crop, + planted_at: 100.days.ago, + finished_at: 1.day.ago) + end context 'crop is an annual' do - let(:crop) { FactoryBot.create :annual_crop } + let(:crop) { FactoryBot.create(:annual_crop) } describe 'with no harvests' do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" end - it do + + it "predicts lifespan" do + is_expected.to have_text "Median lifespan of #{crop.name} plants is 99 days" + end + + it "describes annual crops" do is_expected.to have_text( "#{crop.name} is an annual crop (living and reproducing in a single year or less)" ) @@ -217,9 +230,12 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" + end + + it "describes perennial crops" do + is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") end - it { is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") } end context 'crop perennial value is null' do @@ -229,7 +245,7 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" end end end From 86ea8eab398b7095f5527c8cc9fea72e20a02b60 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 Nov 2017 21:44:32 +1300 Subject: [PATCH 25/56] Reducing crop class size --- app/models/crop.rb | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 0b6a63bc1..4fa4ef487 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -117,7 +117,6 @@ class Crop < ActiveRecord::Base def update_index(_name_obj) __elasticsearch__.index_document if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" end - # End Elasticsearch section def to_s @@ -128,7 +127,6 @@ class Crop < ActiveRecord::Base scientific_names.first.name unless scientific_names.empty? end - # crop.default_photo # currently returns the first available photo, but exists so that # later we can choose a default photo based on different criteria, # eg. popularity @@ -140,7 +138,6 @@ class Crop < ActiveRecord::Base harvest_with_photo.photos.first if harvest_with_photo end - # crop.sunniness # returns hash indicating whether this crop is grown in # sun/semi-shade/shade # key: sunniness (eg. 'sun') @@ -149,7 +146,6 @@ class Crop < ActiveRecord::Base count_uses_of_property 'sunniness' end - # crop.planted_from # returns a hash of propagation methods (seed, seedling, etc), # key: propagation method (eg. 'seed') # value: count of how many times it's been used by plantings @@ -157,7 +153,6 @@ class Crop < ActiveRecord::Base count_uses_of_property 'planted_from' end - # crop.popular_plant_parts # returns a hash of most harvested plant parts (fruit, seed, etc) # key: plant part (eg. 'fruit') # value: count of how many times it's been used by harvests @@ -206,15 +201,6 @@ class Crop < ActiveRecord::Base reason_for_rejection end - # # Crop.search(string) - def self.search(query) - CropSearchService.search(query) - end - - def self.case_insensitive_name(name) - where(["lower(crops.name) = :value", { value: name.downcase }]) - end - def update_medians plantings.each(&:update_harvest_days) update_lifespan_medians @@ -231,6 +217,14 @@ class Crop < ActiveRecord::Base update(median_days_to_last_harvest: Planting.where(crop: self).median(:days_to_last_harvest)) end + def self.search(query) + CropSearchService.search(query) + end + + def self.case_insensitive_name(name) + where(["lower(crops.name) = :value", { value: name.downcase }]) + end + private def count_uses_of_property(col_name) From 67dec795a0c65f2e8e1fbf522815b2ae52a347d9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 Nov 2017 22:43:47 +1300 Subject: [PATCH 26/56] Reinstated test of first harvest prediction display --- app/views/crops/_predictions.html.haml | 6 +++--- spec/features/crops/crop_detail_page_spec.rb | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 7d947db1c..dbde9c783 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -13,17 +13,17 @@ - if crop.annual? && crop.median_lifespan.present? %p Median lifespan of #{crop.name} plants is - %b= crop.median_lifespan + %strong= crop.median_lifespan days - if crop.median_days_to_first_harvest.present? %p First harvest expected - %b= crop.median_days_to_first_harvest + %strong= crop.median_days_to_first_harvest days after planting - if crop.annual? && crop.median_days_to_last_harvest.present? %p Last harvest expected - %b= crop.median_days_to_last_harvest + %strong= crop.median_days_to_last_harvest days after planting diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index e33e2fe90..05ebdb6e7 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -172,17 +172,19 @@ feature "crop detail page", js: true do shared_examples "predicts harvest" do describe 'with harvest history data' do before do - other_planting = FactoryBot.create :planting, crop: planting.crop, planted_at: 200.days.ago # 50 days to harvest - FactoryBot.create(:harvest, planting: other_planting, harvested_at: 150.days.ago, crop: planting.crop) + FactoryBot.create(:harvest, harvested_at: 150.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) # 20 days to harvest - FactoryBot.create(:harvest, planting: other_planting, harvested_at: 180.days.ago, crop: planting.crop) + FactoryBot.create(:harvest, harvested_at: 180.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) # 10 days to harvest - FactoryBot.create(:harvest, planting: other_planting, harvested_at: 190.days.ago, crop: planting.crop) + FactoryBot.create(:harvest, harvested_at: 190.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) + end + it "predicts harvest" do + is_expected.to have_text("First harvest expected 20 days after planting") end - # it "predicts harvest" do - # is_expected.to have_text("First harvest expected 20 days after planting") - # end end end From 28fdb6e1ed125781caa937bb48431951f8eaccd9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 Nov 2017 12:29:39 +1300 Subject: [PATCH 27/56] Reducing class line count --- app/models/planting.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index 4fe2ccc0a..4dd0b57c4 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -6,17 +6,9 @@ class Planting < ActiveRecord::Base # Constants SUNNINESS_VALUES = %w(sun semi-shade shade) PLANTED_FROM_VALUES = [ - 'seed', - 'seedling', - 'cutting', - 'root division', - 'runner', - 'bulb', - 'root/tuber', - 'bare root plant', - 'advanced plant', - 'graft', - 'layering' + 'seed', 'seedling', 'cutting', 'root division', 'runner', + 'bulb', 'root/tuber', 'bare root plant', 'advanced plant', + 'graft', 'layering' ] ## From c1836cc78e759663647339f6ca48b27056882f6d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 Nov 2017 21:23:28 +1300 Subject: [PATCH 28/56] Removed un-used method, to reduce class size --- app/models/crop.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 4fa4ef487..96ba2bc01 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -102,16 +102,6 @@ class Crop < ActiveRecord::Base Photo.joins(:harvests).where("harvests.crop_id": id) end - def as_indexed_json(_options = {}) - as_json( - only: [:id, :name, :approval_status], - include: { - scientific_names: { only: :name }, - alternate_names: { only: :name } - } - ) - end - # update the Elasticsearch index (only if we're using it in this # environment) def update_index(_name_obj) From fa5e151af07abd55f692716b70413de4f2f9b4d3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 Nov 2017 22:00:32 +1300 Subject: [PATCH 29/56] Request spec for photos api --- spec/requests/api/v1/photos_request_spec.rb | 86 +++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 spec/requests/api/v1/photos_request_spec.rb diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb new file mode 100644 index 000000000..a98446781 --- /dev/null +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -0,0 +1,86 @@ +require 'rails_helper' + +RSpec.describe 'Photos', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:photo) { FactoryBot.create :photo } + let(:photo_encoded_as_json_api) do + { "id" => photo.id.to_s, + "type" => "photos", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "harvests" => harvests_as_json_api, + "gardens" => gardens_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/photos/#{photo.id}" } + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:harvests_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } + end + + let(:gardens_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } + end + + let(:plantings_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/plantings", + "related" => "#{resource_url}/plantings" } } + end + + let(:attributes) do + { + "thumbnail-url" => photo.thumbnail_url, + "fullsize-url" => photo.fullsize_url, + "link-url" => photo.link_url, + "license-name" => photo.license_name, + "link-url" => photo.link_url, + "title" => photo.title + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/photos', {}, headers } + it { expect(subject['data']).to include(photo_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/photos/#{photo.id}", {}, headers } + it { expect(subject['data']['attributes']).to eq(attributes) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']).to eq(photo_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/photos', { 'photo' => { 'name' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/photos/#{photo.id}", { 'photo' => { 'name' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/photos/#{photo.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end From c4a1806a87379ce6d5f476de867d25820c79262d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 Nov 2017 22:01:37 +1300 Subject: [PATCH 30/56] Request spec for photos api --- app/resources/api/v1/photo_resource.rb | 4 +++- spec/requests/api/v1/photos_request_spec.rb | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb index 54ab48cc9..84c7eab16 100644 --- a/app/resources/api/v1/photo_resource.rb +++ b/app/resources/api/v1/photo_resource.rb @@ -4,10 +4,12 @@ module Api immutable has_one :owner, class_name: 'Member' + has_many :plantings + has_many :gardens + has_many :harvests attribute :thumbnail_url attribute :fullsize_url - attribute :link_url attribute :license_name attribute :link_url attribute :title diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb index a98446781..f6ee3e433 100644 --- a/spec/requests/api/v1/photos_request_spec.rb +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -49,7 +49,6 @@ RSpec.describe 'Photos', type: :request do "fullsize-url" => photo.fullsize_url, "link-url" => photo.link_url, "license-name" => photo.license_name, - "link-url" => photo.link_url, "title" => photo.title } end From c747d46ab56e33465b8ab992389f316c6cc7be08 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 Nov 2017 23:22:10 +1300 Subject: [PATCH 31/56] Request spec for seeds api --- spec/requests/api/v1/seeds_request_spec.rb | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 spec/requests/api/v1/seeds_request_spec.rb diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb new file mode 100644 index 000000000..41d622a1f --- /dev/null +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -0,0 +1,73 @@ +require 'rails_helper' + +RSpec.describe 'Photos', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:seed) { FactoryBot.create :seed } + let(:seed_encoded_as_json_api) do + { "id" => seed.id.to_s, + "type" => "seeds", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "crop" => crop_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/seeds/#{seed.id}" } + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:crop_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } + end + + let(:attributes) do + { + "description" => seed.description, + "quantity" => seed.quantity, + "plant-before" => "2013-07-15", + "tradable-to" => seed.tradable_to, + "days-until-maturity-min" => seed.days_until_maturity_min, + "days-until-maturity-max" => seed.days_until_maturity_max, + "organic" => seed.organic, + "gmo" => seed.gmo, + "heirloom" => seed.heirloom + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/seeds', {}, headers } + it { expect(subject['data']).to include(seed_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/seeds/#{seed.id}", {}, headers } + it { expect(subject['data']['attributes']).to eq(attributes) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']).to eq(seed_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/seeds', { 'seed' => { 'name' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/seeds/#{seed.id}", { 'seed' => { 'name' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/seeds/#{seed.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end From eeafb4caa5733eded703414788415fed629311f8 Mon Sep 17 00:00:00 2001 From: deppbot Date: Sun, 12 Nov 2017 00:09:58 +0800 Subject: [PATCH 32/56] Bundle Update on 2017-11-12 --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 500ff014a..5f8bcf612 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,7 +33,7 @@ GEM activejob (4.2.10) activesupport (= 4.2.10) globalid (>= 0.3.0) - activemerchant (1.74.0) + activemerchant (1.75.0) activesupport (>= 3.2.14, < 6.x) builder (>= 2.1.2, < 4.0.0) i18n (>= 0.6.9) @@ -84,7 +84,7 @@ GEM activesupport (>= 3.0.0) uniform_notifier (~> 1.10.0) byebug (9.1.0) - cancancan (2.0.0) + cancancan (2.1.0) capybara (2.15.4) addressable mini_mime (>= 0.1.3) @@ -377,7 +377,7 @@ GEM pry (0.11.2) coderay (~> 1.1.0) method_source (~> 0.9.0) - public_suffix (3.0.0) + public_suffix (3.0.1) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.6.8) @@ -510,7 +510,7 @@ GEM thread_safe (0.3.6) tilt (2.0.8) timecop (0.9.1) - tins (1.15.0) + tins (1.15.1) trollop (1.16.2) tzinfo (1.2.4) thread_safe (~> 0.1) @@ -529,7 +529,7 @@ GEM rack-test (>= 0.5.3) websocket-driver (0.7.0) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) + websocket-extensions (0.1.3) will_paginate (3.1.6) xmlrpc (0.3.0) xpath (2.1.0) From 3fa5ffc5447f450daa51a9b2748218c0acc1092d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 22:51:55 +1300 Subject: [PATCH 33/56] Planting's owner must be the same as its garden's owner --- app/models/planting.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/planting.rb b/app/models/planting.rb index f5f482a5d..4fe2ccc0a 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -50,6 +50,7 @@ class Planting < ActiveRecord::Base validates :garden, presence: true validates :crop, presence: true, approved: { message: "must be present and exist in our database" } validate :finished_must_be_after_planted + validate :owner_must_match_garden_owner validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } @@ -142,4 +143,8 @@ class Planting < ActiveRecord::Base return unless planted_at && finished_at # only check if we have both errors.add(:finished_at, "must be after the planting date") unless planted_at < finished_at end + + def owner_must_match_garden_owner + errors.add(:owner, "must be the same as garden") unless owner == garden.owner + end end From 140611d868a935ede121120e73afd1ffca893a2f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 22:52:40 +1300 Subject: [PATCH 34/56] Get planting factory's owner from its garden --- spec/factories/planting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index 2deb014c5..2bcfac397 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :planting do - garden owner + garden { FactoryBot.create :garden, owner: owner } crop planted_at Time.zone.local(2014, 7, 30) quantity 33 From 97f19a0038594b7eda0670ed4044d91f9f3176d7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 12 Nov 2017 15:51:29 +1300 Subject: [PATCH 35/56] If a harvest has a planting, it must have the same owner --- app/models/harvest.rb | 6 ++++++ spec/factories/harvests.rb | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 21339ab47..c2ad7eab1 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -58,6 +58,7 @@ class Harvest < ActiveRecord::Base in: WEIGHT_UNITS_VALUES.values, message: "%s is not a valid unit" } validate :crop_must_match_planting + validate :owner_must_match_planting validate :harvest_must_be_after_planting def time_from_planting_to_harvest @@ -131,6 +132,11 @@ class Harvest < ActiveRecord::Base errors.add(:planting, "must be the same crop") unless crop == planting.crop end + def owner_must_match_planting + return if planting.blank? # only check if we are linked to a planting + errors.add(:owner, "of harvest must be the same as planting") unless owner == planting.owner + end + def harvest_must_be_after_planting # only check if we are linked to a planting return unless harvested_at.present? && planting.present? && planting.planted_at.present? diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index e1ff04fb3..c910f49da 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -4,7 +4,8 @@ FactoryBot.define do factory :harvest do crop plant_part - owner + planting + owner { planting.owner } harvested_at Time.zone.local(2015, 9, 17) quantity "3" unit "individual" From a6cc530fe59c875880d729743f5ccceb041e71d0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 11 Nov 2017 22:53:07 +1300 Subject: [PATCH 36/56] Updating specs to use same owner for garden and planting --- spec/controllers/harvests_controller_spec.rb | 101 +++++++++--------- spec/factories/harvests.rb | 10 +- spec/features/gardens_spec.rb | 4 +- .../plantings/planting_a_crop_spec.rb | 4 +- spec/models/crop_spec.rb | 34 +++--- spec/models/garden_spec.rb | 40 +++---- spec/models/planting_spec.rb | 16 ++- spec/views/crops/_grown_for.html.haml_spec.rb | 18 ++-- .../crops/_planting_advice.html.haml_spec.rb | 82 +++++++------- spec/views/gardens/show.html.haml_spec.rb | 2 +- spec/views/harvests/show.html.haml_spec.rb | 17 +-- spec/views/plantings/_form.html.haml_spec.rb | 1 + spec/views/plantings/edit.html.haml_spec.rb | 2 +- spec/views/plantings/index.html.haml_spec.rb | 40 +++---- spec/views/plantings/new.html.haml_spec.rb | 3 +- spec/views/plantings/show.html.haml_spec.rb | 42 +++----- 16 files changed, 213 insertions(+), 203 deletions(-) diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index ff4972a7a..c0dea9f2e 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -25,63 +25,61 @@ describe HarvestsController do end describe "GET index" do - before do - @member1 = FactoryBot.create(:member) - @member2 = FactoryBot.create(:member) - @tomato = FactoryBot.create(:tomato) - @maize = FactoryBot.create(:maize) - @harvest1 = FactoryBot.create(:harvest, owner_id: @member1.id, crop_id: @tomato.id) - @harvest2 = FactoryBot.create(:harvest, owner_id: @member2.id, crop_id: @maize.id) + let(:member1) { FactoryBot.create(:member) } + let(:member2) { FactoryBot.create(:member) } + let(:tomato) { FactoryBot.create(:tomato) } + let(:maize) { FactoryBot.create(:maize) } + let(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } + let(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } + + describe "assigns all harvests as @harvests" do + before { get :index, {} } + it { assigns(:harvests).should =~ [harvest1, harvest2] } end - it "assigns all harvests as @harvests" do - get :index, {} - assigns(:harvests).should =~ [@harvest1, @harvest2] + describe "picks up owner from params and shows owner's harvests only" do + before { get :index, owner: member1.slug } + it { expect(assigns(:owner)).to eq member1 } + it { expect(assigns(:harvests)).to eq [harvest1] } end - it "picks up owner from params and shows owner's harvests only" do - get :index, owner: @member1.slug - assigns(:owner).should eq @member1 - assigns(:harvests).should eq [@harvest1] + describe "picks up crop from params and shows the harvests for the crop only" do + before { get :index, crop: maize.name } + it { expect(assigns(:crop)).to eq maize } + it { expect(assigns(:harvests)).to eq [harvest2] } end - it "picks up crop from params and shows the harvests for the crop only" do - get :index, crop: @maize.name - assigns(:crop).should eq @maize - assigns(:harvests).should eq [@harvest2] - end - - it "generates a csv" do - get :index, format: "csv" - response.status.should eq 200 + describe "generates a csv" do + before { get :index, format: "csv" } + it { expect(response.status).to eq 200 } end end describe "GET show" do - it "assigns the requested harvest as @harvest" do - harvest = Harvest.create! valid_attributes - get :show, id: harvest.to_param - assigns(:harvest).should eq(harvest) + let(:harvest) { Harvest.create! valid_attributes } + describe "assigns the requested harvest as @harvest" do + before { get :show, id: harvest.to_param } + it { expect(assigns(:harvest)).to eq(harvest) } end end describe "GET new" do - it "assigns a new harvest as @harvest" do - get :new, {} - assigns(:harvest).should be_a_new(Harvest) + before { get :new, {} } + + describe "assigns a new harvest as @harvest" do + it { expect(assigns(:harvest)).to be_a_new(Harvest) } end - it "sets the date of the harvest to today" do - get :new, {} - assigns(:harvest).harvested_at.should == Time.zone.today + describe "sets the date of the harvest to today" do + it { expect(assigns(:harvest).harvested_at).to eq(Time.zone.today) } end end describe "GET edit" do - it "assigns the requested harvest as @harvest" do - harvest = Harvest.create! valid_attributes - get :edit, id: harvest.to_param - assigns(:harvest).should eq(harvest) + let(:harvest) { Harvest.create! valid_attributes } + describe "assigns the requested harvest as @harvest" do + before { get :edit, id: harvest.to_param } + it { expect(assigns(:harvest)).to eq(harvest) } end end @@ -104,10 +102,10 @@ describe HarvestsController do response.should redirect_to(Harvest.last) end - it "links to planting" do - planting = FactoryBot.create(:planting, owner_id: member.id) - post :create, harvest: valid_attributes.merge(planting_id: planting.id) - expect(Harvest.last.planting.id).to eq(planting.id) + describe "links to planting" do + let(:planting) { FactoryBot.create(:planting, owner_id: member.id, garden: member.gardens.first) } + before { post :create, harvest: valid_attributes.merge(planting_id: planting.id) } + it { expect(Harvest.last.planting.id).to eq(planting.id) } end end @@ -129,10 +127,13 @@ describe HarvestsController do describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - it "does not save planting_id" do - allow(Harvest).to receive(:new).and_return(harvest) - post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) - expect(harvest.planting_id).to eq(nil) + + describe "does not save planting_id" do + before do + allow(Harvest).to receive(:new).and_return(harvest) + post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) + end + it { expect(harvest.planting_id).not_to eq(not_my_planting.id) } end end end @@ -181,10 +182,12 @@ describe HarvestsController do describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - it "does not save planting_id" do - put :update, id: harvest.to_param, - harvest: valid_attributes.merge(planting_id: not_my_planting.id) - expect(harvest.planting_id).to eq(nil) + describe "does not save planting_id" do + before do + put :update, id: harvest.to_param, + harvest: valid_attributes.merge(planting_id: not_my_planting.id) + end + it { expect(harvest.planting_id).to eq(nil) } end end end diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index c910f49da..c707a2e2c 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -2,16 +2,20 @@ FactoryBot.define do factory :harvest do - crop + crop { planting.present? ? planting.crop : FactoryBot.create(:crop) } plant_part - planting - owner { planting.owner } + planting nil + owner { planting.present? ? planting.owner : FactoryBot.create(:member) } harvested_at Time.zone.local(2015, 9, 17) quantity "3" unit "individual" weight_quantity 6 weight_unit "kg" description "A lovely harvest" + + factory :harvest_with_planting do + planting + end end trait :long_description do diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 3d78cbe5d..e9a20d060 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -2,9 +2,9 @@ require 'rails_helper' feature "Planting a crop", js: true do let!(:garden) { create :garden } - let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") } + let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse("2013-3-10") } let!(:tomato) { create :tomato } - let!(:finished_planting) { create :finished_planting, garden: garden, crop: tomato } + let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden: garden, crop: tomato } background do login_as garden.owner diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 177cf9942..0c984837b 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -5,7 +5,9 @@ feature "Planting a crop", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } - let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") } + let!(:planting) do + create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") + end background do login_as member diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 406a65eb0..860e2e935 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -348,7 +348,23 @@ describe Crop do end end + let(:maize) { FactoryBot.create(:maize) } + let(:pp1) { FactoryBot.create(:plant_part) } + let(:pp2) { FactoryBot.create(:plant_part) } + context "harvests" do + let(:h1) do + FactoryBot.create(:harvest, + crop: maize, + plant_part: pp1) + end + + let(:h2) do + FactoryBot.create(:harvest, + crop: maize, + plant_part: pp2) + end + it "has harvests" do crop = FactoryBot.create(:crop) harvest = FactoryBot.create(:harvest, crop: crop) @@ -356,20 +372,6 @@ describe Crop do end end - it 'has plant_parts' do - @maize = FactoryBot.create(:maize) - @pp1 = FactoryBot.create(:plant_part) - @pp2 = FactoryBot.create(:plant_part) - @h1 = FactoryBot.create(:harvest, - crop: @maize, - plant_part: @pp1) - @h2 = FactoryBot.create(:harvest, - crop: @maize, - plant_part: @pp2) - @maize.plant_parts.should include @pp1 - @maize.plant_parts.should include @pp2 - end - it "doesn't duplicate plant_parts" do @maize = FactoryBot.create(:maize) @pp1 = FactoryBot.create(:plant_part) @@ -385,9 +387,7 @@ describe Crop do context "search", :elasticsearch do let(:mushroom) { FactoryBot.create(:crop, name: 'mushroom') } - before do - sync_elasticsearch([mushroom]) - end + before { sync_elasticsearch([mushroom]) } it "finds exact matches" do Crop.search('mushroom').should eq [mushroom] diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index 867b333d1..cbb097d91 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -64,30 +64,30 @@ describe Garden do let(:walnut) { FactoryBot.create(:walnut) } it "should fetch < 4 featured plantings if insufficient exist" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p2, @p1] end it "should fetch most recent 4 featured plantings" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) - @p3 = FactoryBot.create(:planting, crop: chard, garden: garden) - @p4 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) + @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) + @p4 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end it "should skip repeated plantings" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) - @p3 = FactoryBot.create(:planting, crop: chard, garden: garden) - @p4 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden) - @p6 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p7 = FactoryBot.create(:planting, crop: pear, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) + @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) + @p4 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden, owner: garden.owner) + @p6 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p7 = FactoryBot.create(:planting, crop: pear, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p7, @p6, @p5, @p3] end @@ -103,8 +103,8 @@ describe Garden do it "destroys plantings when deleted" do garden = FactoryBot.create(:garden, owner: owner) - @planting1 = FactoryBot.create(:planting, garden: garden) - @planting2 = FactoryBot.create(:planting, garden: garden) + @planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) + @planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) garden.plantings.size.should eq(2) all = Planting.count garden.destroy @@ -185,8 +185,8 @@ describe Garden do it "marks plantings as finished when garden is inactive" do garden = FactoryBot.create(:garden) - p1 = FactoryBot.create(:planting, garden: garden) - p2 = FactoryBot.create(:planting, garden: garden) + p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) + p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) p1.finished.should eq false p2.finished.should eq false @@ -203,8 +203,8 @@ describe Garden do it "doesn't mark the wrong plantings as finished" do g1 = FactoryBot.create(:garden) g2 = FactoryBot.create(:garden) - p1 = FactoryBot.create(:planting, garden: g1) - p2 = FactoryBot.create(:planting, garden: g2) + p1 = FactoryBot.create(:planting, garden: g1, owner: g1.owner) + p2 = FactoryBot.create(:planting, garden: g2, owner: g2.owner) # mark the garden as inactive g1.active = false diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 462bee3e4..ec9eb0746 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -4,7 +4,7 @@ describe Planting do let(:crop) { FactoryBot.create(:tomato) } let(:garden_owner) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: garden_owner) } - let(:planting) { FactoryBot.create(:planting, crop: crop, garden: garden) } + let(:planting) { FactoryBot.create(:planting, crop: crop, garden: garden, owner: garden.owner) } let(:finished_planting) do FactoryBot.create :planting, planted_at: 4.days.ago, finished_at: 2.days.ago, finished: true end @@ -120,7 +120,10 @@ describe Planting do describe 'planting has first harvest' do let(:planting) { FactoryBot.create :planting, planted_at: 100.days.ago } before do - FactoryBot.create :harvest, planting: planting, crop: planting.crop, harvested_at: 10.days.ago + FactoryBot.create(:harvest, + planting: planting, + crop: planting.crop, + harvested_at: 10.days.ago) planting.update_harvest_days planting.crop.update_harvest_medians end @@ -148,12 +151,6 @@ describe Planting do planting.owner.should be_an_instance_of Member end - it "owner isn't necessarily the garden owner" do - # a new owner should be created automatically by FactoryBot - # note that formerly, the planting belonged to an owner through the garden - planting.owner.should_not eq garden_owner - end - it "generates a location" do planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}" end @@ -355,7 +352,8 @@ describe Planting do # this one is newer, and has the same owner, through the garden @planting2 = FactoryBot.create(:planting, created_at: 1.minute.ago, - owner_id: @planting1.owner.id) + garden: @planting1.garden, + owner: @planting1.owner) @planting2.photos << FactoryBot.create(:photo) @planting2.save diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index 290d5d8c6..183445346 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -13,17 +13,17 @@ require 'rails_helper' describe "crops/_grown_for" do - before(:each) do - @crop = FactoryBot.create(:crop) - @pp = FactoryBot.create(:plant_part) - @harvest = FactoryBot.create(:harvest, - crop: @crop, - plant_part: @pp) + let(:crop) { FactoryBot.create(:crop) } + let(:plant_path) { FactoryBot.create(:plant_part) } + let!(:harvest) do + FactoryBot.create(:harvest, + crop: crop, + plant_part: plant_path) end it 'shows plant parts' do - render partial: 'crops/grown_for', locals: { crop: @crop } - rendered.should have_content @pp.name - assert_select "a", href: plant_part_path(@pp) + render partial: 'crops/grown_for', locals: { crop: crop } + rendered.should have_content plant_path.name + assert_select "a", href: plant_part_path(plant_path) end end diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 58df0584d..2e6bf9e93 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -13,58 +13,62 @@ require 'rails_helper' describe "crops/_planting_advice" do - before(:each) do - @owner = FactoryBot.create(:member) - @crop = FactoryBot.create(:crop) - @garden = FactoryBot.create(:garden, owner: @owner) - @planting = FactoryBot.create(:planting, - garden: @garden, - crop: @crop) + let(:planting) { FactoryBot.create(:planting) } + subject { rendered } + + shared_examples "render planting_advice" do + before { render 'crops/planting_advice', crop: planting.crop } end - context "sunniness" do - it "doesn't show sunniness if none are set" do - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in: not known." + describe "sunniness" do + context "with no sunniness set" do + include_examples "render planting_advice" + it "doesn't show sunniness" do + is_expected.to have_content "Plant in: not known." + end end - it "shows sunniness frequencies" do - FactoryBot.create(:sunny_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in:" - rendered.should have_content "sun (1)" + context "with sunniness frequencies" do + before { FactoryBot.create(:sunny_planting, crop: planting.crop) } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (1)" } end - it "shows multiple sunniness frequencies" do - FactoryBot.create(:sunny_planting, crop: @crop) - FactoryBot.create(:sunny_planting, crop: @crop) - FactoryBot.create(:shady_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in:" - rendered.should have_content "sun (2), shade (1)" + context "with multiple sunniness frequencies" do + before do + FactoryBot.create_list(:sunny_planting, 2, crop: planting.crop) + FactoryBot.create(:shady_planting, crop: planting.crop) + end + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (2), shade (1)" } end end - context "planted from" do - it "doesn't show planted_from if none are set" do - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from: not known." + describe "planted from" do + context "when none are set" do + include_examples "render planting_advice" + it "doesn't show planted_from " do + is_expected.to have_content "Plant from: not known." + end end - it "shows planted_from frequencies" do - FactoryBot.create(:seed_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from:" - rendered.should have_content "seed (1)" + context "with planted_from frequencies" do + before { FactoryBot.create(:seed_planting, crop: planting.crop) } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (1)" } end - it "shows multiple planted_from frequencies" do - FactoryBot.create(:seed_planting, crop: @crop) - FactoryBot.create(:seed_planting, crop: @crop) - FactoryBot.create(:cutting_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from:" - rendered.should have_content "seed (2), cutting (1)" + context "with multiple planted_from frequencies" do + before do + FactoryBot.create_list(:seed_planting, 2, crop: planting.crop) + FactoryBot.create(:cutting_planting, crop: planting.crop) + end + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (2), cutting (1)" } end end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 83f993a16..b22ee0452 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -17,7 +17,7 @@ describe "gardens/show" do @owner = FactoryBot.create(:member) controller.stub(:current_user) { @owner } @garden = FactoryBot.create(:garden, owner: @owner) - @planting = FactoryBot.create(:planting, garden: @garden) + @planting = FactoryBot.create(:planting, garden: @garden, owner: @garden.owner) assign(:garden, @garden) assign(:current_plantings, [@planting]) assign(:finished_plantings, []) diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index 129648c71..b13d53ed6 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -13,16 +13,19 @@ require 'rails_helper' describe "harvests/show" do - before(:each) do + let!(:harvest) { FactoryBot.create(:harvest) } + + before do controller.stub(:current_user) { nil } - @crop = FactoryBot.create(:tomato) - @harvest = assign(:harvest, FactoryBot.create(:harvest, crop: @crop)) + assign(:harvest, harvest) render end - it "renders attributes" do - rendered.should have_content @crop.name - rendered.should have_content @harvest.harvested_at.to_s - rendered.should have_content @harvest.plant_part.to_s + subject { render } + + describe "renders attributes" do + it { is_expected.to have_content harvest.crop.name } + it { is_expected.to have_content harvest.harvested_at.to_s } + it { is_expected.to have_content harvest.plant_part.to_s } end end diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 59d4d832b..926150f73 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -24,6 +24,7 @@ describe "plantings/_form" do @planting = FactoryBot.create(:planting, garden: @garden, crop: @crop, + owner: @member, planted_at: Date.new(2013, 3, 1)) render end diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index c37f9947a..fc7ff7f30 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -28,7 +28,7 @@ describe "plantings/edit" do @garden2 = FactoryBot.create(:garden_a, owner: @member) @planting = assign(:planting, - FactoryBot.create(:planting, garden: @garden, crop: @tomato)) + FactoryBot.create(:planting, garden: @garden, crop: @tomato, owner: @member)) end context "logged in" do diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index e7831889f..10de32f81 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -13,29 +13,31 @@ require 'rails_helper' describe "plantings/index" do + let(:member) { FactoryBot.create(:member) } + let(:garden) { FactoryBot.create(:garden, owner: member) } + let(:tomato) { FactoryBot.create(:tomato) } + let(:maize) { FactoryBot.create(:maize) } before(:each) do controller.stub(:current_user) { nil } - @member = FactoryBot.create(:member) - @garden = FactoryBot.create(:garden, owner: @member) - @tomato = FactoryBot.create(:tomato) - @maize = FactoryBot.create(:maize) page = 1 per_page = 3 total_entries = 3 plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ FactoryBot.create(:planting, - garden: @garden, - crop: @tomato, - owner: @member), + garden: garden, + crop: tomato, + owner: member), FactoryBot.create(:planting, - garden: @garden, - crop: @maize, + garden: garden, + crop: maize, + owner: garden.owner, description: '', planted_at: Time.zone.local(2013, 1, 13)), FactoryBot.create(:planting, - garden: @garden, - crop: @tomato, + garden: garden, + owner: garden.owner, + crop: tomato, planted_at: Time.zone.local(2013, 1, 13), finished_at: Time.zone.local(2013, 1, 20), finished: true) @@ -46,10 +48,10 @@ describe "plantings/index" do end it "renders a list of plantings" do - rendered.should have_content @tomato.name - rendered.should have_content @maize.name - rendered.should have_content @member.login_name - rendered.should have_content @garden.name + rendered.should have_content tomato.name + rendered.should have_content maize.name + rendered.should have_content member.login_name + rendered.should have_content garden.name end it "displays planting time" do @@ -69,14 +71,14 @@ describe "plantings/index" do end it "displays member's name in title" do - assign(:owner, @member) + assign(:owner, member) render - view.content_for(:title).should have_content @member.login_name + view.content_for(:title).should have_content member.login_name end it "displays crop's name in title" do - assign(:crop, @tomato) + assign(:crop, tomato) render - view.content_for(:title).should have_content @tomato.name + view.content_for(:title).should have_content tomato.name end end diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 9eb941d1d..db1da2826 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -25,7 +25,8 @@ describe "plantings/new" do assign(:planting, FactoryBot.create(:planting, garden: @garden_a, - crop: @crop2)) + crop: @crop2, + owner: @member)) end context "logged in" do diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index f948ca394..b68ceb6c1 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -13,25 +13,22 @@ require 'rails_helper' describe "plantings/show" do - def create_planting_for(member) - @garden = FactoryBot.create(:garden, owner: @member) - @crop = FactoryBot.create(:tomato) - @planting = assign(:planting, - FactoryBot.create(:planting, garden: @garden, crop: @crop, - planted_from: 'cutting')) + let(:crop) { FactoryBot.create(:tomato) } + let(:member) { FactoryBot.create(:member) } + let(:garden) { FactoryBot.create(:garden, owner: member) } + let(:planting) do + FactoryBot.create(:planting, garden: garden, crop: crop, + owner: garden.owner, + planted_from: 'cutting') end before(:each) do - @member = FactoryBot.create(:member) - controller.stub(:current_user) { @member } - @p = create_planting_for(@member) + assign(:planting, planting) + controller.stub(:current_user) { member } end context 'sunniness' do - before(:each) do - @p = assign(:planting, - FactoryBot.create(:sunny_planting)) - end + let(:planting) { FactoryBot.create(:sunny_planting) } it "shows the sunniness" do render @@ -41,10 +38,7 @@ describe "plantings/show" do end context 'planted from' do - before(:each) do - @p = assign(:planting, FactoryBot.create(:cutting_planting)) - end - + let(:planting) { FactoryBot.create(:cutting_planting) } it "shows planted_from" do render rendered.should have_content 'Planted from:' @@ -52,8 +46,7 @@ describe "plantings/show" do end it "doesn't show planted_from if blank" do - @p.planted_from = '' - @p.save + planting.update(planted_from: '') render rendered.should_not have_content 'Planted from:' rendered.should_not have_content 'cutting' @@ -61,10 +54,10 @@ describe "plantings/show" do end it "shows photos" do - @photo = FactoryBot.create(:photo, owner: @member) - @p.photos << @photo + photo = FactoryBot.create(:photo, owner: member) + planting.photos << photo render - assert_select "img[src='#{@photo.thumbnail_url}']" + assert_select "img[src='#{photo.thumbnail_url}']" end it "shows a link to add photos" do @@ -96,13 +89,12 @@ describe "plantings/show" do context "location set" do before(:each) do - @p.owner.location = 'Greenwich, UK' - @p.owner.save + planting.owner.update(location: 'Greenwich, UK') render end it "shows the member's location in parentheses" do - rendered.should have_content "(#{@p.owner.location})" + rendered.should have_content "(#{planting.owner.location})" end end end From 80a4739f343bc0855a3af6c9b8c8fe7427d5b333 Mon Sep 17 00:00:00 2001 From: Shiny Date: Mon, 13 Nov 2017 22:54:55 +1300 Subject: [PATCH 37/56] Underscore prefix on our last unused args (#1442) --- .rubocop_todo.yml | 7 ------- app/controllers/sessions_controller.rb | 2 +- config/unicorn.rb | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b303fd313..211de1ca6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -10,13 +10,6 @@ Lint/HandleExceptions: Exclude: - 'lib/tasks/testing.rake' -# Cop supports --auto-correct. -# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. -Lint/UnusedBlockArgument: - Exclude: - - 'app/controllers/sessions_controller.rb' - - 'config/unicorn.rb' - # Cop supports --auto-correct. # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. Lint/UnusedMethodArgument: diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 968e71e33..6106e0c75 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -2,7 +2,7 @@ class SessionsController < Devise::SessionsController respond_to :json def create - super do |resource| + super do |_resource| if Crop.pending_approval.present? && current_member.role?(:crop_wrangler) flash[:alert] = "There are crops waiting to be wrangled." end diff --git a/config/unicorn.rb b/config/unicorn.rb index e4153a81f..6a63af23f 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -3,7 +3,7 @@ worker_processes 3 timeout 30 preload_app true -before_fork do |server, worker| +before_fork do |_server, _worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid @@ -13,7 +13,7 @@ before_fork do |server, worker| ActiveRecord::Base.connection.disconnect! end -after_fork do |server, worker| +after_fork do |_server, _worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT' end From 90653aa57f20b53243a607944d0ec166286457da Mon Sep 17 00:00:00 2001 From: deppbot Date: Wed, 15 Nov 2017 04:10:21 +0800 Subject: [PATCH 38/56] Bundle Update on 2017-11-15 --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5f8bcf612..b973bae24 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -84,8 +84,8 @@ GEM activesupport (>= 3.0.0) uniform_notifier (~> 1.10.0) byebug (9.1.0) - cancancan (2.1.0) - capybara (2.15.4) + cancancan (2.1.1) + capybara (2.16.0) addressable mini_mime (>= 0.1.3) nokogiri (>= 1.3.3) @@ -139,7 +139,7 @@ GEM term-ansicolor (~> 1.3) thor (~> 0.19.1) tins (~> 1.6) - crass (1.0.2) + crass (1.0.3) csv_shaper (1.3.0) activesupport (>= 3.0.0) d3-rails (3.5.17) @@ -323,7 +323,7 @@ GEM multi_xml (0.6.0) multipart-post (2.0.0) nenv (0.3.0) - newrelic_rpm (4.5.0.337) + newrelic_rpm (4.6.0.338) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) notiffany (0.1.1) @@ -360,8 +360,8 @@ GEM cocaine (~> 0.5.5) mime-types mimemagic (~> 0.3.0) - parser (2.4.0.0) - ast (~> 2.2) + parser (2.4.0.2) + ast (~> 2.3) pg (0.21.0) phantomjs (2.1.1.0) platform-api (2.1.0) @@ -374,7 +374,7 @@ GEM cliver (~> 0.3.1) websocket-driver (>= 0.2.0) powerpack (0.1.1) - pry (0.11.2) + pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) public_suffix (3.0.1) @@ -469,7 +469,7 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.6) + sass-rails (5.0.7) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) From b8a5ff9acf5eea198fd9239b58dab74de22be362 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 Nov 2017 22:08:38 +1300 Subject: [PATCH 39/56] Don't show lifespan of perennials --- app/views/crops/_predictions.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 86aaf8f43..7d947db1c 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -10,19 +10,19 @@ an annual crop (living and reproducing in a single year or less) -- unless crop.median_lifespan.nil? +- if crop.annual? && crop.median_lifespan.present? %p Median lifespan of #{crop.name} plants is %b= crop.median_lifespan days -- unless crop.median_days_to_first_harvest.nil? +- if crop.median_days_to_first_harvest.present? %p First harvest expected %b= crop.median_days_to_first_harvest days after planting -- if crop.perennial == false && crop.median_days_to_last_harvest.present? +- if crop.annual? && crop.median_days_to_last_harvest.present? %p Last harvest expected %b= crop.median_days_to_last_harvest From 5ad00681420e7ef7304b240fcc8ce1e26195359a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 Nov 2017 23:13:55 +1300 Subject: [PATCH 40/56] Run existing crop specs with annual crop --- app/models/crop.rb | 8 ++- spec/features/crops/crop_detail_page_spec.rb | 60 +++++++++++++------- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 44251ec36..0b6a63bc1 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -170,7 +170,7 @@ class Crop < ActiveRecord::Base end def annual? - perennial != true + !perennial end def interesting? @@ -215,6 +215,12 @@ class Crop < ActiveRecord::Base where(["lower(crops.name) = :value", { value: name.downcase }]) end + def update_medians + plantings.each(&:update_harvest_days) + update_lifespan_medians + update_harvest_medians + end + def update_lifespan_medians # Median lifespan of plantings update(median_lifespan: Planting.where(crop: self).median(:lifespan)) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 45d855bc2..e33e2fe90 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -169,41 +169,54 @@ feature "crop detail page", js: true do end end - shared_examples "lots of harvests" do - def planting - FactoryBot.create :planting, crop: crop, planted_at: 100.days.ago, finished_at: 1.day.ago + shared_examples "predicts harvest" do + describe 'with harvest history data' do + before do + other_planting = FactoryBot.create :planting, crop: planting.crop, planted_at: 200.days.ago + # 50 days to harvest + FactoryBot.create(:harvest, planting: other_planting, harvested_at: 150.days.ago, crop: planting.crop) + # 20 days to harvest + FactoryBot.create(:harvest, planting: other_planting, harvested_at: 180.days.ago, crop: planting.crop) + # 10 days to harvest + FactoryBot.create(:harvest, planting: other_planting, harvested_at: 190.days.ago, crop: planting.crop) + end + # it "predicts harvest" do + # is_expected.to have_text("First harvest expected 20 days after planting") + # end end - before do - # 50 days to harvest - FactoryBot.create(:harvest, harvested_at: 50.days.ago, crop: crop, planting: planting) - # 20 days to harvest - FactoryBot.create(:harvest, harvested_at: 80.days.ago, crop: crop, planting: planting) - # 10 days to harvest - FactoryBot.create(:harvest, harvested_at: 90.days.ago, crop: crop, planting: planting) - planting.crop.plantings.each(&:update_harvest_days) - planting.crop.update_lifespan_medians - planting.crop.update_harvest_medians - end - it { is_expected.to have_text("First harvest expected 20 days after planting") } - it { is_expected.to have_text "Median lifespan of #{crop.name} plants is 99 days" } end subject do + # Update the medians after all the + # data has been loaded + crop.reload + crop.update_medians + visit crop_path(crop) page end context 'predictions' do + let!(:planting) do + FactoryBot.create(:planting, crop: crop, + planted_at: 100.days.ago, + finished_at: 1.day.ago) + end context 'crop is an annual' do - let(:crop) { FactoryBot.create :annual_crop } + let(:crop) { FactoryBot.create(:annual_crop) } describe 'with no harvests' do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" end - it do + + it "predicts lifespan" do + is_expected.to have_text "Median lifespan of #{crop.name} plants is 99 days" + end + + it "describes annual crops" do is_expected.to have_text( "#{crop.name} is an annual crop (living and reproducing in a single year or less)" ) @@ -217,9 +230,12 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" + end + + it "describes perennial crops" do + is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") end - it { is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") } end context 'crop perennial value is null' do @@ -229,7 +245,7 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" end end end From cef236d8f8c5185170c7adaf6b0e83f4ed148cea Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 Nov 2017 21:44:32 +1300 Subject: [PATCH 41/56] Reducing crop class size --- app/models/crop.rb | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 0b6a63bc1..4fa4ef487 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -117,7 +117,6 @@ class Crop < ActiveRecord::Base def update_index(_name_obj) __elasticsearch__.index_document if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" end - # End Elasticsearch section def to_s @@ -128,7 +127,6 @@ class Crop < ActiveRecord::Base scientific_names.first.name unless scientific_names.empty? end - # crop.default_photo # currently returns the first available photo, but exists so that # later we can choose a default photo based on different criteria, # eg. popularity @@ -140,7 +138,6 @@ class Crop < ActiveRecord::Base harvest_with_photo.photos.first if harvest_with_photo end - # crop.sunniness # returns hash indicating whether this crop is grown in # sun/semi-shade/shade # key: sunniness (eg. 'sun') @@ -149,7 +146,6 @@ class Crop < ActiveRecord::Base count_uses_of_property 'sunniness' end - # crop.planted_from # returns a hash of propagation methods (seed, seedling, etc), # key: propagation method (eg. 'seed') # value: count of how many times it's been used by plantings @@ -157,7 +153,6 @@ class Crop < ActiveRecord::Base count_uses_of_property 'planted_from' end - # crop.popular_plant_parts # returns a hash of most harvested plant parts (fruit, seed, etc) # key: plant part (eg. 'fruit') # value: count of how many times it's been used by harvests @@ -206,15 +201,6 @@ class Crop < ActiveRecord::Base reason_for_rejection end - # # Crop.search(string) - def self.search(query) - CropSearchService.search(query) - end - - def self.case_insensitive_name(name) - where(["lower(crops.name) = :value", { value: name.downcase }]) - end - def update_medians plantings.each(&:update_harvest_days) update_lifespan_medians @@ -231,6 +217,14 @@ class Crop < ActiveRecord::Base update(median_days_to_last_harvest: Planting.where(crop: self).median(:days_to_last_harvest)) end + def self.search(query) + CropSearchService.search(query) + end + + def self.case_insensitive_name(name) + where(["lower(crops.name) = :value", { value: name.downcase }]) + end + private def count_uses_of_property(col_name) From b591529892e3b147bc0c1b9ebeb975d3fb0f049e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 Nov 2017 22:43:47 +1300 Subject: [PATCH 42/56] Reinstated test of first harvest prediction display --- app/views/crops/_predictions.html.haml | 6 +++--- spec/features/crops/crop_detail_page_spec.rb | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 7d947db1c..dbde9c783 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -13,17 +13,17 @@ - if crop.annual? && crop.median_lifespan.present? %p Median lifespan of #{crop.name} plants is - %b= crop.median_lifespan + %strong= crop.median_lifespan days - if crop.median_days_to_first_harvest.present? %p First harvest expected - %b= crop.median_days_to_first_harvest + %strong= crop.median_days_to_first_harvest days after planting - if crop.annual? && crop.median_days_to_last_harvest.present? %p Last harvest expected - %b= crop.median_days_to_last_harvest + %strong= crop.median_days_to_last_harvest days after planting diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index e33e2fe90..05ebdb6e7 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -172,17 +172,19 @@ feature "crop detail page", js: true do shared_examples "predicts harvest" do describe 'with harvest history data' do before do - other_planting = FactoryBot.create :planting, crop: planting.crop, planted_at: 200.days.ago # 50 days to harvest - FactoryBot.create(:harvest, planting: other_planting, harvested_at: 150.days.ago, crop: planting.crop) + FactoryBot.create(:harvest, harvested_at: 150.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) # 20 days to harvest - FactoryBot.create(:harvest, planting: other_planting, harvested_at: 180.days.ago, crop: planting.crop) + FactoryBot.create(:harvest, harvested_at: 180.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) # 10 days to harvest - FactoryBot.create(:harvest, planting: other_planting, harvested_at: 190.days.ago, crop: planting.crop) + FactoryBot.create(:harvest, harvested_at: 190.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) + end + it "predicts harvest" do + is_expected.to have_text("First harvest expected 20 days after planting") end - # it "predicts harvest" do - # is_expected.to have_text("First harvest expected 20 days after planting") - # end end end From 1cd3c64590d320952b605180b7c4973f17cc7260 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 Nov 2017 12:29:39 +1300 Subject: [PATCH 43/56] Reducing class line count --- app/models/planting.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index 4fe2ccc0a..4dd0b57c4 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -6,17 +6,9 @@ class Planting < ActiveRecord::Base # Constants SUNNINESS_VALUES = %w(sun semi-shade shade) PLANTED_FROM_VALUES = [ - 'seed', - 'seedling', - 'cutting', - 'root division', - 'runner', - 'bulb', - 'root/tuber', - 'bare root plant', - 'advanced plant', - 'graft', - 'layering' + 'seed', 'seedling', 'cutting', 'root division', 'runner', + 'bulb', 'root/tuber', 'bare root plant', 'advanced plant', + 'graft', 'layering' ] ## From efe39da878ce97940b49ffbff69b5a58ea9c28ce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 Nov 2017 21:23:28 +1300 Subject: [PATCH 44/56] Removed un-used method, to reduce class size --- app/models/crop.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 4fa4ef487..96ba2bc01 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -102,16 +102,6 @@ class Crop < ActiveRecord::Base Photo.joins(:harvests).where("harvests.crop_id": id) end - def as_indexed_json(_options = {}) - as_json( - only: [:id, :name, :approval_status], - include: { - scientific_names: { only: :name }, - alternate_names: { only: :name } - } - ) - end - # update the Elasticsearch index (only if we're using it in this # environment) def update_index(_name_obj) From d8bf8ae4dfd107d499773ce69f8d59af4b7c8e08 Mon Sep 17 00:00:00 2001 From: milesgould Date: Fri, 17 Nov 2017 10:34:32 +0000 Subject: [PATCH 45/56] De-deprecate controller and view specs We deprecated controller and view specs on the grounds that they were brittle, and were a poorer measure of user experience than feature specs. However, feature specs have their own problems: they're much slower to run, and flakier (see #901). We also ran into a few cases where feature specs erroneously passed because they were checking for the presence of a string that occurred in the error page! Hence, we're cautiously un-deprecating controller and view specs. Fixes #1132 --- spec/controllers/account_types_controller_spec.rb | 12 ------------ spec/controllers/accounts_controller_spec.rb | 12 ------------ spec/controllers/admin/orders_controller_spec.rb | 12 ------------ spec/controllers/admin_controller_spec.rb | 12 ------------ spec/controllers/authentications_controller_spec.rb | 12 ------------ spec/controllers/comments_controller_spec.rb | 12 ------------ spec/controllers/crops_controller_spec.rb | 12 ------------ spec/controllers/forums_controller_spec.rb | 12 ------------ spec/controllers/gardens_controller_spec.rb | 12 ------------ spec/controllers/harvests_controller_spec.rb | 12 ------------ spec/controllers/home_controller_spec.rb | 12 ------------ spec/controllers/member_controller_spec.rb | 12 ------------ spec/controllers/notifications_controller_spec.rb | 12 ------------ spec/controllers/order_items_controller_spec.rb | 12 ------------ spec/controllers/orders_controller_spec.rb | 12 ------------ spec/controllers/photos_controller_spec.rb | 11 ----------- spec/controllers/places_controller_spec.rb | 12 ------------ spec/controllers/plant_parts_controller_spec.rb | 12 ------------ spec/controllers/plantings_controller_spec.rb | 12 ------------ spec/controllers/posts_controller_spec.rb | 12 ------------ spec/controllers/products_controller_spec.rb | 12 ------------ spec/controllers/registrations_controller_spec.rb | 12 ------------ spec/controllers/roles_controller_spec.rb | 12 ------------ spec/controllers/scientific_names_controller_spec.rb | 12 ------------ spec/controllers/seeds_controller_spec.rb | 12 ------------ spec/controllers/shop_controller_spec.rb | 12 ------------ spec/views/account_types/edit.html.haml_spec.rb | 12 ------------ spec/views/account_types/index.html.haml_spec.rb | 12 ------------ spec/views/account_types/new.html.haml_spec.rb | 12 ------------ spec/views/account_types/show.html.haml_spec.rb | 12 ------------ spec/views/accounts/edit.html.haml_spec.rb | 12 ------------ spec/views/accounts/index.html.haml_spec.rb | 12 ------------ spec/views/accounts/new.html.haml_spec.rb | 12 ------------ spec/views/accounts/show.html.haml_spec.rb | 12 ------------ spec/views/admin/index_spec.rb | 12 ------------ spec/views/admin/newsletter_spec.rb | 12 ------------ spec/views/admin/orders/index_spec.rb | 12 ------------ spec/views/comments/edit.html.haml_spec.rb | 12 ------------ spec/views/comments/index.html.haml_spec.rb | 12 ------------ spec/views/comments/index.rss.haml_spec.rb | 12 ------------ spec/views/comments/new.html.haml_spec.rb | 12 ------------ spec/views/comments/show.html.haml_spec.rb | 12 ------------ spec/views/crops/_grown_for.html.haml_spec.rb | 12 ------------ spec/views/crops/_planting_advice.html.haml_spec.rb | 12 ------------ spec/views/crops/_popover.html.haml_spec.rb | 12 ------------ spec/views/crops/edit.html.haml_spec.rb | 12 ------------ spec/views/crops/hierarchy.html.haml_spec.rb | 12 ------------ spec/views/crops/index.html.haml_spec.rb | 12 ------------ spec/views/crops/index.rss.haml_spec.rb | 12 ------------ spec/views/crops/new.html.haml_spec.rb | 12 ------------ spec/views/crops/wrangle.html.haml_spec.rb | 12 ------------ .../devise/mailer/confirmation_instructions_spec.rb | 12 ------------ .../mailer/reset_password_instructions_spec.rb | 12 ------------ spec/views/devise/mailer/unlock_instructions_spec.rb | 12 ------------ spec/views/devise/registrations/edit_spec.rb | 12 ------------ spec/views/devise/registrations/new_spec.rb | 12 ------------ spec/views/devise/sessions/new_spec.rb | 12 ------------ spec/views/devise/unlocks/new_spec.rb | 12 ------------ spec/views/forums/edit.html.haml_spec.rb | 12 ------------ spec/views/forums/index.html.haml_spec.rb | 12 ------------ spec/views/forums/new.html.haml_spec.rb | 12 ------------ spec/views/forums/show.html.haml_spec.rb | 12 ------------ spec/views/gardens/edit.html.haml_spec.rb | 12 ------------ spec/views/gardens/new.html.haml_spec.rb | 12 ------------ spec/views/gardens/show.html.haml_spec.rb | 12 ------------ spec/views/harvests/edit.html.haml_spec.rb | 12 ------------ spec/views/harvests/index.html.haml_spec.rb | 12 ------------ spec/views/harvests/new.html.haml_spec.rb | 12 ------------ spec/views/harvests/show.html.haml_spec.rb | 12 ------------ spec/views/home/_blurb.html.haml_spec.rb | 12 ------------ spec/views/home/_crops.html.haml_spec.rb | 12 ------------ spec/views/home/_members.html.haml_spec.rb | 12 ------------ spec/views/home/_seeds.html.haml_spec.rb | 12 ------------ spec/views/home/_stats.html.haml_spec.rb | 12 ------------ spec/views/home/index_spec.rb | 12 ------------ spec/views/layouts/_header_spec.rb | 12 ------------ spec/views/layouts/_meta_spec.rb | 12 ------------ spec/views/layouts/application_spec.rb | 12 ------------ spec/views/notifications/index.html.haml_spec.rb | 12 ------------ spec/views/notifications/new.html.haml_spec.rb | 12 ------------ spec/views/notifications/show.html.haml_spec.rb | 12 ------------ spec/views/notifier/notify.html.haml_spec.rb | 12 ------------ spec/views/orders/index.html.haml_spec.rb | 12 ------------ spec/views/orders/show.html.haml_spec.rb | 12 ------------ spec/views/photos/edit.html.haml_spec.rb | 12 ------------ spec/views/photos/index.html.haml_spec.rb | 12 ------------ spec/views/photos/new.html.haml_spec.rb | 12 ------------ spec/views/photos/show.html.haml_spec.rb | 12 ------------ spec/views/places/_map_attribution.html.haml_spec.rb | 12 ------------ spec/views/places/index.html.haml_spec.rb | 12 ------------ spec/views/places/show.html.haml_spec.rb | 12 ------------ spec/views/plant_parts/edit.html.haml_spec.rb | 12 ------------ spec/views/plant_parts/index.html.haml_spec.rb | 12 ------------ spec/views/plant_parts/new.html.haml_spec.rb | 12 ------------ spec/views/plant_parts/show.html.haml_spec.rb | 12 ------------ spec/views/plantings/_form.html.haml_spec.rb | 12 ------------ spec/views/plantings/edit.html.haml_spec.rb | 12 ------------ spec/views/plantings/index.html.haml_spec.rb | 12 ------------ spec/views/plantings/index.rss.haml_spec.rb | 12 ------------ spec/views/plantings/new.html.haml_spec.rb | 12 ------------ spec/views/plantings/show.html.haml_spec.rb | 12 ------------ spec/views/posts/_single.html.haml_spec.rb | 12 ------------ spec/views/posts/edit.html.haml_spec.rb | 12 ------------ spec/views/posts/index.html.haml_spec.rb | 12 ------------ spec/views/posts/index.rss.haml_spec.rb | 12 ------------ spec/views/posts/new.html.haml_spec.rb | 12 ------------ spec/views/posts/show.rss.haml_spec.rb | 12 ------------ spec/views/products/edit.html.haml_spec.rb | 12 ------------ spec/views/products/index.html.haml_spec.rb | 12 ------------ spec/views/products/new.html.haml_spec.rb | 12 ------------ spec/views/products/show.html.haml_spec.rb | 12 ------------ spec/views/roles/edit.html.haml_spec.rb | 12 ------------ spec/views/roles/index.html.haml_spec.rb | 12 ------------ spec/views/roles/new.html.haml_spec.rb | 12 ------------ spec/views/roles/show.html.haml_spec.rb | 12 ------------ spec/views/scientific_names/edit.html.haml_spec.rb | 12 ------------ spec/views/scientific_names/index.html.haml_spec.rb | 12 ------------ spec/views/scientific_names/new.html.haml_spec.rb | 12 ------------ spec/views/scientific_names/show.html.haml_spec.rb | 12 ------------ spec/views/seeds/edit.html.haml_spec.rb | 12 ------------ spec/views/seeds/index.rss.haml_spec.rb | 12 ------------ spec/views/seeds/new.html.haml_spec.rb | 12 ------------ spec/views/seeds/show.html.haml_spec.rb | 12 ------------ spec/views/shop/index_spec.rb | 12 ------------ 124 files changed, 1487 deletions(-) diff --git a/spec/controllers/account_types_controller_spec.rb b/spec/controllers/account_types_controller_spec.rb index 633311b6e..3a7559f63 100644 --- a/spec/controllers/account_types_controller_spec.rb +++ b/spec/controllers/account_types_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe AccountTypesController do diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index d159f4114..2b4222f1d 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe AccountsController do diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb index a81875427..fb475b34c 100644 --- a/spec/controllers/admin/orders_controller_spec.rb +++ b/spec/controllers/admin/orders_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe Admin::OrdersController do diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb index 6e97245d1..9f134bbab 100644 --- a/spec/controllers/admin_controller_spec.rb +++ b/spec/controllers/admin_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe AdminController do diff --git a/spec/controllers/authentications_controller_spec.rb b/spec/controllers/authentications_controller_spec.rb index fe7eaa61f..8b61bbddc 100644 --- a/spec/controllers/authentications_controller_spec.rb +++ b/spec/controllers/authentications_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe AuthenticationsController do diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index e65a24544..23210a875 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe CommentsController do diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index 9a0a1dcdc..1f9e06d43 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe CropsController do diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb index f320204e2..5c59473cb 100644 --- a/spec/controllers/forums_controller_spec.rb +++ b/spec/controllers/forums_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe ForumsController do diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 5fef6e210..b0ccae0b8 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' RSpec.describe GardensController, type: :controller do diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index c0dea9f2e..8a2edb56b 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe HarvestsController do diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index eb71e1f4a..cb12b2bb4 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe HomeController do diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 866507f5f..b04bcd799 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe MembersController do diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 0619a6707..fd6f40aa1 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe NotificationsController do diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb index 0c1b50706..1da3c3b8d 100644 --- a/spec/controllers/order_items_controller_spec.rb +++ b/spec/controllers/order_items_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe OrderItemsController do diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb index d02fc6e27..3c6631d8c 100644 --- a/spec/controllers/orders_controller_spec.rb +++ b/spec/controllers/orders_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe OrdersController do diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 7c935422c..8f4fab28e 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -1,15 +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. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. require 'rails_helper' diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index 79c1dc623..8b6cb0a31 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe PlacesController do diff --git a/spec/controllers/plant_parts_controller_spec.rb b/spec/controllers/plant_parts_controller_spec.rb index 239422efa..c6e11f315 100644 --- a/spec/controllers/plant_parts_controller_spec.rb +++ b/spec/controllers/plant_parts_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe PlantPartsController do diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index e9ce41369..1bacacc8c 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe PlantingsController do diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 4cd61d242..cbfe8b46c 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe PostsController do diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb index 63c17aa66..173ef9ba4 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/products_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe ProductsController do diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index c69144fd6..015bbb705 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe RegistrationsController do diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb index 5c2271bce..9bf0ea1b5 100644 --- a/spec/controllers/roles_controller_spec.rb +++ b/spec/controllers/roles_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe RolesController do diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb index 64b1e97fe..412f53224 100644 --- a/spec/controllers/scientific_names_controller_spec.rb +++ b/spec/controllers/scientific_names_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe ScientificNamesController do diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index 9ae6af1e2..c2fd699eb 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe SeedsController do diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 4a438ea76..6298b7e76 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe ShopController do diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb index 09bcc35ce..1bd22be03 100644 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ b/spec/views/account_types/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "account_types/edit" do diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb index b5aa55b17..56020fc35 100644 --- a/spec/views/account_types/index.html.haml_spec.rb +++ b/spec/views/account_types/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "account_types/index" do diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb index 3efc39b05..027a1b7c1 100644 --- a/spec/views/account_types/new.html.haml_spec.rb +++ b/spec/views/account_types/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "account_types/new" do diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb index 828639f00..a31d4bc33 100644 --- a/spec/views/account_types/show.html.haml_spec.rb +++ b/spec/views/account_types/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "account_types/show" do diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb index 96b29ef75..bc5c3b5a3 100644 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ b/spec/views/accounts/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "accounts/edit" do diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb index 5d23d9d76..4ec76151e 100644 --- a/spec/views/accounts/index.html.haml_spec.rb +++ b/spec/views/accounts/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "accounts/index" do diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb index 6ba4da067..77f6ff20f 100644 --- a/spec/views/accounts/new.html.haml_spec.rb +++ b/spec/views/accounts/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "accounts/new" do diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb index 71be40505..d96fbbd96 100644 --- a/spec/views/accounts/show.html.haml_spec.rb +++ b/spec/views/accounts/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "accounts/show" do diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index 1c5f9bd20..beb0eacbd 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'admin/index.html.haml', type: "view" do diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb index 901e3a12a..384833034 100644 --- a/spec/views/admin/newsletter_spec.rb +++ b/spec/views/admin/newsletter_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'admin/newsletter.html.haml', type: "view" do diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb index c819f0268..8d80dc3ef 100644 --- a/spec/views/admin/orders/index_spec.rb +++ b/spec/views/admin/orders/index_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'admin/orders/index.html.haml', type: "view" do diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb index e562ca027..2ef7d480f 100644 --- a/spec/views/comments/edit.html.haml_spec.rb +++ b/spec/views/comments/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "comments/edit" do diff --git a/spec/views/comments/index.html.haml_spec.rb b/spec/views/comments/index.html.haml_spec.rb index 1bf0e734f..91ed15a88 100644 --- a/spec/views/comments/index.html.haml_spec.rb +++ b/spec/views/comments/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "comments/index" do diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb index c3b6fdd32..672658bac 100644 --- a/spec/views/comments/index.rss.haml_spec.rb +++ b/spec/views/comments/index.rss.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'comments/index.rss.haml' do diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index 074b5bfe5..e0533ea5b 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "comments/new" do diff --git a/spec/views/comments/show.html.haml_spec.rb b/spec/views/comments/show.html.haml_spec.rb index baf02cbbb..6315b4f69 100644 --- a/spec/views/comments/show.html.haml_spec.rb +++ b/spec/views/comments/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "comments/show" do diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index 183445346..c378c296c 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "crops/_grown_for" do diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 2e6bf9e93..c7a4719b5 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "crops/_planting_advice" do diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb index 35d508fd8..dde4a893f 100644 --- a/spec/views/crops/_popover.html.haml_spec.rb +++ b/spec/views/crops/_popover.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "crops/_popover" do diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb index 03f333bf2..eed85528d 100644 --- a/spec/views/crops/edit.html.haml_spec.rb +++ b/spec/views/crops/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "crops/edit" do diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb index c711b2174..833bb2b98 100644 --- a/spec/views/crops/hierarchy.html.haml_spec.rb +++ b/spec/views/crops/hierarchy.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "crops/hierarchy" do diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 421e33e00..9f2985035 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "crops/index" do diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb index 623fb296e..72a8bbdff 100644 --- a/spec/views/crops/index.rss.haml_spec.rb +++ b/spec/views/crops/index.rss.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'crops/index.rss.haml' do diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb index a1208352a..5ce7eefdc 100644 --- a/spec/views/crops/new.html.haml_spec.rb +++ b/spec/views/crops/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "crops/new" do diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index 6550026f6..085060570 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "crops/wrangle" do diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index 01e0d7230..d2cce98c4 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb index 7d0cdfe6a..fc2ad1bbe 100644 --- a/spec/views/devise/mailer/reset_password_instructions_spec.rb +++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb index 693fe97b0..633545cf3 100644 --- a/spec/views/devise/mailer/unlock_instructions_spec.rb +++ b/spec/views/devise/mailer/unlock_instructions_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do context "logged in" do diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index 7c69a8d3e..3d9dae906 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'devise/registrations/edit.html.haml', type: "view" do diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb index be00abae9..48805b806 100644 --- a/spec/views/devise/registrations/new_spec.rb +++ b/spec/views/devise/registrations/new_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'devise/registrations/new.html.haml', type: "view" do diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb index 93b14b9c3..dfe91af2a 100644 --- a/spec/views/devise/sessions/new_spec.rb +++ b/spec/views/devise/sessions/new_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'devise/sessions/new.html.haml', type: "view" do diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index c53968a8d..60d056d72 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'devise/unlocks/new.html.haml', type: "view" do diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb index d7d426a8e..44151170a 100644 --- a/spec/views/forums/edit.html.haml_spec.rb +++ b/spec/views/forums/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "forums/edit" do diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb index cf8377858..02b265e85 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "forums/index" do diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb index 8c95c7c1f..72cd7ae45 100644 --- a/spec/views/forums/new.html.haml_spec.rb +++ b/spec/views/forums/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "forums/new" do diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index 5b6bae8fa..08892df58 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "forums/show" do diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb index 1928f6d8b..1326f1544 100644 --- a/spec/views/gardens/edit.html.haml_spec.rb +++ b/spec/views/gardens/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "gardens/edit" do diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb index 97eab872e..7346997dc 100644 --- a/spec/views/gardens/new.html.haml_spec.rb +++ b/spec/views/gardens/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "gardens/new" do diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index b22ee0452..015333ae0 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "gardens/show" do diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index a475a6300..1193b4284 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "harvests/edit" do diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index db9ce915f..fe205cda6 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "harvests/index" do diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index 4b792a4c6..d79055a38 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "harvests/new" do diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index b13d53ed6..5e2f167af 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "harvests/show" do diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb index 710fcd4d4..47244a445 100644 --- a/spec/views/home/_blurb.html.haml_spec.rb +++ b/spec/views/home/_blurb.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'home/_blurb.html.haml', type: "view" do diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb index ecbb74227..cc91976b8 100644 --- a/spec/views/home/_crops.html.haml_spec.rb +++ b/spec/views/home/_crops.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'home/_crops.html.haml', type: "view" do diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index f131d5b67..76aa434b6 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'home/_members.html.haml', type: "view" do diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index 4a128f1f6..7b8d6156c 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'home/_seeds.html.haml', type: "view" do diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb index 6bfc3e6fe..a9979190c 100644 --- a/spec/views/home/_stats.html.haml_spec.rb +++ b/spec/views/home/_stats.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'home/_stats.html.haml', type: "view" do diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 190ee7b9f..5e11882fd 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'home/index.html.haml', type: "view" do diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index badecf8f7..5060fc30d 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'layouts/_header.html.haml', type: "view" do diff --git a/spec/views/layouts/_meta_spec.rb b/spec/views/layouts/_meta_spec.rb index 805f0298d..151c6fe19 100644 --- a/spec/views/layouts/_meta_spec.rb +++ b/spec/views/layouts/_meta_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'layouts/_meta.html.haml', type: "view" do diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index b773cce58..f094ae2c2 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'layouts/application.html.haml', type: "view" do diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index ee52b7319..2c8195069 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "notifications/index" do diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb index 2830966e1..a7f030f47 100644 --- a/spec/views/notifications/new.html.haml_spec.rb +++ b/spec/views/notifications/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "notifications/new" do diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb index 7cf7838c9..14db0448c 100644 --- a/spec/views/notifications/show.html.haml_spec.rb +++ b/spec/views/notifications/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "notifications/show" do diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb index 66e81b158..913ea10d2 100644 --- a/spec/views/notifier/notify.html.haml_spec.rb +++ b/spec/views/notifier/notify.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'notifier/notify.html.haml', type: "view" do diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb index 6053de32f..c95f204e2 100644 --- a/spec/views/orders/index.html.haml_spec.rb +++ b/spec/views/orders/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "orders/index" do diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb index 32289bfc9..a9f662de9 100644 --- a/spec/views/orders/show.html.haml_spec.rb +++ b/spec/views/orders/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "orders/show" do diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb index f1f2eacc5..a52b51a79 100644 --- a/spec/views/photos/edit.html.haml_spec.rb +++ b/spec/views/photos/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "photos/edit" do diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index 4e1674765..b603de1e6 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "photos/index" do diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb index 2dcb51bfc..e4f24f9e4 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "photos/new" do diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb index 5ca8c31e1..cecb0008b 100644 --- a/spec/views/photos/show.html.haml_spec.rb +++ b/spec/views/photos/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "photos/show" do diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb index efc101bc1..7082290c8 100644 --- a/spec/views/places/_map_attribution.html.haml_spec.rb +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "places/_map_attribution.html.haml", type: :view do diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb index 44299c286..f3a3661ae 100644 --- a/spec/views/places/index.html.haml_spec.rb +++ b/spec/views/places/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "places/index" do diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index c5e4cca10..635d06ab9 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "places/show" do diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb index e871b49d3..683dd6ab0 100644 --- a/spec/views/plant_parts/edit.html.haml_spec.rb +++ b/spec/views/plant_parts/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plant_parts/edit" do diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb index 73dec883e..65ecf2d63 100644 --- a/spec/views/plant_parts/index.html.haml_spec.rb +++ b/spec/views/plant_parts/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plant_parts/index" do diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb index 31218ee71..b1b3f12ae 100644 --- a/spec/views/plant_parts/new.html.haml_spec.rb +++ b/spec/views/plant_parts/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plant_parts/new" do diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb index bffd0f394..b367a723b 100644 --- a/spec/views/plant_parts/show.html.haml_spec.rb +++ b/spec/views/plant_parts/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plant_parts/show" do diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 926150f73..692b53173 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plantings/_form" do diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index fc7ff7f30..b83af0028 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plantings/edit" do diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index 10de32f81..f682d62e9 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plantings/index" do diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index 1d15ad5cc..c4a394561 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'plantings/index.rss.haml' do diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index db1da2826..6667a05ee 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plantings/new" do diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index b68ceb6c1..c20f7e909 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "plantings/show" do diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 833970b29..a153995c5 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "posts/_single" do diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 8bee4298b..48d64a267 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "posts/edit" do diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index 17aab3d47..eeebac8b6 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "posts/index" do diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index a47b80b48..3d4ec11f2 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'posts/index.rss.haml', type: "view" do diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index 0c788716e..fa344e55b 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "posts/new" do diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb index 97625fa2c..c22c4196f 100644 --- a/spec/views/posts/show.rss.haml_spec.rb +++ b/spec/views/posts/show.rss.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'posts/show.rss.haml' do diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb index e0d8ebbda..3d60c9e95 100644 --- a/spec/views/products/edit.html.haml_spec.rb +++ b/spec/views/products/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "products/edit" do diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb index cbde70cf1..90e08e2a3 100644 --- a/spec/views/products/index.html.haml_spec.rb +++ b/spec/views/products/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "products/index" do diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb index d75741775..336c6bac1 100644 --- a/spec/views/products/new.html.haml_spec.rb +++ b/spec/views/products/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "products/new" do diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb index ee529cc71..315d9caae 100644 --- a/spec/views/products/show.html.haml_spec.rb +++ b/spec/views/products/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "products/show" do diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb index 9135b8639..a86f67ceb 100644 --- a/spec/views/roles/edit.html.haml_spec.rb +++ b/spec/views/roles/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "roles/edit" do diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb index 54fe35337..e4b28e9ba 100644 --- a/spec/views/roles/index.html.haml_spec.rb +++ b/spec/views/roles/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "roles/index" do diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb index a56fce052..1cdce8c41 100644 --- a/spec/views/roles/new.html.haml_spec.rb +++ b/spec/views/roles/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "roles/new" do diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb index 03df232ec..56f1cc4fb 100644 --- a/spec/views/roles/show.html.haml_spec.rb +++ b/spec/views/roles/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "roles/show" do diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index abd9b4c62..ecaa2056f 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "scientific_names/edit" do diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb index 248ca5be9..4d63ac9e1 100644 --- a/spec/views/scientific_names/index.html.haml_spec.rb +++ b/spec/views/scientific_names/index.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "scientific_names/index" do diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb index f820007a7..0cf5a4205 100644 --- a/spec/views/scientific_names/new.html.haml_spec.rb +++ b/spec/views/scientific_names/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "scientific_names/new" do diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb index a12082fa4..b728df2b3 100644 --- a/spec/views/scientific_names/show.html.haml_spec.rb +++ b/spec/views/scientific_names/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "scientific_names/show" do diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb index 6822bf961..f450d7065 100644 --- a/spec/views/seeds/edit.html.haml_spec.rb +++ b/spec/views/seeds/edit.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "seeds/edit" do diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 7e2b3df88..4df8e526c 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'seeds/index.rss.haml' do diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb index a05da5b23..5c5cf3ae4 100644 --- a/spec/views/seeds/new.html.haml_spec.rb +++ b/spec/views/seeds/new.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "seeds/new" do diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb index 654d27b0f..975f2baa1 100644 --- a/spec/views/seeds/show.html.haml_spec.rb +++ b/spec/views/seeds/show.html.haml_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe "seeds/show" do diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb index e809782bc..3bd0061d7 100644 --- a/spec/views/shop/index_spec.rb +++ b/spec/views/shop/index_spec.rb @@ -1,15 +1,3 @@ -## DEPRECATION NOTICE: Do not add new tests to this file! -## -## View and controller tests are deprecated in the Growstuff project. -## We no longer write new view and controller tests, but instead write -## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara). -## These test the full stack, behaving as a browser, and require less complicated setup -## to run. Please feel free to delete old view/controller tests as they are reimplemented -## in feature tests. -## -## If you submit a pull request containing new view or controller tests, it will not be -## merged. - require 'rails_helper' describe 'shop/index.html.haml', type: "view" do From 949c7c31d823a3efe1a9cf0a10effd3da1f30528 Mon Sep 17 00:00:00 2001 From: deppbot Date: Sat, 18 Nov 2017 08:10:02 +0800 Subject: [PATCH 46/56] Bundle Update on 2017-11-18 --- Gemfile.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5e1f4564c..6cdced74a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -423,7 +423,7 @@ GEM thor (>= 0.18.1, < 2.0) rainbow (2.1.0) raindrops (0.19.0) - rake (12.2.1) + rake (12.3.0) rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) @@ -630,6 +630,7 @@ DEPENDENCIES will_paginate xmlrpc + RUBY VERSION ruby 2.4.1p111 From fd9fc38def0b79abf9a197fad9af789ed8162bac Mon Sep 17 00:00:00 2001 From: Logan Gingerich Date: Mon, 6 Nov 2017 07:40:15 -0700 Subject: [PATCH 47/56] fixes #1433 Says what item you're adding a photo to on photos#new --- app/controllers/photos_controller.rb | 3 ++- app/views/photos/new.html.haml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 0dd3a275d..e0de2ff65 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -19,8 +19,9 @@ class PhotosController < ApplicationController def new @type = params[:type] @id = params[:id] - @photo = Photo.new + planting = Planting.find @id + @crop_name = Crop.find(planting.crop_id).name.capitalize retrieve_from_flickr respond_with @photo end diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 4bb2013f2..6ff5df91a 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -1,5 +1,9 @@ - content_for :title, "New Photo" +%h3 + Choose photo for + = @crop_name + - if @flickr_auth %p Connected to Flickr as From 73524b8883744937944f70672dd81eeb49ab0f48 Mon Sep 17 00:00:00 2001 From: Logan Gingerich Date: Mon, 6 Nov 2017 13:10:12 -0700 Subject: [PATCH 48/56] Now displays correctly for planting, harvest or garden --- app/controllers/photos_controller.rb | 5 +++-- app/views/photos/new.html.haml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index e0de2ff65..b18811090 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -19,9 +19,10 @@ class PhotosController < ApplicationController def new @type = params[:type] @id = params[:id] + @photo = Photo.new - planting = Planting.find @id - @crop_name = Crop.find(planting.crop_id).name.capitalize + item_class = Growstuff::Constants::PhotoModels.get_item(params[:type]) + @item = item_class.find_by!(id: params[:id], owner_id: current_member.id) retrieve_from_flickr respond_with @photo end diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 6ff5df91a..31023b694 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -2,7 +2,7 @@ %h3 Choose photo for - = @crop_name + = @item - if @flickr_auth %p From 6304f230a5c46b880fb695ff77c075d9c969e666 Mon Sep 17 00:00:00 2001 From: Logan Gingerich Date: Thu, 9 Nov 2017 10:27:57 -0700 Subject: [PATCH 49/56] Refactored and specs updated --- app/controllers/photos_controller.rb | 15 +++++++++------ spec/controllers/photos_controller_spec.rb | 20 ++++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index b18811090..0e1a11410 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -21,8 +21,7 @@ class PhotosController < ApplicationController @id = params[:id] @photo = Photo.new - item_class = Growstuff::Constants::PhotoModels.get_item(params[:type]) - @item = item_class.find_by!(id: params[:id], owner_id: current_member.id) + find_item_name retrieve_from_flickr respond_with @photo end @@ -76,15 +75,19 @@ class PhotosController < ApplicationController raise "No item id provided" unless item_id? collection = Growstuff::Constants::PhotoModels.get_relation(@photo, params[:type]) - item_class = Growstuff::Constants::PhotoModels.get_item(params[:type]) - item = item_class.find_by!(id: params[:id], owner_id: current_member.id) - raise "Could not find this item owned by you" unless item + find_item_name + raise "Could not find this item owned by you" unless @item - collection << item unless collection.include?(item) + collection << @item unless collection.include?(@item) rescue => e flash[:alert] = e.message end + def find_item_name + item_class = Growstuff::Constants::PhotoModels.get_item(params[:type]) + @item = item_class.find_by!(id: params[:id], owner_id: current_member.id) + end + def retrieve_from_flickr @flickr_auth = current_member.auth('flickr') @current_set = params[:set] diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 8f4fab28e..bc9d1dbad 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -29,37 +29,41 @@ describe PhotosController do @member.stub(:flickr_photos) { [[], 0] } @member.stub(:flickr_sets) { { "foo" => "bar" } } controller.stub(:current_member) { @member } + @tomato = FactoryBot.create(:tomato) + @planting1 = FactoryBot.create(:planting, crop: @tomato, owner: @member) + @garden1 = FactoryBot.create(:garden, owner: @member) + @harvest1 = FactoryBot.create(:harvest, owner: @member) end it "assigns the flickr auth as @flickr_auth" do @auth = FactoryBot.create(:flickr_authentication, member: @member) - get :new, {} + get :new, type: "planting", id: @planting1.id assigns(:flickr_auth).should be_an_instance_of(Authentication) end it "assigns a planting id" do - get :new, type: "planting", id: 5 - assigns(:id).should eq "5" + get :new, type: "planting", id: @planting1.id + assigns(:id).should eq @planting1.id.to_s 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" + get :new, type: "harvest", id: @harvest1.id + assigns(:id).should eq @harvest1.id.to_s 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" + get :new, type: "garden", id: @garden1.id + assigns(:id).should eq @garden1.id.to_s 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' + get :new, type: "planting", id: @planting1.id, set: 'foo' assigns(:current_set).should eq "foo" expect(flash[:alert]).not_to be_present end From 3969f410f15bef569cf0603833ad7d1a62d4f5c5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 Nov 2017 15:44:45 +1300 Subject: [PATCH 50/56] Tidy up photos logic, and test of signin/out on photos#new --- app/controllers/photos_controller.rb | 45 +++++++------ spec/controllers/photos_controller_spec.rb | 76 ++++++++++------------ spec/features/signout_spec.rb | 20 ++++-- 3 files changed, 74 insertions(+), 67 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 0e1a11410..4dfc3c602 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -17,11 +17,12 @@ class PhotosController < ApplicationController end def new - @type = params[:type] @id = params[:id] + @type = params[:type] + redirect_to photos_path if @type.nil? @photo = Photo.new - find_item_name + @item = item_to_link_to retrieve_from_flickr respond_with @photo end @@ -31,9 +32,14 @@ class PhotosController < ApplicationController end def create - find_or_create_photo_from_flickr_photo - add_photo_to_collection - @photo.save if @photo.present? + @photo = find_or_create_photo_from_flickr_photo + @item = item_to_link_to + raise "Could not find this item owned by you" unless @item + collection << @item unless collection.include?(@item) + @photo.save! if @photo.present? + rescue => e + flash[:alert] = e.message + ensure respond_with @photo end @@ -50,6 +56,10 @@ class PhotosController < ApplicationController private def item_id? + item_id.present? + end + + def item_id params.key? :id end @@ -63,29 +73,22 @@ class PhotosController < ApplicationController end 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 + 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 add_photo_to_collection + def collection raise "Missing or invalid type provided" unless Growstuff::Constants::PhotoModels.types.include?(params[:type]) raise "No item id provided" unless item_id? - collection = Growstuff::Constants::PhotoModels.get_relation(@photo, params[:type]) - - find_item_name - raise "Could not find this item owned by you" unless @item - - collection << @item unless collection.include?(@item) - rescue => e - flash[:alert] = e.message + Growstuff::Constants::PhotoModels.get_relation(@photo, params[:type]) end - def find_item_name + def item_to_link_to item_class = Growstuff::Constants::PhotoModels.get_item(params[:type]) - @item = item_class.find_by!(id: params[:id], owner_id: current_member.id) + item_class.find_by!(id: params[:id], owner_id: current_member.id) end def retrieve_from_flickr diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index bc9d1dbad..8788ee09f 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -23,49 +23,41 @@ describe PhotosController do end describe "GET new" do + let(:tomato) { FactoryBot.create(:tomato) } + let(:planting) { FactoryBot.create(:planting, crop: tomato, owner: member) } + let(:garden) { FactoryBot.create(:garden, owner: member) } + let(:harvest) { FactoryBot.create(:harvest, owner: member) } + let(:member) { FactoryBot.create(:member) } + let!(:auth) { FactoryBot.create(:flickr_authentication, member: member) } + before(:each) do - @member = FactoryBot.create(:member) - sign_in @member - @member.stub(:flickr_photos) { [[], 0] } - @member.stub(:flickr_sets) { { "foo" => "bar" } } - controller.stub(:current_member) { @member } - @tomato = FactoryBot.create(:tomato) - @planting1 = FactoryBot.create(:planting, crop: @tomato, owner: @member) - @garden1 = FactoryBot.create(:garden, owner: @member) - @harvest1 = FactoryBot.create(:harvest, owner: @member) + sign_in member + member.stub(:flickr_photos) { [[], 0] } + member.stub(:flickr_sets) { { "foo" => "bar" } } + controller.stub(:current_member) { member } end - it "assigns the flickr auth as @flickr_auth" do - @auth = FactoryBot.create(:flickr_authentication, member: @member) - get :new, type: "planting", id: @planting1.id - assigns(:flickr_auth).should be_an_instance_of(Authentication) + describe "planting photos" do + before(:each) { get :new, type: "planting", id: planting.id } + it { assigns(:flickr_auth).should be_an_instance_of(Authentication) } + it { assigns(:id).should eq planting.id.to_s } + it { assigns(:type).should eq "planting" } + it { expect(flash[:alert]).not_to be_present } + it { expect(flash[:alert]).not_to be_present } end - it "assigns a planting id" do - get :new, type: "planting", id: @planting1.id - assigns(:id).should eq @planting1.id.to_s - assigns(:type).should eq "planting" - expect(flash[:alert]).not_to be_present + describe "harvest photos" do + before { get :new, type: "harvest", id: harvest.id } + it { assigns(:id).should eq harvest.id.to_s } + it { assigns(:type).should eq "harvest" } + it { expect(flash[:alert]).not_to be_present } end - it "assigns a harvest id" do - get :new, type: "harvest", id: @harvest1.id - assigns(:id).should eq @harvest1.id.to_s - assigns(:type).should eq "harvest" - expect(flash[:alert]).not_to be_present - end - - it "assigns a garden id" do - get :new, type: "garden", id: @garden1.id - assigns(:id).should eq @garden1.id.to_s - assigns(:type).should eq "garden" - expect(flash[:alert]).not_to be_present - end - - it "assigns the current set as @current_set" do - get :new, type: "planting", id: @planting1.id, set: 'foo' - assigns(:current_set).should eq "foo" - expect(flash[:alert]).not_to be_present + describe "garden photos" do + before { get :new, type: "garden", id: garden.id } + it { assigns(:id).should eq garden.id.to_s } + it { assigns(:type).should eq "garden" } + it { expect(flash[:alert]).not_to be_present } end end @@ -92,11 +84,13 @@ describe PhotosController do Photo.last.plantings.first.should eq planting end - it "doesn't attach a photo to a planting twice" do - 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 + describe "doesn't attach a photo to a planting twice" do + before do + 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 + end + it { expect(flash[:alert]).not_to be_present } + it { expect(Photo.last.plantings.size).to eq 1 } end it "attaches the photo to a harvest" do diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 433286078..575f11678 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -13,17 +13,27 @@ feature "signout" do expect(current_path).to eq crops_path end - scenario "after signout, redirect to signin page if page needs authentication" do - models = %w[plantings harvests posts photos gardens seeds] - models.each do |model| - visit "/#{model}/new" + shared_examples "sign-in redirects" do |path| + scenario "after signout, redirect to signin page if page needs authentication" do + visit path expect(current_path).to eq new_member_session_path fill_in 'Login', with: member.login_name fill_in 'Password', with: member.password click_button 'Sign in' - expect(current_path).to eq "/#{model}/new" + expect(current_path).to eq path click_link 'Sign out' expect(current_path).to eq new_member_session_path end end + + let(:path) {} + describe 'most models' do + let(:garden) { FactoryBot.create :garden, owner: member } + include_examples "sign-in redirects", "/plantings/new" + include_examples "sign-in redirects", "/harvests/new" + include_examples "sign-in redirects", "/posts/new" + include_examples "sign-in redirects", "/gardens/new" + include_examples "sign-in redirects", "/seeds/new" + include_examples "sign-in redirects", "/photos/new?type=garden&id=1" + end end From c8974a869fe4629af94fdb04c4163365e01b48b8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 Nov 2017 16:50:56 +1300 Subject: [PATCH 51/56] Use the ||= operator --- 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 4dfc3c602..3703557d2 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -74,7 +74,7 @@ class PhotosController < ApplicationController 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 ||= Photo.new(photo_params) photo.owner_id = current_member.id photo.set_flickr_metadata photo From faed8b019e96ae06fa7c7223cdfdd6560f9da84f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 Nov 2017 16:51:25 +1300 Subject: [PATCH 52/56] Removed rescue in a controller --- app/controllers/photos_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 3703557d2..5c8dedfd1 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -37,9 +37,6 @@ class PhotosController < ApplicationController raise "Could not find this item owned by you" unless @item collection << @item unless collection.include?(@item) @photo.save! if @photo.present? - rescue => e - flash[:alert] = e.message - ensure respond_with @photo end From 7906d50d131be011a25021d79746bd5710a1a333 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 Nov 2017 17:14:29 +1300 Subject: [PATCH 53/56] Shaved some yaks to remove a rescue from a controller --- app/controllers/photos_controller.rb | 57 +++++++++++++--------- spec/controllers/photos_controller_spec.rb | 29 +++++------ 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 5c8dedfd1..2c707f726 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -17,10 +17,6 @@ class PhotosController < ApplicationController end def new - @id = params[:id] - @type = params[:type] - redirect_to photos_path if @type.nil? - @photo = Photo.new @item = item_to_link_to retrieve_from_flickr @@ -32,11 +28,13 @@ class PhotosController < ApplicationController end def create - @photo = find_or_create_photo_from_flickr_photo - @item = item_to_link_to - raise "Could not find this item owned by you" unless @item - collection << @item unless collection.include?(@item) - @photo.save! if @photo.present? + ActiveRecord::Base.transaction do + @photo = find_or_create_photo_from_flickr_photo + @item = item_to_link_to + raise "Could not find this #{type} owned by you" unless @item + collection << @item unless collection.include?(@item) + @photo.save! if @photo.present? + end respond_with @photo end @@ -52,12 +50,14 @@ class PhotosController < ApplicationController private - def item_id? - item_id.present? + # + # Params + def item_id + params[:id] end - def item_id - params.key? :id + def item_type + params[:type] end def flickr_photo_id_param @@ -69,6 +69,26 @@ class PhotosController < ApplicationController :license_url, :thumbnail_url, :fullsize_url, :link_url) end + # Item with photos attached + # + def item_to_link_to + raise "No item id provided" if item_id.nil? + raise "No item type provided" if item_type.nil? + raise "Missing or invalid type provided" unless photos_supported_on_type?(item_type) + item_class = Growstuff::Constants::PhotoModels.get_item(item_type) + item_class.find_by!(id: params[:id], owner_id: current_member.id) + end + + def collection + Growstuff::Constants::PhotoModels.get_relation(@photo, item_type) + end + + def photos_supported_on_type?(_type) + Growstuff::Constants::PhotoModels.types.include?(item_type) + end + + # + # Flickr retrieval def find_or_create_photo_from_flickr_photo photo = Photo.find_by(flickr_photo_id: flickr_photo_id_param) photo ||= Photo.new(photo_params) @@ -77,17 +97,6 @@ class PhotosController < ApplicationController photo end - def collection - raise "Missing or invalid type provided" unless Growstuff::Constants::PhotoModels.types.include?(params[:type]) - raise "No item id provided" unless item_id? - Growstuff::Constants::PhotoModels.get_relation(@photo, params[:type]) - end - - def item_to_link_to - item_class = Growstuff::Constants::PhotoModels.get_item(params[:type]) - item_class.find_by!(id: params[:id], owner_id: current_member.id) - end - def retrieve_from_flickr @flickr_auth = current_member.auth('flickr') @current_set = params[:set] diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 8788ee09f..3c4f9dacb 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -40,23 +40,20 @@ describe PhotosController do describe "planting photos" do before(:each) { get :new, type: "planting", id: planting.id } it { assigns(:flickr_auth).should be_an_instance_of(Authentication) } - it { assigns(:id).should eq planting.id.to_s } - it { assigns(:type).should eq "planting" } + it { assigns(:item).should eq planting } it { expect(flash[:alert]).not_to be_present } it { expect(flash[:alert]).not_to be_present } end describe "harvest photos" do before { get :new, type: "harvest", id: harvest.id } - it { assigns(:id).should eq harvest.id.to_s } - it { assigns(:type).should eq "harvest" } + it { assigns(:item).should eq harvest } it { expect(flash[:alert]).not_to be_present } end describe "garden photos" do before { get :new, type: "garden", id: garden.id } - it { assigns(:id).should eq garden.id.to_s } - it { assigns(:type).should eq "garden" } + it { assigns(:item).should eq garden } it { expect(flash[:alert]).not_to be_present } end end @@ -108,18 +105,20 @@ describe PhotosController do it "doesn't attach photo to a comment" do comment = FactoryBot.create(:comment) - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id - expect(flash[:alert]).to be_present + expect do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id + end.to raise_error end end describe "for the second time" do + let(:planting) { FactoryBot.create :planting, owner: member } it "does not add a photo twice" do expect do - post :create, photo: { flickr_photo_id: 1 } + post :create, photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting' end.to change(Photo, :count).by(1) expect do - post :create, photo: { flickr_photo_id: 1 } + post :create, photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting' end.to change(Photo, :count).by(0) end end @@ -146,16 +145,18 @@ describe PhotosController do it "does not create the planting/photo link" do # members will be auto-created, and different another_planting = FactoryBot.create(:planting) - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id - expect(flash[:alert]).to be_present + expect do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id + end.to raise_error(ActiveRecord::RecordNotFound) 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 another_harvest = FactoryBot.create(:harvest) - post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id - expect(flash[:alert]).to be_present + expect do + post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id + end.to raise_error(ActiveRecord::RecordNotFound) Photo.last.harvests.first.should_not eq another_harvest end end From c20d9b78c5f143904d3d29642b12496f5e58ec6a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 Nov 2017 21:52:29 +1300 Subject: [PATCH 54/56] Reduced the tests of signout on photos/new --- spec/features/signout_spec.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 575f11678..107795cc1 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -17,23 +17,34 @@ feature "signout" do scenario "after signout, redirect to signin page if page needs authentication" do visit path expect(current_path).to eq new_member_session_path + expect(page).to have_http_status(200) fill_in 'Login', with: member.login_name fill_in 'Password', with: member.password click_button 'Sign in' - expect(current_path).to eq path + expect(page).to have_http_status(200) + # path has params removed after signin + expect(current_path).to eq path.split('?')[0] click_link 'Sign out' + expect(page).to have_http_status(200) expect(current_path).to eq new_member_session_path end end let(:path) {} - describe 'most models' do - let(:garden) { FactoryBot.create :garden, owner: member } + describe 'after signout, redirect to signin page if page needs authentication' do include_examples "sign-in redirects", "/plantings/new" include_examples "sign-in redirects", "/harvests/new" include_examples "sign-in redirects", "/posts/new" include_examples "sign-in redirects", "/gardens/new" include_examples "sign-in redirects", "/seeds/new" - include_examples "sign-in redirects", "/photos/new?type=garden&id=1" + end + + scenario 'photos' do + garden = FactoryBot.create :garden, owner: member + visit "/photos/new?id=#{garden.id}&type=garden" + expect(current_path).to eq new_member_session_path + expect(page).to have_http_status(200) + # photos/new needs id&type params, + # but these are stripped after signing in end end From 3e149a5d1d182caff8216375631148e5aa7087c4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 Nov 2017 22:12:03 +1300 Subject: [PATCH 55/56] Feature spec for showing item details on photo adding page --- app/views/gardens/show.html.haml | 4 +- spec/features/photos/new_photo_spec.rb | 51 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 spec/features/photos/new_photo_spec.rb diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 70f062468..ef5b41cfb 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -91,8 +91,8 @@ %p = link_to new_photo_path(type: "garden", id: @garden.id), class: 'btn btn-primary' do - %span.glyphicon.glyphicon-camera{ title: "Add Photo" } - Add Photo + %span.glyphicon.glyphicon-camera{ title: "Add photo" } + Add photo - if @garden.photos.size.positive? %h3= localize_plural(@garden.photos, Photo) .row diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb new file mode 100644 index 000000000..0f0c8af2c --- /dev/null +++ b/spec/features/photos/new_photo_spec.rb @@ -0,0 +1,51 @@ +require 'rails_helper' + +feature "new photo page" do + let(:photo) { FactoryBot.create :photo } + + context "signed in member" do + let(:member) { FactoryBot.create :member } + + background { login_as member } + + context "viewing a planting" do + let(:planting) { FactoryBot.create :planting, owner: member } + + scenario "add photo" do + visit planting_path(planting) + click_link "Add photo" + expect(page).to have_text planting.crop.name + end + end + + context "viewing a harvest" do + let(:harvest) { FactoryBot.create :harvest, owner: member } + + scenario "add photo" do + visit harvest_path(harvest) + click_link "Add photo" + expect(page).to have_text harvest.crop.name + end + end + + context "viewing a garden" do + let(:garden) { FactoryBot.create :garden, owner: member } + + scenario "add photo" do + visit garden_path(garden) + click_link "Add photo" + expect(page).to have_text garden.name + end + end + + pending "viewing a seed" do + let(:seed) { FactoryBot.create :seed, owner: member } + + scenario "add photo" do + visit seed_path(seed) + click_link "Add photo" + expect(page).to have_text seed.to_s + end + end + end +end From dafaffcd7391cf96908d4ba8dce318b7d3d9fc48 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 Nov 2017 22:14:43 +1300 Subject: [PATCH 56/56] Path remains same after sign out for our test cases --- spec/features/signout_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 107795cc1..a6402df2c 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -22,8 +22,7 @@ feature "signout" do fill_in 'Password', with: member.password click_button 'Sign in' expect(page).to have_http_status(200) - # path has params removed after signin - expect(current_path).to eq path.split('?')[0] + expect(current_path).to eq path click_link 'Sign out' expect(page).to have_http_status(200) expect(current_path).to eq new_member_session_path