mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-24 08:52:14 -04:00
Merge branch 'dev' into plantings-show
This commit is contained in:
24
Gemfile.lock
24
Gemfile.lock
@@ -79,8 +79,8 @@ GEM
|
||||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.11)
|
||||
byebug (11.0.1)
|
||||
cancancan (2.3.0)
|
||||
capybara (3.16.0)
|
||||
cancancan (3.0.0)
|
||||
capybara (3.16.2)
|
||||
addressable
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (~> 1.8)
|
||||
@@ -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
|
||||
@@ -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.6)
|
||||
railties (>= 4)
|
||||
sprockets-rails
|
||||
json (2.1.0)
|
||||
jsonapi-resources (0.9.6)
|
||||
@@ -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)
|
||||
@@ -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.0.0)
|
||||
parser (2.6.2.1)
|
||||
ast (~> 2.4.0)
|
||||
pg (0.21.0)
|
||||
platform-api (2.2.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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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,82 +14,11 @@ 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
|
||||
expect(page).to have_no_selector('li', text: /tomato/i)
|
||||
expect(page).to have_no_selector('button', text: /Show+/i)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "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 }
|
||||
|
||||
scenario "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
|
||||
|
||||
scenario "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
|
||||
@@ -97,54 +26,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 +84,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."
|
||||
|
||||
@@ -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,14 @@ 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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 }
|
||||
@@ -72,36 +72,4 @@ feature "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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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,8 @@ 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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -49,7 +49,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
expect(page).not_to have_content "Finishes"
|
||||
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)
|
||||
@@ -155,7 +155,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"
|
||||
@@ -169,7 +169,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"
|
||||
@@ -177,7 +177,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).not_to have_content "Finishes"
|
||||
click_link "Edit"
|
||||
@@ -188,7 +188,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
expect(page).to have_content "Finished"
|
||||
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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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']})"
|
||||
|
||||
@@ -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']})"
|
||||
|
||||
@@ -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']})"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 }
|
||||
|
||||
describe "Selecting a date with datepicker" do
|
||||
before do
|
||||
|
||||
@@ -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']")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user