From 71ab33d20cc2bb150e01d2baed80c8d009ba09e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 1 Apr 2019 07:55:43 +0000 Subject: [PATCH 01/17] Bump i18n-tasks from 0.9.28 to 0.9.29 Bumps [i18n-tasks](https://github.com/glebm/i18n-tasks) from 0.9.28 to 0.9.29. - [Release notes](https://github.com/glebm/i18n-tasks/releases) - [Changelog](https://github.com/glebm/i18n-tasks/blob/master/CHANGES.md) - [Commits](https://github.com/glebm/i18n-tasks/compare/v0.9.28...v0.9.29) Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6c138a2fe..4ca106605 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -212,7 +212,7 @@ GEM excon moneta multi_json (>= 1.9.2) - highline (2.0.0) + highline (2.0.1) html2haml (2.2.0) erubis (~> 2.7.0) haml (>= 4.0, < 6) @@ -223,7 +223,7 @@ GEM multi_xml (>= 0.5.2) i18n (1.6.0) concurrent-ruby (~> 1.0) - i18n-tasks (0.9.28) + i18n-tasks (0.9.29) activesupport (>= 4.0.2) ast (>= 2.1.0) erubi @@ -326,7 +326,7 @@ GEM parallel (1.14.0) paranoia (2.4.1) activerecord (>= 4.0, < 5.3) - parser (2.6.0.0) + parser (2.6.2.0) ast (~> 2.4.0) pg (0.21.0) platform-api (2.2.0) From 4ba5319ba89f137137ec0375df9e8adb91aa42d4 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Sat, 30 Mar 2019 20:25:15 +0000 Subject: [PATCH 02/17] Auto corrected by following Lint Ruby Capybara/FeatureMethods --- spec/features/admin/forums_spec.rb | 14 +++--- spec/features/cms_spec.rb | 8 +-- .../comments/commenting_a_comment_spec.rb | 10 ++-- spec/features/crops/alternate_name_spec.rb | 18 +++---- spec/features/crops/browse_crops_spec.rb | 10 ++-- spec/features/crops/creating_a_crop_spec.rb | 6 +-- spec/features/crops/crop_detail_page_spec.rb | 42 ++++++++-------- spec/features/crops/crop_photos_spec.rb | 6 +-- spec/features/crops/crop_search_spec.rb | 8 +-- spec/features/crops/crop_wranglers_spec.rb | 20 ++++---- .../crops/crop_wrangling_button_spec.rb | 10 ++-- spec/features/crops/delete_crop_spec.rb | 8 +-- spec/features/crops/inflections_spec.rb | 14 +++--- spec/features/crops/request_new_crop_spec.rb | 12 ++--- spec/features/crops/requested_crops_spec.rb | 6 +-- spec/features/crops/show_spec.rb | 8 +-- spec/features/following_spec.rb | 24 ++++----- spec/features/footer_spec.rb | 4 +- spec/features/gardens/actions_spec.rb | 4 +- spec/features/gardens/adding_gardens_spec.rb | 8 +-- spec/features/gardens/gardens_index_spec.rb | 4 +- spec/features/gardens_spec.rb | 24 ++++----- .../features/harvests/browse_harvests_spec.rb | 12 ++--- .../harvests/harvesting_a_crop_spec.rb | 26 +++++----- spec/features/home/home_spec.rb | 6 +-- spec/features/likeable_spec.rb | 8 +-- spec/features/locale_spec.rb | 4 +- spec/features/member_profile_spec.rb | 50 +++++++++---------- spec/features/members/deletion_spec.rb | 34 ++++++------- spec/features/members_list_spec.rb | 6 +-- spec/features/notifications_spec.rb | 6 +-- spec/features/photos/new_photo_spec.rb | 12 ++--- spec/features/photos/show_photo_spec.rb | 4 +- .../features/places/searching_a_place_spec.rb | 6 +-- spec/features/planting_reminder_spec.rb | 16 +++--- .../plantings/planting_a_crop_spec.rb | 16 +++--- spec/features/posts/posting_a_post_spec.rb | 10 ++-- spec/features/rss/comments_spec.rb | 6 +-- spec/features/rss/crops_spec.rb | 6 +-- spec/features/rss/members_spec.rb | 6 +-- spec/features/rss/plantings_spec.rb | 6 +-- spec/features/rss/posts_spec.rb | 6 +-- spec/features/rss/seeds_spec.rb | 6 +-- spec/features/scientific_name_spec.rb | 18 +++---- spec/features/seeds/adding_seeds_spec.rb | 4 +- spec/features/seeds/misc_seeds_spec.rb | 6 +-- spec/features/seeds/seed_photos.rb | 2 +- spec/features/signin_spec.rb | 18 +++---- spec/features/signout_spec.rb | 8 +-- spec/features/signup_spec.rb | 10 ++-- spec/features/unsubscribing_spec.rb | 10 ++-- spec/requests/api/v1/gardens_request_spec.rb | 4 +- .../requests/api/v1/plantings_request_spec.rb | 4 +- 53 files changed, 302 insertions(+), 302 deletions(-) diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb index 8cfce4915..75acbbbd3 100644 --- a/spec/features/admin/forums_spec.rb +++ b/spec/features/admin/forums_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -feature "forums", js: true do +describe "forums", js: true do context "as an admin user" do let(:member) { create :admin_member } let(:forum) { create :forum } - background do + before do login_as member end - scenario "navigating to forum admin without js", js: false do + it "navigating to forum admin without js", js: false do visit root_path click_link "Admin" expect(current_path).to eq admin_path @@ -20,7 +20,7 @@ feature "forums", js: true do expect(page).to have_content "New forum" end - scenario "navigating to forum admin with js" do + it "navigating to forum admin with js" do visit root_path click_link member.login_name click_link "Admin" @@ -32,7 +32,7 @@ feature "forums", js: true do expect(page).to have_content "New forum" end - scenario "adding a forum" do + it "adding a forum" do visit forums_path click_link "New forum" expect(current_path).to eq new_forum_path @@ -43,7 +43,7 @@ feature "forums", js: true do expect(page).to have_content 'Forum was successfully created' end - scenario 'editing forum' do + it 'editing forum' do visit forum_path forum click_link 'Edit' fill_in 'Name', with: 'Something else' @@ -54,7 +54,7 @@ feature "forums", js: true do expect(page).to have_content 'Something else' end - scenario 'deleting forum' do + it 'deleting forum' do visit forum_path forum click_link 'Delete' expect(current_path).to eq forums_path diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb index 405f77f18..4abe7d6d4 100644 --- a/spec/features/cms_spec.rb +++ b/spec/features/cms_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -feature "cms admin" do +describe "cms admin" do let(:member) { create :member } let(:admin_member) { create :admin_member } - scenario "can't view CMS admin if not signed in" do + it "can't view CMS admin if not signed in" do visit comfy_admin_cms_path expect(current_path).to eq root_path expect(page).to have_content "Please sign in as an admin user" end - scenario "can't view CMS admin if not an admin member" do + it "can't view CMS admin if not an admin member" do # sign in as an ordinary member login_as member visit comfy_admin_cms_path @@ -18,7 +18,7 @@ feature "cms admin" do expect(page).to have_content "Please sign in as an admin user" end - scenario "admin members can view CMS admin area" do + it "admin members can view CMS admin area" do login_as admin_member visit comfy_admin_cms_path expect(current_path).to match(/#{comfy_admin_cms_path}/) # match any CMS admin page diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb index 6c195e518..2ab3fa615 100644 --- a/spec/features/comments/commenting_a_comment_spec.rb +++ b/spec/features/comments/commenting_a_comment_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -feature 'Commenting on a post' do +describe 'Commenting on a post' do let(:member) { create :member } let(:post) { create :post, author: member } - background do + before do login_as member visit new_comment_path post_id: post.id end - scenario "creating a comment" do + it "creating a comment" do fill_in "comment_body", with: "This is a sample test for comment" click_button "Post comment" expect(page).to have_content "comment was successfully created." @@ -19,11 +19,11 @@ feature 'Commenting on a post' do context "editing a comment" do let(:existing_comment) { create :comment, post: post, author: member } - background do + before do visit edit_comment_path existing_comment end - scenario "saving edit" do + it "saving edit" do fill_in "comment_body", with: "Testing edit for comment" click_button "Post comment" expect(page).to have_content "comment was successfully updated." diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index 716a26bc2..522ee8e30 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -feature "Alternate names", js: true do +describe "Alternate names", js: true do let!(:alternate_eggplant) { create :alternate_eggplant } let(:crop) { alternate_eggplant.crop } - scenario "Display alternate names on crop page" do + it "Display alternate names on crop page" do visit crop_path(alternate_eggplant.crop) expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.name end - scenario "Index page for alternate names" do + it "Index page for alternate names" do visit alternate_names_path expect(page).to have_content alternate_eggplant.name end @@ -19,11 +19,11 @@ feature "Alternate names", js: true do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { crop_wranglers.first } - background do + before do login_as member end - scenario "Crop wranglers can edit alternate names" do + it "Crop wranglers can edit alternate names" do visit crop_path(crop) expect(page.status_code).to equal 200 expect(page).to have_content "CROP WRANGLER" @@ -39,7 +39,7 @@ feature "Alternate names", js: true do expect(page).to have_content 'Alternate name was successfully updated' end - scenario "Crop wranglers can delete alternate names" do + it "Crop wranglers can delete alternate names" do visit crop_path(alternate_eggplant.crop) expect(page).to have_link "Delete", href: alternate_name_path(alternate_eggplant) @@ -49,7 +49,7 @@ feature "Alternate names", js: true do expect(page).to have_content 'Alternate name was successfully deleted' end - scenario "Crop wranglers can add alternate names" do + it "Crop wranglers can add alternate names" do visit crop_path(crop) expect(page).to have_link "Add", href: new_alternate_name_path(crop_id: crop.id) @@ -63,7 +63,7 @@ feature "Alternate names", js: true do expect(page).to have_content 'Alternate name was successfully created' end - scenario "The show-alternate-name page works" do + it "The show-alternate-name page works" do visit alternate_name_path(alternate_eggplant) expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.crop.name @@ -73,7 +73,7 @@ feature "Alternate names", js: true do let(:rejected_crop) { create :rejected_crop } let(:pending_alt_name) { create :alternate_name, crop: rejected_crop } - scenario "Displays crop rejection message" do + it "Displays crop rejection message" do visit alternate_name_path(pending_alt_name) expect(page).to have_content "This crop was rejected for the following reason: Totally fake" end diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index c9a6335ec..9a4c23ac3 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -1,28 +1,28 @@ require 'rails_helper' -feature "browse crops" do +describe "browse crops" do let(:tomato) { create :tomato } let(:maize) { create :maize } let(:pending_crop) { create :crop_request } let(:rejected_crop) { create :rejected_crop } - scenario "has a form for sorting by" do + it "has a form for sorting by" do visit crops_path expect(page).to have_css "select#sort" end - scenario "shows a list of crops" do + it "shows a list of crops" do crop1 = tomato visit crops_path expect(page).to have_content crop1.name end - scenario "pending crops are not listed" do + it "pending crops are not listed" do visit crops_path expect(page).not_to have_content pending_crop.name end - scenario "rejected crops are not listed" do + it "rejected crops are not listed" do visit crops_path expect(page).not_to have_content rejected_crop.name end diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb index 64eff3628..14dd983d2 100644 --- a/spec/features/crops/creating_a_crop_spec.rb +++ b/spec/features/crops/creating_a_crop_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -feature "Crop - " do +describe "Crop - " do let!(:crop_wrangler) { FactoryBot.create :crop_wrangling_member } let!(:member) { FactoryBot.create :member } - background do + before do login_as member visit new_crop_path end - scenario "creating a crop with multiple scientific and alternate name", :js do + it "creating a crop with multiple scientific and alternate name", :js do within "form#new_crop" do fill_in "crop_name", with: "Philippine flower" fill_in "en_wikipedia_url", with: "https://en.wikipedia.org/wiki/Jasminum_sambac" diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 6386c7044..fb0297854 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "crop detail page", js: true do +describe "crop detail page", js: true do subject do # Update the medians after all the # data has been loaded @@ -14,7 +14,7 @@ feature "crop detail page", js: true do let(:crop) { create :crop } context "varieties" do - scenario "The crop DOES NOT have varieties" do + it "The crop DOES NOT have varieties" do visit crop_path(crop) within ".varieties" do @@ -23,7 +23,7 @@ feature "crop detail page", js: true do end end - scenario "The crop has one variety" do + it "The crop has one variety" do create :crop, name: 'Roma tomato 1', parent: crop subject @@ -42,7 +42,7 @@ feature "crop detail page", js: true do let!(:roma3) { create :crop, name: 'Roma tomato 3', parent: crop } let!(:roma4) { create :crop, name: 'Roma tomato 4', parent: crop } - scenario "The crop has 4 varieties" do + it "The crop has 4 varieties" do subject within ".varieties" do @@ -53,7 +53,7 @@ feature "crop detail page", js: true do end end - scenario "The crop has 5 varieties, including grandchild", js: true do + it "The crop has 5 varieties, including grandchild", js: true do create :crop, name: 'Roma tomato child 1', parent: roma4 subject @@ -97,54 +97,54 @@ feature "crop detail page", js: true do context "signed in member" do let(:member) { create :member } - background do + before do login_as(member) end context "action buttons" do - background { subject } + before { subject } - scenario "has a link to plant the crop" do + it "has a link to plant the crop" do expect(page).to have_link "Plant #{crop.name}", href: new_planting_path(crop_id: crop.id) end - scenario "has a link to harvest the crop" do + it "has a link to harvest the crop" do expect(page).to have_link "Harvest #{crop.name}", href: new_harvest_path(crop_id: crop.id) end - scenario "has a link to add seeds" do + it "has a link to add seeds" do expect(page).to have_link "Add #{crop.name} seeds to stash", href: new_seed_path(crop_id: crop.id) end end context "SEO" do - background { subject } + before { subject } - scenario "has seed heading with SEO" do + it "has seed heading with SEO" do expect(page).to have_content "Find #{crop.name} seeds" end - scenario "has harvest heading with SEO" do + it "has harvest heading with SEO" do expect(page).to have_content "#{crop.name.capitalize} harvests" end - scenario "has planting heading with SEO" do + it "has planting heading with SEO" do expect(page).to have_content "See who's planted #{crop.name.pluralize}" end - scenario "has planting advice with SEO" do + it "has planting advice with SEO" do expect(page).to have_content "How to grow #{crop.name}" end - scenario "has a link to Wikipedia with SEO" do + it "has a link to Wikipedia with SEO" do expect(page).to have_content "Learn more about #{crop.name}" expect(page).to have_link "Wikipedia (English)", href: crop.en_wikipedia_url end - scenario "has a link to OpenFarm" do + it "has a link to OpenFarm" do expect(page).to have_link "OpenFarm - Growing guide", href: "https://openfarm.cc/en/crops/#{CGI.escape crop.name}" end - scenario "has a link to gardenate" do + it "has a link to gardenate" do expect(page).to have_link "Gardenate - Planting reminders", href: "http://www.gardenate.com/plant/#{CGI.escape crop.name}" end @@ -155,18 +155,18 @@ feature "crop detail page", js: true do let(:member) { create :member } let(:seed) { create :seed, crop: crop, quantity: 20, owner: member } - scenario "User not signed in" do + it "User not signed in" do visit crop_path(seed.crop) expect(page).not_to have_content "You have 20 seeds" end - scenario "User signed in" do + it "User signed in" do login_as(member) visit crop_path(seed.crop) expect(page).to have_link "You have 20 seeds of this crop." end - scenario "click link to your owned seeds" do + it "click link to your owned seeds" do login_as(member) visit crop_path(seed.crop) click_link "You have 20 seeds of this crop." diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index 0d7d1fbee..a7bfed6b3 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "crop detail page", js: true do +describe "crop detail page", js: true do subject { page } let!(:member) { FactoryBot.create :member } @@ -50,12 +50,12 @@ feature "crop detail page", js: true do end context "when signed in" do - background { login_as(FactoryBot.create(:member)) } + before { login_as(FactoryBot.create(:member)) } include_examples "shows photos" end context "when signed in as photos owner" do - background { login_as(member) } + before { login_as(member) } include_examples "shows photos" end diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb index 0cea2e168..b87655a01 100644 --- a/spec/features/crops/crop_search_spec.rb +++ b/spec/features/crops/crop_search_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "crop search" do - scenario "search results show the search term in title" do +describe "crop search" do + it "search results show the search term in title" do visit root_path within "form#navbar-search" do fill_in "term", with: "tomato" @@ -10,12 +10,12 @@ feature "crop search" do expect(page).to have_css "h1", text: "Crops matching \"tomato\"" end - scenario "search page with no search term shows suitable title" do + it "search page with no search term shows suitable title" do visit search_crops_path expect(page).to have_css "h1", text: "Crop search" end - scenario "search page has a search form on it" do + it "search page has a search form on it" do visit search_crops_path expect(page).to have_css "form#crop-search" end diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index f9db489b2..c623d16b6 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "crop wranglers", js: true do +describe "crop wranglers", js: true do context "signed in wrangler" do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:wrangler) { crop_wranglers.first } @@ -8,9 +8,9 @@ feature "crop wranglers", js: true do let!(:requested_crop) { create :crop_request } let!(:rejected_crop) { create :rejected_crop } - background { login_as wrangler } + before { login_as wrangler } - scenario "sees crop wranglers listed on the crop wrangler page" do + it "sees crop wranglers listed on the crop wrangler page" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -23,7 +23,7 @@ feature "crop wranglers", js: true do end end - scenario "can see list of crops with extra detail of who created a crop" do + it "can see list of crops with extra detail of who created a crop" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -40,7 +40,7 @@ feature "crop wranglers", js: true do it { expect(page).to have_link 'Delete' } end - scenario "can create a new crop" do + it "can create a new crop" do visit root_path click_link wrangler.login_name click_link 'Crop Wrangling' @@ -53,13 +53,13 @@ feature "crop wranglers", js: true do expect(page).to have_content 'planticus maximus' end - scenario "View pending crops" do + it "View pending crops" do visit crop_path(requested_crop) expect(page).to have_content "This crop is currently pending approval." expect(page).to have_content "Please approve this even though it's fake." end - scenario "View rejected crops" do + it "View rejected crops" do visit crop_path(rejected_crop) expect(page).to have_content "This crop was rejected for the following reason: Totally fake" end @@ -69,14 +69,14 @@ feature "crop wranglers", js: true do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { create :member } - background { login_as member } + before { login_as member } - scenario "can't see wrangling page without js", js: false do + it "can't see wrangling page without js", js: false do visit root_path expect(page).not_to have_link "Crop Wrangling" end - scenario "can't see wrangling page with js" do + it "can't see wrangling page with js" do visit root_path click_link member.login_name expect(page).not_to have_link "Crop Wrangling" diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb index bf285ba66..7e9c3d8d1 100644 --- a/spec/features/crops/crop_wrangling_button_spec.rb +++ b/spec/features/crops/crop_wrangling_button_spec.rb @@ -1,27 +1,27 @@ require 'rails_helper' -feature "crop wrangling button" do +describe "crop wrangling button" do let(:crop_wrangler) { create :crop_wrangling_member } let(:member) { create :member } context "crop wrangling button" do - background do + before do login_as crop_wrangler visit crops_path end - scenario "has a link to crop wrangling page" do + it "has a link to crop wrangling page" do expect(page).to have_link "Wrangle Crops", href: wrangle_crops_path end end context "crop wrangling button" do - background do + before do login_as member visit crops_path end - scenario "has no link to crop wrangling page" do + it "has no link to crop wrangling page" do expect(page).to have_no_link "Wrangle Crops", href: wrangle_crops_path end end diff --git a/spec/features/crops/delete_crop_spec.rb b/spec/features/crops/delete_crop_spec.rb index f1302c784..8a25b629a 100644 --- a/spec/features/crops/delete_crop_spec.rb +++ b/spec/features/crops/delete_crop_spec.rb @@ -1,20 +1,20 @@ require 'rails_helper' -feature "Delete crop spec" do +describe "Delete crop spec" do context "As a crop wrangler" do let(:wrangler) { FactoryBot.create :crop_wrangling_member } let!(:pending_crop) { FactoryBot.create :crop_request } let!(:approved_crop) { FactoryBot.create :crop } - background { login_as wrangler } + before { login_as wrangler } - scenario "Delete approved crop" do + it "Delete approved crop" do visit crop_path(approved_crop) click_link 'Delete' expect(page).to have_content "crop was successfully destroyed" end - scenario "Delete pending crop" do + it "Delete pending crop" do visit crop_path(pending_crop) click_link 'Delete' expect(page).to have_content "crop was successfully destroyed" diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb index 615c4c9e9..c7ca5ce37 100644 --- a/spec/features/crops/inflections_spec.rb +++ b/spec/features/crops/inflections_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature "irregular crop inflections" do +describe "irregular crop inflections" do # We're just testing a couple of representative crops to # check that inflection works: you don't need to add # every crop here. - scenario "crops which are mass nouns" do + it "crops which are mass nouns" do expect("kale".pluralize).to eq "kale" expect("broccoli".pluralize).to eq "broccoli" expect("square foot".pluralize).to eq "square feet" @@ -26,29 +26,29 @@ feature "irregular crop inflections" do expect("star anise".pluralize).to eq "star anise" end - scenario "crops which are particularly irregular" do + it "crops which are particularly irregular" do expect("curry leaf".pluralize).to eq "curry leaves" end - scenario "crops which require -es" do + it "crops which require -es" do expect("mango".pluralize).to eq "mangoes" expect("potato".pluralize).to eq "potatoes" end - scenario "crops where the first crop would normally be pluralized" do + it "crops where the first crop would normally be pluralized" do expect("Potato Onion".pluralize).to eq "Potato Onions" expect("pear tomato".pluralize).to eq "pear tomatoes" expect("chilli pepper".pluralize).to eq "chilli peppers" end - scenario "crops where the proper name succeeds the crop that would normally be pluralized" do + it "crops where the proper name succeeds the crop that would normally be pluralized" do expect("potato Taranaki".pluralize).to eq "potato Taranaki" expect("potato Gladstone".pluralize).to eq "potato Gladstone" expect("potato matariki".pluralize).to eq "potato matariki" expect("spinach Santana".pluralize).to eq "spinach Santana" end - scenario "crops of Māori origin" do + it "crops of Māori origin" do expect("kūmara".pluralize).to eq "kūmara" expect("pūhā".pluralize).to eq "pūhā" end diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb index 1374d1176..cd5cfb984 100644 --- a/spec/features/crops/request_new_crop_spec.rb +++ b/spec/features/crops/request_new_crop_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -feature "Requesting a new crop" do +describe "Requesting a new crop" do context "As a regular member" do let(:member) { create :member } let!(:wrangler) { create :crop_wrangling_member } - background do + before do login_as member end - scenario "Submit request" do + it "Submit request" do visit new_crop_path fill_in "Name", with: "Couch potato" fill_in "request_notes", with: "Couch potatoes are real for real." @@ -24,9 +24,9 @@ feature "Requesting a new crop" do let!(:crop) { create :crop_request } let!(:already_approved) { create :crop } - background { login_as wrangler } + before { login_as wrangler } - scenario "Approve a request" do + it "Approve a request" do visit edit_crop_path(crop) select "approved", from: "Approval status" click_button "Save" @@ -36,7 +36,7 @@ feature "Requesting a new crop" do expect(page).to have_content "crop was successfully updated." end - scenario "Rejecting a crop" do + it "Rejecting a crop" do visit edit_crop_path(crop) select "rejected", from: "Approval status" select "not edible", from: "Reason for rejection" diff --git a/spec/features/crops/requested_crops_spec.rb b/spec/features/crops/requested_crops_spec.rb index 2ab750fe7..a4e406b63 100644 --- a/spec/features/crops/requested_crops_spec.rb +++ b/spec/features/crops/requested_crops_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' -feature "Crop - " do +describe "Crop - " do let(:member) { create :member } let!(:requested_crop) { create :crop, requester: member, approval_status: 'pending', name: 'puha for dinner' } - background do + before do login_as member visit requested_crops_path end - scenario "creating a crop with multiple scientific and alternate name", :js do + it "creating a crop with multiple scientific and alternate name", :js do expect(page).to have_content "puha for dinner" end end diff --git a/spec/features/crops/show_spec.rb b/spec/features/crops/show_spec.rb index cc5ff75db..bfab353a4 100644 --- a/spec/features/crops/show_spec.rb +++ b/spec/features/crops/show_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature "browse crops" do +describe "browse crops" do let(:tomato) { create :tomato } let(:maize) { create :maize } let(:pending_crop) { create :crop_request } let(:rejected_crop) { create :rejected_crop } - scenario "Show crop info" do + it "Show crop info" do visit crop_path(tomato) expect(page).to have_text 'tomato' end @@ -18,7 +18,7 @@ feature "browse crops" do FactoryBot.create :harvest, crop: tomato, harvested_at: 60.minutes.ago, created_at: 10.minutes.ago end - scenario "Shows most recently harvested harvest" do + it "Shows most recently harvested harvest" do visit crop_path(tomato) expect(page).to have_link(href: harvest_path(most_recent_harvest)) end @@ -31,7 +31,7 @@ feature "browse crops" do FactoryBot.create :planting, crop: tomato, planted_at: 60.minutes.ago, created_at: 10.minutes.ago end - scenario "Shows most recently planted planting" do + it "Shows most recently planted planting" do visit crop_path(tomato) expect(page).to have_link(href: planting_path(most_recent_planting)) end diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb index 0be64a4f0..762320671 100644 --- a/spec/features/following_spec.rb +++ b/spec/features/following_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature "follows", :js do +describe "follows", :js do context "when signed out" do let(:member) { create :member } - scenario "follow buttons on member profile page" do + it "follow buttons on member profile page" do visit member_path(member) expect(page).not_to have_link "Follow" expect(page).not_to have_link "Unfollow" @@ -15,36 +15,36 @@ feature "follows", :js do let(:member) { create :member } let(:other_member) { create :member } - background do + before do login_as(member) end - scenario "your profile doesn't have a follow button" do + it "your profile doesn't have a follow button" do visit member_path(member) expect(page).not_to have_link "Follow" expect(page).not_to have_link "Unfollow" end context "following another member" do - background { visit member_path(other_member) } + before { visit member_path(other_member) } - scenario "has a follow button" do + it "has a follow button" do expect(page).to have_link "Follow", href: follows_path(followed: other_member.slug) end - scenario "has correct message and unfollow button" do + it "has correct message and unfollow button" do click_link 'Follow' expect(page).to have_content "Followed #{other_member.login_name}" expect(page).to have_link "Unfollow", href: follow_path(member.get_follow(other_member)) end - scenario "has a followed member listed in the following page" do + it "has a followed member listed in the following page" do click_link 'Follow' visit member_follows_path(member) expect(page).to have_content other_member.login_name end - scenario "has correct message and follow button after unfollow" do + it "has correct message and follow button after unfollow" do click_link 'Follow' click_link 'Unfollow' expect(page).to have_content "Unfollowed #{other_member.login_name}" @@ -52,19 +52,19 @@ feature "follows", :js do expect(page).to have_link "Follow", href: follows_path(followed: other_member.slug) end - scenario "has member in following list" do + it "has member in following list" do click_link 'Follow' visit member_follows_path(member) expect(page).to have_content other_member.login_name end - scenario "appears in in followed member's followers list" do + it "appears in in followed member's followers list" do click_link 'Follow' visit member_followers_path(other_member) expect(page).to have_content member.login_name end - scenario "removes members from following and followers lists after unfollow" do + it "removes members from following and followers lists after unfollow" do click_link 'Follow' click_link 'Unfollow' visit member_follows_path(member) diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb index b7d109773..59d65b4db 100644 --- a/spec/features/footer_spec.rb +++ b/spec/features/footer_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature "footer", js: true do +describe "footer", js: true do before { visit root_path } - scenario "footer is on home page" do + it "footer is on home page" do expect(page).to have_css 'footer' end diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 98337063d..80faaf68b 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' require 'custom_matchers' -feature "Gardens" do +describe "Gardens" do context 'logged in' do subject { page } let(:member) { FactoryBot.create :member } - background { login_as member } + before { login_as member } let(:garden) { member.gardens.first } let(:other_member_garden) { FactoryBot.create :garden } diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb index c3f78dd18..437d2812f 100644 --- a/spec/features/gardens/adding_gardens_spec.rb +++ b/spec/features/gardens/adding_gardens_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' require 'custom_matchers' -feature "Gardens", :js do +describe "Gardens", :js do let(:member) { FactoryBot.create :member } - background do + before do login_as member visit new_garden_path end @@ -20,14 +20,14 @@ feature "Gardens", :js do expect(page).to have_optional 'input#garden_area' end - scenario "Create new garden" do + it "Create new garden" do fill_in "Name", with: "New garden" click_button "Save" expect(page).to have_content "Garden was successfully created" expect(page).to have_content "New garden" end - scenario "Refuse to create new garden with negative area" do + it "Refuse to create new garden with negative area" do visit new_garden_path fill_in "Name", with: "Negative Garden" fill_in "Area", with: -5 diff --git a/spec/features/gardens/gardens_index_spec.rb b/spec/features/gardens/gardens_index_spec.rb index b5b929df1..e14bbbc5d 100644 --- a/spec/features/gardens/gardens_index_spec.rb +++ b/spec/features/gardens/gardens_index_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' require 'custom_matchers' -feature "Gardens#index", :js do +describe "Gardens#index", :js do context "Logged in as member" do let(:member) { FactoryBot.create :member, login_name: 'shadow' } - background { login_as member } + before { login_as member } context "with 10 gardens" do before do diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 504ecda49..816995dad 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature "Planting a crop", js: true do +describe "Planting a crop", js: true do # name is aaa to ensure it is ordered first let!(:garden) { create :garden, name: 'aaa' } 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, owner: garden.owner, garden: garden, crop: tomato } - background do + before do login_as garden.owner end - scenario "View gardens" do + it "View gardens" do visit gardens_path expect(page).to have_content "Everyone's gardens" within '.layout-actions' do @@ -24,7 +24,7 @@ feature "Planting a crop", js: true do expect(page).to have_content "Everyone's gardens" end - scenario "Marking a garden as inactive" do + it "Marking a garden as inactive" do visit garden_path(garden) click_link "Mark as inactive" expect(page).to have_content "Garden was successfully updated" @@ -33,14 +33,14 @@ feature "Planting a crop", js: true do expect(page).not_to have_content "Mark as inactive" end - scenario "List only active gardens" do + it "List only active gardens" do visit garden_path(garden) click_link "Mark as inactive" visit gardens_path expect(page).not_to have_link garden_path(garden) end - scenario "Create new garden" do + it "Create new garden" do visit new_garden_path fill_in "Name", with: "New garden" click_button "Save" @@ -48,7 +48,7 @@ feature "Planting a crop", js: true do expect(page).to have_content "New garden" end - scenario "Refuse to create new garden with negative area" do + it "Refuse to create new garden with negative area" do visit new_garden_path fill_in "Name", with: "Negative Garden" fill_in "Area", with: -5 @@ -58,17 +58,17 @@ feature "Planting a crop", js: true do end context "Clicking edit from the index page" do - background do + before do visit gardens_path end - scenario "button on index to edit garden" do + it "button on index to edit garden" do click_link href: edit_garden_path(garden) expect(page).to have_content 'Edit garden' end end - scenario "Edit garden" do + it "Edit garden" do visit new_garden_path fill_in "Name", with: "New garden" click_button "Save" @@ -81,7 +81,7 @@ feature "Planting a crop", js: true do expect(page).to have_content "Different name" end - scenario "Delete garden" do + it "Delete garden" do visit new_garden_path fill_in "Name", with: "New garden" click_button "Save" @@ -98,7 +98,7 @@ feature "Planting a crop", js: true do it_behaves_like "append date" end - scenario "List only active plantings on a garden" do + it "List only active plantings on a garden" do visit gardens_path expect(page).not_to have_content finished_planting.crop_name end diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index b2409c122..a141547e4 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -1,31 +1,31 @@ require 'rails_helper' -feature "browse harvests" do +describe "browse harvests" do subject { page } let!(:member) { create :member } let!(:harvest) { create :harvest, owner: member } - background { login_as member } + before { login_as member } - feature 'blank optional fields' do + describe 'blank optional fields' do let!(:harvest) { create :harvest, :no_description } before { visit harvests_path } - scenario 'read more' do + it 'read more' do is_expected.not_to have_link "Read more" end end - feature "filled in optional fields" do + describe "filled in optional fields" do let!(:harvest) { create :harvest, :long_description } before do visit harvests_path end - scenario 'read more' do + it 'read more' do is_expected.to have_link "Read more" end diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index f30d12baa..6f69555fc 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' require 'custom_matchers' -feature "Harvesting a crop", :js, :elasticsearch do +describe "Harvesting a crop", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let!(:plant_part) { create :plant_part } let(:planting) { create :planting, crop: maize, owner: member } - background do + before do login_as member visit new_harvest_path sync_elasticsearch [maize] @@ -26,7 +26,7 @@ feature "Harvesting a crop", :js, :elasticsearch do expect(page).to have_optional 'textarea#harvest_description' end - scenario "Creating a new harvest", :js do + it "Creating a new harvest", :js do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" @@ -45,24 +45,24 @@ feature "Harvesting a crop", :js, :elasticsearch do context "Clicking edit from the index page" do let!(:harvest) { create :harvest, crop: maize, owner: member } - background do + before do visit harvests_path end - scenario "button on index to edit harvest" do + it "button on index to edit harvest" do click_link "edit_harvest_glyphicon" expect(current_path).to eq edit_harvest_path(harvest) expect(page).to have_content 'Editing harvest' end end - scenario "Clicking link to owner's profile" do + it "Clicking link to owner's profile" do visit member_harvests_path(member) click_link "View #{member}'s profile >>" expect(current_path).to eq member_path member end - scenario "Harvesting from crop page" do + it "Harvesting from crop page" do visit crop_path(maize) within '.crop-actions' do click_link "Harvest #{maize.name}" @@ -77,7 +77,7 @@ feature "Harvesting a crop", :js, :elasticsearch do expect(page).to have_content "maize" end - scenario "Harvesting from planting page" do + it "Harvesting from planting page" do planting = create :planting, crop: maize, owner: member, garden: member.gardens.first visit planting_path(planting) within ".planting-actions" do @@ -96,12 +96,12 @@ feature "Harvesting a crop", :js, :elasticsearch do let(:existing_harvest) { create :harvest, crop: maize, owner: member } let!(:other_plant_part) { create :plant_part, name: 'chocolate' } - background do + before do visit harvest_path(existing_harvest) click_link "Edit" end - scenario "Saving without edits" do + it "Saving without edits" do # Check that the autosuggest helper properly fills inputs with # existing resource's data click_button "Save" @@ -109,7 +109,7 @@ feature "Harvesting a crop", :js, :elasticsearch do expect(page).to have_content "maize" end - scenario "change plant part" do + it "change plant part" do select other_plant_part.name, from: 'harvest[plant_part_id]' click_button "Save" expect(page).to have_content "harvest was successfully updated." @@ -127,11 +127,11 @@ feature "Harvesting a crop", :js, :elasticsearch do planted_at: Time.zone.yesterday end - background do + before do visit harvest_path(existing_harvest) end - scenario "linking to a planting" do + it "linking to a planting" do expect(page).to have_content existing_planting.to_s choose("harvest_planting_id_#{existing_planting.id}") click_button "save" diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 7376de882..219dba412 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "home page" do +describe "home page" do subject { page } let(:member) { FactoryBot.create :member } @@ -16,7 +16,7 @@ feature "home page" do let!(:finished_seed) { FactoryBot.create :tradable_seed, finished: true } let!(:untradable_seed) { FactoryBot.create :untradable_seed } - background do + before do # Add photos, so they can appear on home page planting.photos << photo seed.photos << photo @@ -79,7 +79,7 @@ feature "home page" do end context "when signed in" do - background { login_as member } + before { login_as member } include_examples 'show crops' include_examples 'show plantings' include_examples 'show harvests' diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb index d1b637e0d..0a39154b0 100644 --- a/spec/features/likeable_spec.rb +++ b/spec/features/likeable_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature 'Likeable', js: true do +describe 'Likeable', js: true do let(:member) { FactoryBot.create(:member) } let(:another_member) { FactoryBot.create(:london_member) } let(:post) { FactoryBot.create(:post) } context 'logged in member' do - background do + before do login_as member visit post_path(post) end - scenario 'can be liked' do + it 'can be liked' do expect(page).to have_link 'Like' click_link 'Like' expect(page).to have_content '1 like' @@ -23,7 +23,7 @@ feature 'Likeable', js: true do expect(page).to have_content '0 likes' end - scenario 'displays correct number of likes' do + it 'displays correct number of likes' do expect(page).to have_link 'Like' click_link 'Like' expect(page).to have_content '1 like' diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index 01d164f3c..863fac079 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -feature "Changing locales", js: true do +describe "Changing locales", js: true do after { I18n.locale = :en } - scenario "Locale can be set with a query param" do + it "Locale can be set with a query param" do visit root_path expect(page).to have_content("a community of food gardeners.") visit root_path(locale: 'ja') diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index a548c7eb0..913115188 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature "member profile", js: true do +describe "member profile", js: true do context "signed out member" do let(:member) { create :member } - scenario "basic details on member profile page" do + it "basic details on member profile page" do visit member_path(member) expect(page).to have_css("h1", text: member.login_name) expect(page).to have_content member.bio @@ -12,20 +12,20 @@ feature "member profile", js: true do expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first) end - scenario "no bio" do + it "no bio" do member.bio = nil member.save visit member_path(member) expect(page).to have_content "hasn't written a bio yet" end - scenario "gravatar" do + it "gravatar" do visit member_path(member) expect(page).to have_css "img.avatar" end context "location" do - scenario "member has set location" do + it "member has set location" do london_member = create :london_member visit member_path(london_member) expect(page).to have_css("h1>small", text: london_member.location) @@ -33,7 +33,7 @@ feature "member profile", js: true do expect(page).to have_content "See other members, plantings, seeds and more near #{london_member.location}" end - scenario "member has not set location" do + it "member has not set location" do visit member_path(member) expect(page).not_to have_css("h1>small") expect(page).not_to have_css("#membermap") @@ -42,31 +42,31 @@ feature "member profile", js: true do end context "email privacy" do - scenario "public email address" do + it "public email address" do public_member = create :public_member visit member_path(public_member) expect(page).to have_content public_member.email end - scenario "private email address" do + it "private email address" do visit member_path(member) expect(page).not_to have_content member.email end end context "email privacy" do - scenario "public email address" do + it "public email address" do public_member = create :public_member visit member_path(public_member) expect(page).to have_content public_member.email end - scenario "private email address" do + it "private email address" do visit member_path(member) expect(page).not_to have_content member.email end end context "activity stats" do - scenario "with no activity" do + it "with no activity" do visit member_path(member) expect(page).to have_content "Activity" expect(page).to have_content "0 plantings" @@ -75,7 +75,7 @@ feature "member profile", js: true do expect(page).to have_content "0 posts" end - scenario "with some activity" do + it "with some activity" do create_list :planting, 2, owner: member create_list :harvest, 3, owner: member create_list :seed, 4, owner: member @@ -88,13 +88,13 @@ feature "member profile", js: true do end end - scenario "twitter link" do + it "twitter link" do twitter_auth = create :authentication, member: member visit member_path(member) expect(page).to have_link twitter_auth.name, href: "http://twitter.com/#{twitter_auth.name}" end - scenario "flickr link" do + it "flickr link" do flickr_auth = create :flickr_authentication, member: member visit member_path(member) expect(page).to have_link flickr_auth.name, href: "http://flickr.com/photos/#{flickr_auth.uid}" @@ -107,56 +107,56 @@ feature "member profile", js: true do let(:admin_member) { create :admin_member } let(:crop_wrangler) { create :crop_wrangling_member } - background do + before do login_as(member) end - scenario "admin user's page" do + it "admin user's page" do visit member_path(admin_member) expect(page).to have_text "Admin" end - scenario "crop wrangler's page" do + it "crop wrangler's page" do visit member_path(crop_wrangler) expect(page).to have_text "Crop Wrangler" end - scenario "ordinary user's page" do + it "ordinary user's page" do visit member_path(other_member) expect(page).not_to have_text "Crop Wrangler" expect(page).not_to have_text "Admin" end context "your own profile page" do - background do + before do visit member_path(member) end - scenario "has a link to create new garden" do + it "has a link to create new garden" do expect(page).to have_link "New Garden", href: new_garden_path end - scenario "has a button to edit profile" do + it "has a button to edit profile" do expect(page).to have_link "Edit profile", href: edit_member_registration_path end end context "someone else's profile page" do - background do + before do visit member_path(other_member) end - scenario "has a private message button" do + it "has a private message button" do expect(page).to have_link "Send message", href: new_notification_path(recipient_id: other_member.id) end end context "home page" do - background do + before do visit root_path end - scenario "does not have a button to edit profile" do + it "does not have a button to edit profile" do expect(page).not_to have_link "Edit profile", href: edit_member_registration_path end end diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 3c392cb4c..6cf074f1a 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "member deletion" do +describe "member deletion" do context "with activity and followers" do let(:member) { FactoryBot.create(:member) } let(:other_member) { FactoryBot.create(:member) } @@ -12,7 +12,7 @@ feature "member deletion" do let!(:secondgarden) { FactoryBot.create(:garden, owner: member) } let(:admin) { FactoryBot.create(:admin_member) } - background do + before do login_as(member) visit member_path(other_member) click_link 'Follow' @@ -30,13 +30,13 @@ feature "member deletion" do FactoryBot.create(:member, login_name: "ex_member") end - scenario "has option to delete on member profile page" do + it "has option to delete on member profile page" do visit member_path(member) click_link 'Edit profile' expect(page).to have_link "Delete Account" end - scenario "asks for password before deletion" do + it "asks for password before deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' @@ -44,7 +44,7 @@ feature "member deletion" do expect(page).to have_content "Current password can't be blank" end - scenario "password must be correct" do + it "password must be correct" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' @@ -53,7 +53,7 @@ feature "member deletion" do expect(page).to have_content "Current password is invalid" end - scenario "deletes and removes bio" do + it "deletes and removes bio" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' @@ -64,7 +64,7 @@ feature "member deletion" do end context "deletes and" do - background do + before do logout login_as(member) visit member_path(member) @@ -79,39 +79,39 @@ feature "member deletion" do it { expect(Member.with_deleted.find(member.id)).to eq member } end - scenario "removes plantings" do + it "removes plantings" do visit planting_path(planting) expect(page.status_code).to eq(404) end - scenario "removes gardens" do + it "removes gardens" do visit garden_path(secondgarden) expect(page.status_code).to eq(404) end - scenario "removes harvests and seeds" do + it "removes harvests and seeds" do visit harvest_path(harvest) expect(page.status_code).to eq(404) end - scenario "removes seeds" do + it "removes seeds" do visit seed_path(seed) expect(page.status_code).to eq(404) end - scenario "removes members from following" do + it "removes members from following" do visit member_follows_path(other_member) expect(page).not_to have_content member.login_name.to_s visit member_followers_path(other_member) expect(page).not_to have_content member.login_name.to_s end - scenario "replaces posts with deletion note" do + it "replaces posts with deletion note" do visit post_path(memberpost) expect(page.status_code).to eq(404) end - scenario "replaces comments on others' posts with deletion note, leaving post intact" do + it "replaces comments on others' posts with deletion note, leaving post intact" do FactoryBot.create :comment, post: othermemberpost, author: member, body: 'i am deleting my account' visit post_path(othermemberpost) @@ -120,7 +120,7 @@ feature "member deletion" do expect(page).to have_content "Member Deleted" end - scenario "can't be interesting" do + it "can't be interesting" do expect(Member.interesting).not_to include(member) expect(Planting.interesting).not_to include(planting) expect(Seed.interesting).not_to include(seed) @@ -128,7 +128,7 @@ feature "member deletion" do pending "doesn't show in nearby" - scenario "can no longer sign in" do + it "can no longer sign in" do visit new_member_session_path fill_in 'Login', with: member.login_name fill_in 'Password', with: member.password @@ -145,7 +145,7 @@ feature "member deletion" do FactoryBot.create(:cropbot) let!(:ex_wrangler) { FactoryBot.create(:crop_wrangling_member, login_name: "ex_wrangler") } - scenario "leaves crops behind" do + it "leaves crops behind" do login_as(otherwrangler) visit edit_crop_path(crop) expect(page).to have_content member.login_name diff --git a/spec/features/members_list_spec.rb b/spec/features/members_list_spec.rb index 184efbfb6..9523b6238 100644 --- a/spec/features/members_list_spec.rb +++ b/spec/features/members_list_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature "members list" do +describe "members list" do context "list all members" do let!(:member1) { create :member, login_name: "Archaeopteryx", confirmed_at: Time.zone.parse('2013-02-10') } let!(:member2) { create :member, login_name: "Zephyrosaurus", confirmed_at: Time.zone.parse('2014-01-11') } let!(:member3) { create :member, login_name: "Testingname", confirmed_at: Time.zone.parse('2014-05-09') } - scenario "default alphabetical sort" do + it "default alphabetical sort" do visit members_path expect(page).to have_css "#sort" expect(page).to have_selector "form" @@ -16,7 +16,7 @@ feature "members list" do expect(all_links.last).to have_text member2.login_name end - scenario "recently joined sort" do + it "recently joined sort" do visit members_path expect(page).to have_css "#sort" expect(page).to have_selector "form" diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index a5c544552..347d27627 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "Notifications", :js do +describe "Notifications", :js do let(:sender) { create :member } let(:recipient) { create :member, login_name: 'beyonce' } @@ -13,12 +13,12 @@ feature "Notifications", :js do post_id: nil end - background do + before do login_as recipient visit notification_path(notification) end - scenario "Replying to the notification" do + it "Replying to the notification" do click_link "Reply" expect(page).to have_content "Notification body" diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 3c486fa5b..71cdfc198 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' -feature "new photo page" do +describe "new photo page" do let(:photo) { FactoryBot.create :photo } context "signed in member" do let(:member) { FactoryBot.create :member } - background { login_as member } + before { login_as member } context "viewing a planting" do let(:planting) { FactoryBot.create :planting, owner: member } - scenario "add photo" do + it "add photo" do visit planting_path(planting) within '.planting-actions' do click_link('Add photo') @@ -23,7 +23,7 @@ feature "new photo page" do context "viewing a harvest" do let(:harvest) { FactoryBot.create :harvest, owner: member } - scenario "add photo" do + it "add photo" do visit harvest_path(harvest) within '.harvest-actions' do click_link "Add photo" @@ -35,7 +35,7 @@ feature "new photo page" do context "viewing a garden" do let(:garden) { FactoryBot.create :garden, owner: member } - scenario "add photo" do + it "add photo" do visit garden_path(garden) within '.garden-actions' do click_link "Add photo" @@ -47,7 +47,7 @@ feature "new photo page" do describe "viewing a seed" do let(:seed) { FactoryBot.create :seed, owner: member } - scenario "add photo" do + it "add photo" do visit seed_path(seed) first('.seed-actions').click_link('Add photo') expect(page).to have_text seed.to_s diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb index 973aa349a..a8d2ff802 100644 --- a/spec/features/photos/show_photo_spec.rb +++ b/spec/features/photos/show_photo_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -feature "show photo page" do +describe "show photo page" do context "signed in member" do let(:member) { create :member } - background { login_as member } + before { login_as member } context "linked to planting" do let(:planting) { create :planting } diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index 7a2d12898..29e49ce21 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -1,13 +1,13 @@ require "rails_helper" -feature "User searches" do +describe "User searches" do let(:member) { create :member, location: "Philippines" } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } let!(:seed1) { create :seed, owner: member } let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") } - scenario "with a valid place" do + it "with a valid place" do visit places_path search_with "Philippines" expect(page).to have_content "community near Philippines" @@ -16,7 +16,7 @@ feature "User searches" do expect(page).not_to have_content "No results found" end - scenario "with a blank search string" do + it "with a blank search string" do visit places_path search_with "" expect(page).to have_content "Please enter a valid location" diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index e13803182..1b8fe7a37 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'capybara/email/rspec' -feature "Planting reminder email", :js do +describe "Planting reminder email", :js do let(:member) { create :member } let(:mail) { Notifier.planting_reminder(member) } @@ -11,16 +11,16 @@ feature "Planting reminder email", :js do { host: 'localhost', port: 8080 } end - scenario "has a greeting" do + it "has a greeting" do expect(mail).to have_content "Hello" end context "when member has no plantings" do - scenario "tells you to track your plantings" do + it "tells you to track your plantings" do expect(mail).to have_content "planting your first crop" end - scenario "doesn't list plantings" do + it "doesn't list plantings" do expect(mail).not_to have_content "most recent plantings you've told us about" end end @@ -31,7 +31,7 @@ feature "Planting reminder email", :js do let!(:p1) { create :planting, garden: member.gardens.first, owner: member } let!(:p2) { create :planting, garden: member.gardens.first, owner: member } - scenario "lists plantings" do + it "lists plantings" do expect(mail).to have_content "most recent plantings you've told us about" expect(mail).to have_link p1.to_s, href: planting_url(p1) expect(mail).to have_link p2.to_s, href: planting_url(p2) @@ -40,11 +40,11 @@ feature "Planting reminder email", :js do end context "when member has no harvests" do - scenario "tells you to tracking plantings" do + it "tells you to tracking plantings" do expect(mail).to have_content "Get started now by tracking your first harvest" end - scenario "doesn't list plantings" do + it "doesn't list plantings" do expect(mail).not_to have_content "the last few things you harvested were" end end @@ -55,7 +55,7 @@ feature "Planting reminder email", :js do let!(:h1) { create :harvest, owner: member } let!(:h2) { create :harvest, owner: member } - scenario "lists harvests" do + it "lists harvests" do expect(mail).to have_content "the last few things you harvested were" expect(mail).to have_link h1.to_s, href: harvest_url(h1) expect(mail).to have_link h2.to_s, href: harvest_url(h2) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 8cb70fc5a..e62e9f6ba 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" require 'custom_matchers' -feature "Planting a crop", :js, :elasticsearch do +describe "Planting a crop", :js, :elasticsearch do let(:member) { FactoryBot.create :member } let!(:maize) { FactoryBot.create :maize } let(:garden) { FactoryBot.create :garden, owner: member } @@ -9,7 +9,7 @@ feature "Planting a crop", :js, :elasticsearch do FactoryBot.create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-03-10") end - background do + before do login_as member visit new_planting_path sync_elasticsearch [maize] @@ -32,7 +32,7 @@ feature "Planting a crop", :js, :elasticsearch do it { expect(page).to have_optional 'input#planting_finished_at' } end - scenario "Creating a new planting" do + it "Creating a new planting" do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do @@ -48,7 +48,7 @@ feature "Planting a crop", :js, :elasticsearch do expect(page).to have_content "Not enough data" end - scenario "Clicking link to owner's profile" do + it "Clicking link to owner's profile" do visit member_plantings_path(member) click_link "View #{member}'s profile >>" expect(current_path).to eq member_path(member) @@ -151,7 +151,7 @@ feature "Planting a crop", :js, :elasticsearch do end end - scenario "Planting from crop page" do + it "Planting from crop page" do visit crop_path(maize) within '.crop-actions' do click_link "Plant maize" @@ -165,7 +165,7 @@ feature "Planting a crop", :js, :elasticsearch do expect(page).to have_content "maize" end - scenario "Editing a planting to add details" do + it "Editing a planting to add details" do visit planting_path(planting) click_link "Edit" fill_in "Tell us more about it", with: "Some extra notes" @@ -173,7 +173,7 @@ feature "Planting a crop", :js, :elasticsearch do expect(page).to have_content "planting was successfully updated" end - scenario "Editing a planting to fill in the finished date" do + it "Editing a planting to fill in the finished date" do visit planting_path(planting) expect(page).to have_content "Not enough data" click_link "Edit" @@ -184,7 +184,7 @@ feature "Planting a crop", :js, :elasticsearch do expect(page).not_to have_content "Not enough data" end - scenario "Marking a planting as finished" do + it "Marking a planting as finished" do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb index ac31b6fec..7467517c5 100644 --- a/spec/features/posts/posting_a_post_spec.rb +++ b/spec/features/posts/posting_a_post_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -feature 'Post a post' do +describe 'Post a post' do let(:member) { create :member } - background do + before do login_as member visit new_post_path end - scenario "creating a post" do + it "creating a post" do fill_in "post_subject", with: "Testing" fill_in "post_body", with: "This is a sample test" click_button "Post" @@ -19,11 +19,11 @@ feature 'Post a post' do context "editing a post" do let(:existing_post) { create :post, author: member } - background do + before do visit edit_post_path(existing_post) end - scenario "saving edit" do + it "saving edit" do fill_in "post_subject", with: "Testing Edit" click_button "Post" expect(page).to have_content "Post was successfully updated" diff --git a/spec/features/rss/comments_spec.rb b/spec/features/rss/comments_spec.rb index f053a7e26..fef92010a 100644 --- a/spec/features/rss/comments_spec.rb +++ b/spec/features/rss/comments_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature 'Comments RSS feed' do - scenario 'The index feed exists' do +describe 'Comments RSS feed' do + it 'The index feed exists' do visit comments_path(format: 'rss') expect(page.status_code).to equal 200 end - scenario 'The index title is what we expect' do + it 'The index title is what we expect' do visit comments_path(format: 'rss') expect(page).to have_content "Recent comments on all posts (#{ENV['GROWSTUFF_SITE_NAME']})" end diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb index ef45af20b..80ca34b29 100644 --- a/spec/features/rss/crops_spec.rb +++ b/spec/features/rss/crops_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature 'Crops RSS feed' do - scenario 'The index feed exists' do +describe 'Crops RSS feed' do + it 'The index feed exists' do visit crops_path(format: 'rss') expect(page.status_code).to equal 200 end - scenario 'The index title is what we expect' do + it 'The index title is what we expect' do visit crops_path(format: 'rss') expect(page).to have_content "Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})" end diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb index 3849f9d80..8bf13b3c5 100644 --- a/spec/features/rss/members_spec.rb +++ b/spec/features/rss/members_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -feature 'Members RSS feed' do +describe 'Members RSS feed' do let(:member) { create :member } - scenario 'The show action exists' do + it 'The show action exists' do visit member_path(member, format: 'rss') expect(page.status_code).to equal 200 end - scenario 'The show action title is what we expect' do + it 'The show action title is what we expect' do visit member_path(member, format: 'rss') expect(page).to have_content "#{member.login_name}'s recent posts (#{ENV['GROWSTUFF_SITE_NAME']})" end diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index c3f68fea6..7624c22c0 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature 'Plantings RSS feed' do - scenario 'The index feed exists' do +describe 'Plantings RSS feed' do + it 'The index feed exists' do visit plantings_path(format: 'rss') expect(page.status_code).to equal 200 end - scenario 'The index title is what we expect' do + it 'The index title is what we expect' do visit plantings_path(format: 'rss') expect(page).to have_content "Recent plantings from "\ "#{@owner || 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index 668276fbb..93797c7bc 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature 'Posts RSS feed' do - scenario 'The index feed exists' do +describe 'Posts RSS feed' do + it 'The index feed exists' do visit posts_path(format: 'rss') expect(page.status_code).to equal 200 end - scenario 'The index title is what we expect' do + it 'The index title is what we expect' do visit posts_path(format: 'rss') expect(page).to have_content "Recent posts from "\ "#{@author || 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index abb66e7e3..5ae25949e 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature 'Seeds RSS feed' do - scenario 'The index feed exists' do +describe 'Seeds RSS feed' do + it 'The index feed exists' do visit seeds_path(format: 'rss') expect(page.status_code).to equal 200 end - scenario 'The index title is what we expect' do + it 'The index title is what we expect' do visit seeds_path(format: 'rss') expect(page).to have_content "Recent seeds from "\ "#{@owner || 'all members'} (#{ENV['GROWSTUFF_SITE_NAME']})" diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index 3844a3a07..00563deb6 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -feature "Scientific names", js: true do +describe "Scientific names", js: true do let!(:zea_mays) { create :zea_mays } let(:crop) { zea_mays.crop } - scenario "Display scientific names on crop page" do + it "Display scientific names on crop page" do visit crop_path(zea_mays.crop) expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end - scenario "Index page for scientific names" do + it "Index page for scientific names" do visit scientific_names_path expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name @@ -20,11 +20,11 @@ feature "Scientific names", js: true do let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 } let(:member) { crop_wranglers.first } - background do + before do login_as(member) end - scenario "Crop wranglers can edit scientific names" do + it "Crop wranglers can edit scientific names" do visit crop_path(crop) expect(page.status_code).to equal 200 expect(page).to have_content "CROP WRANGLER" @@ -39,7 +39,7 @@ feature "Scientific names", js: true do expect(page).to have_content 'crop was successfully updated' end - scenario "Crop wranglers can delete scientific names" do + it "Crop wranglers can delete scientific names" do visit crop_path(zea_mays.crop) expect(page).to have_link "Delete", href: scientific_name_path(zea_mays) @@ -49,7 +49,7 @@ feature "Scientific names", js: true do expect(page).to have_content 'Scientific name was successfully deleted.' end - scenario "Crop wranglers can add scientific names" do + it "Crop wranglers can add scientific names" do visit crop_path(crop) expect(page).to have_link "Add", href: new_scientific_name_path(crop_id: crop.id) @@ -63,7 +63,7 @@ feature "Scientific names", js: true do expect(page).to have_content 'crop was successfully created.' end - scenario "The show-scientific-name page works" do + it "The show-scientific-name page works" do visit scientific_name_path(zea_mays) expect(page.status_code).to equal 200 expect(page).to have_link zea_mays.crop.name, @@ -74,7 +74,7 @@ feature "Scientific names", js: true do let(:pending_crop) { create :crop_request } let(:pending_sci_name) { create :scientific_name, crop: pending_crop } - scenario "Displays crop pending message" do + it "Displays crop pending message" do visit scientific_name_path(pending_sci_name) expect(page).to have_content "This crop is currently pending approval" end diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 2964a5ab3..0f21633c3 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' require 'custom_matchers' -feature "Seeds", :js, :elasticsearch do +describe "Seeds", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } - background do + before do login_as member visit new_seed_path sync_elasticsearch [maize] diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index e7c1e0291..0d75dc3c4 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -feature "seeds", js: true do +describe "seeds", js: true do let(:member) { create :member } context "signed in user" do let(:crop) { create :crop } - background { login_as member } + before { login_as member } describe "button on index to edit seed" do let!(:seed) { create :seed, owner: member } @@ -41,7 +41,7 @@ feature "seeds", js: true do # actually adding seeds is in spec/features/seeds_new_spec.rb - scenario "edit seeds" do + it "edit seeds" do seed = create :seed, owner: member visit seed_path(seed) click_link 'Edit' diff --git a/spec/features/seeds/seed_photos.rb b/spec/features/seeds/seed_photos.rb index 60746d98b..add3d0fa5 100644 --- a/spec/features/seeds/seed_photos.rb +++ b/spec/features/seeds/seed_photos.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'custom_matchers' -feature "Seeds", :js do +describe "Seeds", :js do subject do login_as member visit seed_path(seed) diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb index 07fd6a130..4be647588 100644 --- a/spec/features/signin_spec.rb +++ b/spec/features/signin_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature "signin", js: true do +describe "signin", js: true do let(:member) { FactoryBot.create :member } let(:recipient) { FactoryBot.create :member } let(:wrangler) { FactoryBot.create :crop_wrangling_member } @@ -12,34 +12,34 @@ feature "signin", js: true do click_button 'Sign in' end - scenario "via email address" do + it "via email address" do visit crops_path # some random page click_link 'Sign in' login expect(page).to have_content("Sign out") end - scenario "redirect to previous page after signin" do + it "redirect to previous page after signin" do visit crops_path # some random page click_link 'Sign in' login expect(current_path).to eq crops_path end - scenario "don't redirect to devise pages after signin" do + it "don't redirect to devise pages after signin" do visit new_member_registration_path # devise signup page click_link 'Sign in' login expect(current_path).to eq root_path end - scenario "redirect to signin page for if not authenticated to view notification" do + it "redirect to signin page for if not authenticated to view notification" do visit notification_path(notification) expect(current_path).to eq new_member_session_path end shared_examples "redirects to what you were trying to do" do - scenario do + it do visit "/#{model_name}/new" expect(current_path).to eq new_member_session_path login @@ -55,14 +55,14 @@ feature "signin", js: true do end end - scenario "after signin, redirect to new notifications page" do + it "after signin, redirect to new notifications page" do visit new_notification_path(recipient_id: recipient.id) expect(current_path).to eq new_member_session_path login expect(current_path).to eq new_notification_path end - scenario "after crop wrangler signs in and crops await wrangling, show alert" do + it "after crop wrangler signs in and crops await wrangling, show alert" do create :crop_request visit crops_path # some random page click_link 'Sign in' @@ -73,7 +73,7 @@ feature "signin", js: true do end context "with facebook" do - scenario "sign in" do + it "sign in" do # Ordinarily done by database_cleaner Member.where(login_name: 'tdawg').delete_all diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 2ccfd17dc..69f285ea7 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -feature "signout" do +describe "signout" do let(:member) { create :member } let(:path) {} - scenario "redirect to previous page after signout" do + it "redirect to previous page after signout" do visit crops_path # some random page click_link 'Sign in' fill_in 'Login', with: member.login_name @@ -16,7 +16,7 @@ feature "signout" do end shared_examples "sign-in redirects" do |path| - scenario "after signout, redirect to signin page if page needs authentication" do + it "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) @@ -39,7 +39,7 @@ feature "signout" do include_examples "sign-in redirects", "/seeds/new" end - scenario 'photos' do + it '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 diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index 6afb28119..331dedaa7 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -feature "signup", js: true do - scenario "sign up for new account from top menubar" do +describe "signup", js: true do + it "sign up for new account from top menubar" do visit crops_path # something other than front page, which has multiple signup links click_link 'Sign up' fill_in 'Login name', with: 'person123' @@ -13,7 +13,7 @@ feature "signup", js: true do expect(current_path).to eq root_path end - scenario "sign up for new account with existing username" do + it "sign up for new account with existing username" do visit crops_path # something other than front page, which has multiple signup links click_link 'Sign up' fill_in 'Login name', with: 'person123' @@ -32,7 +32,7 @@ feature "signup", js: true do click_button 'Sign up' end - scenario "sign up for new account without accepting TOS" do + it "sign up for new account without accepting TOS" do visit root_path first('.signup a').click # click the 'Sign up' button in the middle of the page fill_in 'Login name', with: 'person123' @@ -45,7 +45,7 @@ feature "signup", js: true do end context "with facebook" do - scenario "sign up" do + it "sign up" do # Ordinarily done by database_cleaner Member.where(login_name: 'tdawg').delete_all Member.where(email: 'tdawg@hotmail.com').delete_all diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index 3f7843034..18af5296b 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' require 'capybara/email/rspec' -feature "unsubscribe" do +describe "unsubscribe" do let(:member) { create :member } let(:notification) { create :notification } - background do + before do clear_emails end - scenario "from planting reminder mailing list" do + it "from planting reminder mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -26,7 +26,7 @@ feature "unsubscribe" do expect(updated_member.send_notification_email).to eq(true) end - scenario "from inbox notification mailing list" do + it "from inbox notification mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -44,7 +44,7 @@ feature "unsubscribe" do expect(updated_member.send_notification_email).to eq(false) end - scenario "visit unsubscribe page with a non-encrypted parameter" do + it "visit unsubscribe page with a non-encrypted parameter" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb index 127513607..89bb2e8ee 100644 --- a/spec/requests/api/v1/gardens_request_spec.rb +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -38,12 +38,12 @@ RSpec.describe 'Gardens', type: :request do "related" => "#{resource_url}/photos" } } end - scenario '#index' do + it '#index' do get '/api/v1/gardens', params: {}, headers: headers expect(subject['data']).to include(garden_encoded_as_json_api) end - scenario '#show' do + it '#show' do get "/api/v1/gardens/#{garden.id}", params: {}, headers: headers expect(subject['data']).to include(garden_encoded_as_json_api) end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb index 9137f8b39..cfd60fcf7 100644 --- a/spec/requests/api/v1/plantings_request_spec.rb +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -71,12 +71,12 @@ RSpec.describe 'Plantings', type: :request do } end - scenario '#index' do + it '#index' do get '/api/v1/plantings', params: {}, headers: headers expect(subject['data']).to include(planting_encoded_as_json_api) end - scenario '#show' do + it '#show' do get "/api/v1/plantings/#{planting.id}", params: {}, headers: headers expect(subject['data']['relationships']).to include("garden" => garden_as_json_api) expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) From 495002d8b9b44d8ce6f7145f114bbb092eab3591 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 1 Apr 2019 22:33:33 +1300 Subject: [PATCH 03/17] Change "background" to "before" --- spec/features/shared_examples/append_date.rb | 2 +- spec/features/shared_examples/crop_suggest.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb index 843730ff7..85b576a75 100644 --- a/spec/features/shared_examples/append_date.rb +++ b/spec/features/shared_examples/append_date.rb @@ -2,7 +2,7 @@ shared_examples "append date" do let(:this_month) { Time.zone.today.strftime("%B") } let(:this_year) { Time.zone.today.strftime("%Y") } - background { visit path } + before { visit path } scenario "Selecting a date with datepicker" do click_link link_text diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index b646ba7df..dc1474d73 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -6,7 +6,7 @@ shared_examples "crop suggest" do |resource| let!(:tomato) { create :tomato } let!(:roma) { create :roma } - background { sync_elasticsearch [pea, pear, maize, tomato] } + before { sync_elasticsearch [pea, pear, maize, tomato] } scenario "placeholder text in crop auto suggest field" do expect(page).to have_selector("input[placeholder='e.g. lettuce']") From 6ef3b027643f3b684eb491360e19fe719eb210ce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 1 Apr 2019 22:33:41 +1300 Subject: [PATCH 04/17] Remove commented out code --- spec/features/gardens/actions_spec.rb | 32 --------------------------- 1 file changed, 32 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 80faaf68b..1f7fe2a26 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -72,36 +72,4 @@ describe "Gardens" do end end end - - # background do - # login_as member - # visit new_garden_path - # end - - # it "has the required fields help text" do - # expect(page).to have_content "* denotes a required field" - # end - - # it "displays required and optional fields properly" do - # expect(page).to have_selector ".form-group.required", text: "Name" - # expect(page).to have_optional 'textarea#garden_description' - # expect(page).to have_optional 'input#garden_location' - # expect(page).to have_optional 'input#garden_area' - # end - - # scenario "Create new garden" do - # fill_in "Name", with: "New garden" - # click_button "Save" - # expect(page).to have_content "Garden was successfully created" - # expect(page).to have_content "New garden" - # end - - # scenario "Refuse to create new garden with negative area" do - # visit new_garden_path - # fill_in "Name", with: "Negative Garden" - # fill_in "Area", with: -5 - # click_button "Save" - # expect(page).not_to have_content "Garden was successfully created" - # expect(page).to have_content "Area must be greater than or equal to 0" - # end end From a2fd0f0ae21165b1d0d6ad4a9063eca671642c02 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Mon, 1 Apr 2019 10:15:18 +0000 Subject: [PATCH 05/17] Auto corrected by following Lint Ruby RSpecEmptyLine --- spec/features/crops/crop_photos_spec.rb | 2 ++ spec/features/home/home_spec.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index a7bfed6b3..1507a5a15 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -51,11 +51,13 @@ describe "crop detail page", js: true do context "when signed in" do before { login_as(FactoryBot.create(:member)) } + include_examples "shows photos" end context "when signed in as photos owner" do before { login_as(member) } + include_examples "shows photos" end diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 219dba412..8a10c83fa 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -80,6 +80,7 @@ describe "home page" do context "when signed in" do before { login_as member } + include_examples 'show crops' include_examples 'show plantings' include_examples 'show harvests' From b43b8f586878f64ca7c0b9a264995e8d4e7e127a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 2 Apr 2019 07:19:42 +0000 Subject: [PATCH 06/17] Bump js-routes from 1.4.4 to 1.4.5 Bumps [js-routes](https://github.com/railsware/js-routes) from 1.4.4 to 1.4.5. - [Release notes](https://github.com/railsware/js-routes/releases) - [Changelog](https://github.com/railsware/js-routes/blob/master/CHANGELOG.md) - [Commits](https://github.com/railsware/js-routes/compare/v1.4.4...v1.4.5) Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4ca106605..d44521854 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -240,8 +240,8 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - js-routes (1.4.4) - railties (>= 3.2) + js-routes (1.4.5) + railties (>= 4) sprockets-rails json (2.1.0) jsonapi-resources (0.9.6) From 7c6a76b41cef80eb7b8af2ee61e7b22db8f92449 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 4 Apr 2019 07:17:14 +0000 Subject: [PATCH 07/17] Bump cancancan from 2.3.0 to 3.0.0 Bumps [cancancan](https://github.com/CanCanCommunity/cancancan) from 2.3.0 to 3.0.0. - [Release notes](https://github.com/CanCanCommunity/cancancan/releases) - [Changelog](https://github.com/CanCanCommunity/cancancan/blob/develop/CHANGELOG.md) - [Commits](https://github.com/CanCanCommunity/cancancan/compare/2.3.0...3.0.0) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index d44521854..0b875f687 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,7 +79,7 @@ GEM activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.0.1) - cancancan (2.3.0) + cancancan (3.0.0) capybara (3.16.0) addressable mini_mime (>= 0.1.3) From d8b70a927a0ab19c30b33e919f95edd9303cf9f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 5 Apr 2019 07:19:56 +0000 Subject: [PATCH 08/17] Bump js-routes from 1.4.5 to 1.4.6 Bumps [js-routes](https://github.com/railsware/js-routes) from 1.4.5 to 1.4.6. - [Release notes](https://github.com/railsware/js-routes/releases) - [Changelog](https://github.com/railsware/js-routes/blob/master/CHANGELOG.md) - [Commits](https://github.com/railsware/js-routes/compare/v1.4.5...v1.4.6) Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0b875f687..3ec98125b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -240,7 +240,7 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - js-routes (1.4.5) + js-routes (1.4.6) railties (>= 4) sprockets-rails json (2.1.0) @@ -339,7 +339,7 @@ GEM psych (3.1.0) public_suffix (3.0.3) puma (3.12.1) - rack (2.0.6) + rack (2.0.7) rack-protection (2.0.5) rack rack-test (1.1.0) From 7ca263aa643032d43c3bc738498bb4d8fc36d84b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 5 Apr 2019 09:42:52 +0000 Subject: [PATCH 09/17] Bump capybara from 3.16.0 to 3.16.1 Bumps [capybara](https://github.com/teamcapybara/capybara) from 3.16.0 to 3.16.1. - [Release notes](https://github.com/teamcapybara/capybara/releases) - [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md) - [Commits](https://github.com/teamcapybara/capybara/compare/3.16.0...3.16.1) Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3ec98125b..886c084ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,7 +80,7 @@ GEM uniform_notifier (~> 1.11) byebug (11.0.1) cancancan (3.0.0) - capybara (3.16.0) + capybara (3.16.1) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -390,7 +390,7 @@ GEM rb-inotify (0.10.0) ffi (~> 1.0) redis (4.1.0) - regexp_parser (1.3.0) + regexp_parser (1.4.0) responders (2.4.1) actionpack (>= 4.2.0, < 6.0) railties (>= 4.2.0, < 6.0) From a48acc0253e5ece2cbb754e56456bd3a2861ec9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 5 Apr 2019 20:19:38 +0000 Subject: [PATCH 10/17] Bump rubocop from 0.66.0 to 0.67.2 Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.66.0 to 0.67.2. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.66.0...v0.67.2) Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 886c084ed..7730545f3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -323,10 +323,10 @@ GEM omniauth-oauth (~> 1.1) rack orm_adapter (0.5.0) - parallel (1.14.0) + parallel (1.17.0) paranoia (2.4.1) activerecord (>= 4.0, < 5.3) - parser (2.6.2.0) + parser (2.6.2.1) ast (~> 2.4.0) pg (0.21.0) platform-api (2.2.0) @@ -415,7 +415,7 @@ GEM rspec-mocks (~> 3.8.0) rspec-support (~> 3.8.0) rspec-support (3.8.0) - rubocop (0.66.0) + rubocop (0.67.2) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) From ad90dd6dfaf402002da2a95135dc02d967d68a2e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Apr 2019 14:21:04 +1200 Subject: [PATCH 11/17] Fixes wrong host name in emails --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 95f82b4c8..ad361ca47 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -80,7 +80,7 @@ Rails.application.configure do config.active_record.dump_schema_after_migration = false # Growstuff configuration - config.action_mailer.default_url_options = { host: ENV['MAIL_SENDER_HOST'] } + config.action_mailer.default_url_options = { host: ENV['HOST'] } config.action_mailer.smtp_settings = { user_name: ENV['SENDGRID_USERNAME'], From a998a8b0f6d1603ba843a0c088c86908bfada47f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Apr 2019 14:50:29 +1200 Subject: [PATCH 12/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a0433b22b..ef1935e0e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ encourage participation from people of all backgrounds and skill levels. ## Important links -* [Issues](http://github.com/Growstuff/growstuff/issues) (features we're +* [Issues](https://github.com/orgs/Growstuff/projects/1) (features we're working on, known bugs, etc) * [IRC](https://webchat.freenode.net/) growstuff channel (general chat, brainstorming and troubleshooting) or [Gitter](https://gitter.im/Growstuff/growstuff) * [Wiki](https://github.com/Growstuff/growstuff/wiki) (general documentation, etc. Help by migrating from the [old wiki](https://web.archive.org/web/*/wiki.growstuff.org)) From 7ac410c4999b17d0893bfe94278c8192010a10b5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 10 Apr 2019 20:02:05 +1200 Subject: [PATCH 13/17] varieties info on crops#show (#1848) * Tests for crop.photos * More info on a crop's varieties, and parent * Update spec for new crop varieties display * Add varieties div wrapper, so test can find the area of the page --- app/views/crops/_thumbnail.html.haml | 8 +- app/views/crops/_varieties.html.haml | 25 +---- app/views/crops/show.html.haml | 12 ++- spec/features/crops/crop_detail_page_spec.rb | 73 +-------------- spec/models/crop_spec.rb | 97 ++++++++++---------- spec/models/photo_spec.rb | 12 +-- 6 files changed, 76 insertions(+), 151 deletions(-) diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index 77793ef22..c9dfe207e 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -11,6 +11,8 @@ - unless crop.scientific_names.empty? .scientificname = crop.scientific_names.first.name - .plantingcount - Planted - = pluralize(crop.plantings.size, "time") + - if crop.annual? && crop.median_lifespan.present? + .planting-lifespan + lifespan + %strong= crop.median_lifespan + days diff --git a/app/views/crops/_varieties.html.haml b/app/views/crops/_varieties.html.haml index 5cdc453ed..2b3407388 100644 --- a/app/views/crops/_varieties.html.haml +++ b/app/views/crops/_varieties.html.haml @@ -1,20 +1,5 @@ -.varieties - - if crop.parent - %p - = crop.name - is a variety of - = succeed "." do - = link_to crop.parent, crop.parent - - - unless crop.varieties.empty? - %p - Varieties of #{crop.name}: - - - max = 5 - = render partial: 'hierarchy', locals: { display_crops: [crop], max: max } - - if max != 0 && @count > max - = button_tag "Show all #{@count - 1} varieties", class: 'btn btn-link toggle crop-hierarchy' - = button_tag "Show less varieties", class: 'btn btn-link toggle crop-hierarchy hide' - - - if !crop.parent && crop.varieties.empty? - %p None known. +- if crop.varieties.size.positive? + %h3 Varieties + .row + - crop.varieties.order(:name).each do |v| + .col-md-2.six-across= render 'crops/thumbnail', crop: v \ No newline at end of file diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 2b58de0bf..42ba16869 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -36,7 +36,7 @@ %h2 Photos %p= render 'crops/photos', photos: @photos %p= link_to 'more photos', crop_photos_path(@crop) - + .row .col-md-3 %h3 Sunniness @@ -48,6 +48,7 @@ %h3 Harvested for = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" + .varieties= render 'varieties', crop: @crop %h3 Crop Map %p @@ -90,8 +91,13 @@ = render 'scientific_names', crop: @crop = render 'alternate_names', crop: @crop - %h4 #{@crop.name.capitalize} varieties - = render 'varieties', crop: @crop + - if @crop.parent + .parent-crop + = @crop.name + is a variety of + = succeed "." do + = link_to @crop.parent, @crop.parent + = render 'crops/thumbnail', crop: @crop.parent = render 'plantings', crop: @crop = render 'harvests', crop: @crop diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index fb0297854..bbf53b0a0 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -18,78 +18,7 @@ describe "crop detail page", js: true do visit crop_path(crop) within ".varieties" do - expect(page).to have_no_selector('li', text: /tomato/i) - expect(page).to have_no_selector('button', text: /Show+/i) - end - end - - it "The crop has one variety" do - create :crop, name: 'Roma tomato 1', parent: crop - - subject - - within ".varieties" do - # It lists all 2 items (note: including the top level item.) - expect(page).to have_selector('li', text: /tomato/i, count: 2) - # It DOES NOT have "Show all/less" toggle link - expect(page).to have_no_selector('button', text: /Show+/i) - end - end - - context "many" do - let!(:roma1) { create :crop, name: 'Roma tomato 1', parent: crop } - let!(:roma2) { create :crop, name: 'Roma tomato 2', parent: crop } - let!(:roma3) { create :crop, name: 'Roma tomato 3', parent: crop } - let!(:roma4) { create :crop, name: 'Roma tomato 4', parent: crop } - - it "The crop has 4 varieties" do - subject - - within ".varieties" do - # It lists all 5 items (note: including the top level item.) - expect(page).to have_selector('li', text: /tomato/i, count: 5) - # It DOES NOT have "Show all/less" toggle link - expect(page).to have_no_selector('button', text: /Show+/i) - end - end - - it "The crop has 5 varieties, including grandchild", js: true do - create :crop, name: 'Roma tomato child 1', parent: roma4 - - subject - - within ".varieties" do - # It lists the first 5 items (note: including the top level item.) - # It HAS have "Show all" toggle link but not "Show less" link - expect(page).to have_selector('li', text: /tomato/i, count: 5) - expect(page).to have_selector('li', text: 'Roma tomato 4') - expect(page).to have_no_selector('li', text: 'Roma tomato child 1') - # It shows the total number (5) correctly - expect(page).to have_selector('button', text: /Show all 5 +/i) - expect(page).to have_no_selector('button', text: /Show less+/i) - - # Clik "Show all" link - page.find('button', text: /Show all+/).click - - # It lists all 6 items (note: including the top level item.) - # It HAS have "Show less" toggle link but not "Show all" link - expect(page).to have_selector('li', text: /tomato/i, count: 6) - expect(page).to have_selector('li', text: 'Roma tomato 4') - expect(page).to have_selector('li', text: 'Roma tomato child 1') - expect(page).to have_no_selector('button', text: /Show all+/i) - expect(page).to have_selector('button', text: /Show less+/i) - - # Clik "Show less" link - page.find('button', text: /Show less+/).click - - # It lists 5 items (note: including the top level item.) - # It HAS have "Show all" toggle link but not "Show less" link - expect(page).to have_selector('li', text: /tomato/i, count: 5) - expect(page).to have_selector('li', text: 'Roma tomato 4') - expect(page).to have_no_selector('li', text: 'Roma tomato child 1') - expect(page).to have_selector('button', text: /Show all 5 +/i) - expect(page).to have_no_selector('button', text: /Show less+/i) - end + expect(page).not_to have_text 'tomato' end end end diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 4cd9c3fc1..fa5f746ce 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -1,25 +1,21 @@ require 'rails_helper' describe Crop do - let(:pp2) { FactoryBot.create(:plant_part) } - let(:pp1) { FactoryBot.create(:plant_part) } - let(:maize) { FactoryBot.create(:maize) } - context 'all fields present' do let(:crop) { FactoryBot.create(:tomato) } - it 'saves a basic crop' do + it 'should save a basic crop' do crop.save.should be(true) end - it 'is fetchable from the database' do + it 'should be fetchable from the database' do crop.save @crop2 = Crop.find_by(name: 'tomato') @crop2.en_wikipedia_url.should eq("http://en.wikipedia.org/wiki/Tomato") @crop2.slug.should eq("tomato") end - it 'stringifies as the system name' do + it 'should stringify as the system name' do crop.save crop.to_s.should eq('tomato') end @@ -31,7 +27,7 @@ describe Crop do end context 'invalid data' do - it 'does not save a crop without a system name' do + it 'should not save a crop without a system name' do crop = FactoryBot.build(:crop, name: nil) expect { crop.save }.to raise_error ActiveRecord::StatementInvalid end @@ -143,57 +139,61 @@ describe Crop do end context 'photos' do - before do - @crop = FactoryBot.create(:tomato) + shared_examples 'has default photo' do + it { expect(Crop.has_photos).to include(crop) } end + let!(:crop) { FactoryBot.create :tomato } + let(:member) { FactoryBot.create :member } context 'with a planting photo' do - before do - @planting = FactoryBot.create(:planting, crop: @crop) - @photo = FactoryBot.create(:photo, owner: @planting.owner) - @planting.photos << @photo - end + let!(:photo) { FactoryBot.create(:photo, owner: planting.owner) } + let!(:planting) { FactoryBot.create(:planting, crop: crop) } - it 'has a default photo' do - @crop.default_photo.should be_an_instance_of Photo - expect(@crop.default_photo.id).to eq @photo.id - end - - it 'is found in has_photos scope' do - Crop.has_photos.should include(@crop) - end + before { planting.photos << photo } + it { expect(crop.default_photo).to eq photo } + include_examples 'has default photo' end context 'with a harvest photo' do - before do - @harvest = FactoryBot.create(:harvest, crop: @crop) - @photo = FactoryBot.create(:photo, owner: @harvest.owner) - @harvest.photos << @photo - end - - it 'has a default photo' do - @crop.default_photo.should be_an_instance_of Photo - expect(@crop.default_photo.id).to eq @photo.id - end + let!(:harvest) { FactoryBot.create(:harvest, crop: crop) } + let!(:photo) { FactoryBot.create(:photo, owner: harvest.owner) } + before { harvest.photos << photo } + it { expect(crop.default_photo).to eq photo } + include_examples 'has default photo' context 'and planting photo' do - before do - @planting = FactoryBot.create(:planting, crop: @crop) - @planting_photo = FactoryBot.create(:photo, owner: @planting.owner) - @planting.photos << @planting_photo - end + let(:planting) { FactoryBot.create(:planting, crop: crop) } + let!(:planting_photo) { FactoryBot.create(:photo, owner: planting.owner) } + before { planting.photos << planting_photo } - it 'prefers the planting photo' do - expect(@crop.default_photo.id).to eq @planting_photo.id + it 'should prefer the planting photo' do + expect(crop.default_photo.id).to eq planting_photo.id end end end context 'with no plantings or harvests' do it 'has no default photo' do - expect(@crop.default_photo).to eq nil + expect(crop.default_photo).to eq nil end end + + describe 'finding all photos' do + let(:planting) { FactoryBot.create :planting, crop: crop } + let(:harvest) { FactoryBot.create :harvest, crop: crop } + let(:seed) { FactoryBot.create :seed, crop: crop } + before do + # Add photos to all + planting.photos << FactoryBot.create(:photo, owner: planting.owner) + harvest.photos << FactoryBot.create(:photo, owner: harvest.owner) + seed.photos << FactoryBot.create(:photo, owner: seed.owner) + end + + it { expect(crop.photos.size).to eq 3 } + it { expect(crop.planting_photos.size).to eq 1 } + it { expect(crop.harvest_photos.size).to eq 1 } + it { expect(crop.seed_photos.size).to eq 1 } + end end context 'sunniness' do @@ -292,7 +292,6 @@ describe Crop do let(:crop2_planting) { crop2.plantings.first } let(:member) { FactoryBot.create :member, login_name: 'pikachu' } - describe 'lists interesting crops' do before do # they need 3+ plantings each to be interesting @@ -337,6 +336,10 @@ 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) { FactoryBot.create(:harvest, crop: maize, plant_part: pp1) } let(:h2) { FactoryBot.create(:harvest, crop: maize, plant_part: pp2) } @@ -386,7 +389,7 @@ describe Crop do end context "csv loading" do - before do + before(:each) do # don't use 'let' for this -- we need to actually create it, # regardless of whether it's used. @cropbot = FactoryBot.create(:cropbot) @@ -553,11 +556,11 @@ describe Crop do tomato.destroy end - it "deletes the association between post and the crop(tomato)" do + it "should delete the association between post and the crop(tomato)" do expect(Post.find(post.id).crops).to eq [maize] end - it "does not delete the posts" do + it "should not delete the posts" do expect(Post.find(post.id)).not_to eq nil end end @@ -577,11 +580,11 @@ describe Crop do end describe "rejecting a crop" do - it "gives reason if a default option" do + it "should give reason if a default option" do expect(rejected_reason.rejection_explanation).to eq "not edible" end - it "shows rejection notes if reason was other" do + it "should show rejection notes if reason was other" do expect(rejected_other.rejection_explanation).to eq "blah blah blah" end end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index d71a6cd1c..b78718f5c 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -146,12 +146,12 @@ describe Photo do seed.photos << seed_photo end - it { expect(Photo.by_model(Harvest)).to eq([harvest_photo]) } - it { expect(Photo.by_model(Planting)).to eq([planting_photo]) } - it { expect(Photo.by_model(Seed)).to eq([seed_photo]) } + it { expect(Photo.by_model(Harvest)).to eq([ harvest_photo ]) } + it { expect(Photo.by_model(Planting)).to eq([ planting_photo ]) } + it { expect(Photo.by_model(Seed)).to eq([ seed_photo ]) } - it { expect(Photo.by_crop(harvest_crop)).to eq([harvest_photo]) } - it { expect(Photo.by_crop(planting_crop)).to eq([planting_photo]) } - it { expect(Photo.by_crop(seed_crop)).to eq([seed_photo]) } + it { expect(Photo.by_crop(harvest_crop)).to eq([ harvest_photo ]) } + it { expect(Photo.by_crop(planting_crop)).to eq([ planting_photo ]) } + it { expect(Photo.by_crop(seed_crop)).to eq([ seed_photo ]) } end end From 3e01da00366091f1dd00a496af241262e4c0c400 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 13 Apr 2019 12:05:58 +1200 Subject: [PATCH 14/17] Remove waffle link, replace with github projects (#1916) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ef1935e0e..c2d696fa2 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,9 @@ You might like to check out: Here on Github, you might find these useful: -* [Waffle](http://waffle.io/Growstuff/growstuff) has stories in "ready" that can be worked on. +* [Github Project Board](https://github.com/orgs/Growstuff/projects/1) has stories in "ready" that can be worked on. * [needs: design](https://github.com/Growstuff/growstuff/labels/needs:%20design) - tasks requiring high-level design -* [needs: visual design](https://github.com/Growstuff/growstuff/labels/needs:%20visual design) - tasks requiring visual/graphical design +* [needs: visual design](https://github.com/Growstuff/growstuff/labels/needs:%20visual+design) - tasks requiring visual/graphical design * [needs: documentation](https://github.com/Growstuff/growstuff/labels/needs:%20documentation) * [needs: data](https://github.com/Growstuff/growstuff/labels/needs:%20data) - tasks requiring data entry, data design, data import, or similar * [curated:beginner](https://github.com/Growstuff/growstuff/labels/curated:%20beginner) - tasks that are ideal for beginner programmers or people new to the project From cb680a5a0eec958b38bbad1ea6be0806eb9f1795 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 13 Apr 2019 12:09:47 +1200 Subject: [PATCH 15/17] Auto corrected by following Lint Ruby Space (#1917) --- spec/models/photo_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index b78718f5c..d71a6cd1c 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -146,12 +146,12 @@ describe Photo do seed.photos << seed_photo end - it { expect(Photo.by_model(Harvest)).to eq([ harvest_photo ]) } - it { expect(Photo.by_model(Planting)).to eq([ planting_photo ]) } - it { expect(Photo.by_model(Seed)).to eq([ seed_photo ]) } + it { expect(Photo.by_model(Harvest)).to eq([harvest_photo]) } + it { expect(Photo.by_model(Planting)).to eq([planting_photo]) } + it { expect(Photo.by_model(Seed)).to eq([seed_photo]) } - it { expect(Photo.by_crop(harvest_crop)).to eq([ harvest_photo ]) } - it { expect(Photo.by_crop(planting_crop)).to eq([ planting_photo ]) } - it { expect(Photo.by_crop(seed_crop)).to eq([ seed_photo ]) } + it { expect(Photo.by_crop(harvest_crop)).to eq([harvest_photo]) } + it { expect(Photo.by_crop(planting_crop)).to eq([planting_photo]) } + it { expect(Photo.by_crop(seed_crop)).to eq([seed_photo]) } end end From fb133b97b0b3d730ea7137904e964d6927cb3298 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 13 Apr 2019 12:12:35 +1200 Subject: [PATCH 16/17] Bump capybara from 3.16.1 to 3.16.2 (#1915) Bumps [capybara](https://github.com/teamcapybara/capybara) from 3.16.1 to 3.16.2. - [Release notes](https://github.com/teamcapybara/capybara/releases) - [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md) - [Commits](https://github.com/teamcapybara/capybara/compare/3.16.1...3.16.2) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7730545f3..38eb9fa60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,7 +80,7 @@ GEM uniform_notifier (~> 1.11) byebug (11.0.1) cancancan (3.0.0) - capybara (3.16.1) + capybara (3.16.2) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) From 5a8404e356023ef0aa98cda8a6998f7c0d7d9839 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 13 Apr 2019 00:15:24 +0000 Subject: [PATCH 17/17] Bump leaflet-rails from 1.3.1 to 1.4.0 Bumps [leaflet-rails](https://github.com/axyjo/leaflet-rails) from 1.3.1 to 1.4.0. - [Release notes](https://github.com/axyjo/leaflet-rails/releases) - [Changelog](https://github.com/axyjo/leaflet-rails/blob/master/CHANGELOG.md) - [Commits](https://github.com/axyjo/leaflet-rails/compare/v1.3.1...v1.4.0) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 38eb9fa60..98c785cf1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -265,7 +265,7 @@ GEM kramdown (2.1.0) launchy (2.4.3) addressable (~> 2.3) - leaflet-rails (1.3.1) + leaflet-rails (1.4.0) rails (>= 4.2.0) letter_opener (1.7.0) launchy (~> 2.2)