mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-30 04:35:28 -04:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,3 +14,4 @@ custom_plan.rb
|
||||
zeus.json
|
||||
.bundle
|
||||
config/application.yml
|
||||
.idea/**
|
||||
@@ -63,3 +63,4 @@ submit the change with your pull request.
|
||||
- Gabrielle DeWitt / [gabrielle27](https://github.com/gabrielle27)
|
||||
- Manmeet Singh / [manmeetsingh](https://github.com/manmeetsingh)
|
||||
- Jym Paul Carandang / [jacarandang](https://github.com/jacarandang)
|
||||
- Anthony Atkinson / [sha1sum](https://github.com/sha1sum)
|
||||
2
Gemfile
2
Gemfile
@@ -104,6 +104,8 @@ group :development do
|
||||
gem 'binding_of_caller'
|
||||
gem 'letter_opener'
|
||||
gem 'quiet_assets'
|
||||
gem 'guard'
|
||||
gem 'guard-rspec'
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
|
||||
34
Gemfile.lock
34
Gemfile.lock
@@ -163,9 +163,11 @@ GEM
|
||||
railties (>= 3.0.0)
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.9.10)
|
||||
figaro (1.0.0)
|
||||
thor (~> 0.14)
|
||||
flickraw (0.9.8)
|
||||
formatador (0.2.5)
|
||||
friendly_id (5.0.4)
|
||||
activerecord (>= 4.0.0)
|
||||
gibbon (1.1.4)
|
||||
@@ -174,6 +176,20 @@ GEM
|
||||
gravatar-ultimate (2.0.0)
|
||||
activesupport (>= 2.3.14)
|
||||
rack
|
||||
guard (2.12.8)
|
||||
formatador (>= 0.2.4)
|
||||
listen (>= 2.7, <= 4.0)
|
||||
lumberjack (~> 1.0)
|
||||
nenv (~> 0.1)
|
||||
notiffany (~> 0.0)
|
||||
pry (>= 0.9.12)
|
||||
shellany (~> 0.0)
|
||||
thor (>= 0.18.1)
|
||||
guard-compat (1.2.1)
|
||||
guard-rspec (4.6.2)
|
||||
guard (~> 2.1)
|
||||
guard-compat (~> 1.1)
|
||||
rspec (>= 2.99.0, < 4.0)
|
||||
haml (4.1.0.beta.1)
|
||||
tilt
|
||||
haml-rails (0.6.0)
|
||||
@@ -233,6 +249,10 @@ GEM
|
||||
letter_opener (1.3.0)
|
||||
launchy (~> 2.2)
|
||||
libv8 (3.16.14.7)
|
||||
listen (3.0.2)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
lumberjack (1.0.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
memcachier (0.0.2)
|
||||
@@ -243,10 +263,14 @@ GEM
|
||||
multi_json (1.10.1)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nenv (0.2.0)
|
||||
netrc (0.10.0)
|
||||
newrelic_rpm (3.9.8.273)
|
||||
nokogiri (1.6.5)
|
||||
mini_portile (~> 0.6.0)
|
||||
notiffany (0.0.6)
|
||||
nenv (~> 0.1)
|
||||
shellany (~> 0.0)
|
||||
oauth (0.4.7)
|
||||
omniauth (1.2.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
@@ -307,12 +331,19 @@ GEM
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
raindrops (0.13.0)
|
||||
rake (10.4.2)
|
||||
rb-fsevent (0.9.5)
|
||||
rb-inotify (0.9.5)
|
||||
ffi (>= 0.5.0)
|
||||
ref (1.0.5)
|
||||
responders (1.1.2)
|
||||
railties (>= 3.2, < 4.2)
|
||||
rest-client (1.7.2)
|
||||
mime-types (>= 1.16, < 3.0)
|
||||
netrc (~> 0.7)
|
||||
rspec (3.1.0)
|
||||
rspec-core (~> 3.1.0)
|
||||
rspec-expectations (~> 3.1.0)
|
||||
rspec-mocks (~> 3.1.0)
|
||||
rspec-activemodel-mocks (1.0.1)
|
||||
activemodel (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
@@ -343,6 +374,7 @@ GEM
|
||||
sprockets (~> 2.8, < 3.0)
|
||||
sprockets-rails (~> 2.0)
|
||||
sexp_processor (4.4.4)
|
||||
shellany (0.0.1)
|
||||
simplecov (0.9.1)
|
||||
docile (~> 1.1.0)
|
||||
multi_json (~> 1.0)
|
||||
@@ -423,6 +455,8 @@ DEPENDENCIES
|
||||
geocoder!
|
||||
gibbon
|
||||
gravatar-ultimate
|
||||
guard
|
||||
guard-rspec
|
||||
haml
|
||||
haml-rails
|
||||
heroku-api
|
||||
|
||||
13
Guardfile
Normal file
13
Guardfile
Normal file
@@ -0,0 +1,13 @@
|
||||
guard :rspec,
|
||||
cmd: 'bundle exec rspec --format documentation',
|
||||
failed_mode: :keep do
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/libs/#{m[1]}_spec.rb" }
|
||||
watch('spec/spec_helper.rb') { "spec" }
|
||||
|
||||
# Rails example
|
||||
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
||||
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
||||
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
||||
watch('config/routes.rb') { "spec/routing" }
|
||||
end
|
||||
@@ -97,12 +97,25 @@ p.stats {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.homepage-members {
|
||||
height: 100px;
|
||||
.member-cards {
|
||||
display: flex;
|
||||
flex: none;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.member-thumbnail {
|
||||
padding: .25em;
|
||||
|
||||
.homepage-members:nth-child(odd) {
|
||||
margin-left: 0px;
|
||||
div {
|
||||
width: 5em;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
div ~ div {
|
||||
width: 15em;
|
||||
padding-left: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
#placesmap, #cropmap {
|
||||
@@ -324,3 +337,24 @@ html, body {
|
||||
#add-sci_name-row, #remove-sci_name-row, #add-alt_name-row, #remove-alt_name-row{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.panel-footer{
|
||||
height: 6em;
|
||||
}
|
||||
|
||||
#gardens_panel_body{
|
||||
height: 20em;
|
||||
}
|
||||
|
||||
.form-group.required .control-label:before {
|
||||
content: "* ";
|
||||
color: red;
|
||||
}
|
||||
|
||||
.margin-bottom {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.red {
|
||||
color: red;
|
||||
}
|
||||
|
||||
@@ -31,5 +31,11 @@ module ApplicationHelper
|
||||
"#{klass.name.downcase.pluralize}/#{identifier}-#{count}-#{max_updated_at}"
|
||||
end
|
||||
|
||||
def required_field_help_text
|
||||
asterisk = content_tag :span, '*', class: ['red']
|
||||
text = content_tag :em, 'denotes a required field'
|
||||
content_tag :div, asterisk + ' '.html_safe + text, class: ['margin-bottom']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
25
app/helpers/gardens_helper.rb
Normal file
25
app/helpers/gardens_helper.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
module GardensHelper
|
||||
|
||||
def display_garden_description(garden)
|
||||
if garden.description.nil?
|
||||
"no description provided."
|
||||
else
|
||||
truncate(garden.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", garden_path(garden) }
|
||||
end
|
||||
end
|
||||
|
||||
def display_garden_plantings(plantings)
|
||||
if plantings.blank?
|
||||
"None"
|
||||
else
|
||||
output = ""
|
||||
plantings.first(2).each do |planting|
|
||||
output += "<li>"
|
||||
output += planting.quantity.nil? ? "0 " : "#{planting.quantity} "
|
||||
output += link_to planting.crop.name, planting.crop
|
||||
output += ", planted on #{planting.planted_at}</li>"
|
||||
end
|
||||
output.html_safe
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -37,4 +37,12 @@ module HarvestsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def display_harvest_description(harvest)
|
||||
if harvest.description.nil?
|
||||
"no description provided."
|
||||
else
|
||||
truncate(harvest.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", harvest_path(harvest) }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
11
app/helpers/seeds_helper.rb
Normal file
11
app/helpers/seeds_helper.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module SeedsHelper
|
||||
|
||||
def display_seed_description(seed)
|
||||
if seed.description.nil?
|
||||
"no description provided."
|
||||
else
|
||||
truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", seed_path(seed) }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,3 +1,5 @@
|
||||
= required_field_help_text
|
||||
|
||||
= form_for(@garden, :html => {:class => "form-horizontal", :role => "form"}) do |f|
|
||||
- if @garden.errors.any?
|
||||
#error_explanation
|
||||
@@ -6,7 +8,7 @@
|
||||
- @garden.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :name, :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.text_field :name, :class => 'form-control'
|
||||
@@ -14,12 +16,12 @@
|
||||
.form-group
|
||||
= f.label :description, :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.text_area :description, :rows => 6, :class => 'form-control'
|
||||
= f.text_area :description, :rows => 6, :class => 'form-control', :placeholder => 'optional'
|
||||
|
||||
.form-group
|
||||
= f.label :location, :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.text_field :location, :value => @garden.location || current_member.location, :class => 'form-control'
|
||||
= f.text_field :location, :value => @garden.location || current_member.location, :class => 'form-control', :placeholder => 'optional'
|
||||
%span.help-block
|
||||
If you have a location set in your profile, it will be used when
|
||||
you create a new garden.
|
||||
@@ -31,7 +33,7 @@
|
||||
.form-group
|
||||
= f.label :area, :class => 'control-label col-md-2'
|
||||
.col-md-2
|
||||
= f.number_field :area, :class => 'input-small form-control'
|
||||
= f.number_field :area, :class => 'input-small form-control', :placeholder => 'optional'
|
||||
.col-md-2
|
||||
= f.select(:area_unit, Garden::AREA_UNITS_VALUES, {:include_blank => false}, :class => 'form-control')
|
||||
|
||||
|
||||
36
app/views/gardens/_thumbnail.html.haml
Normal file
36
app/views/gardens/_thumbnail.html.haml
Normal file
@@ -0,0 +1,36 @@
|
||||
.panel.panel-success
|
||||
.panel-heading
|
||||
%h3.panel-title
|
||||
= link_to "#{garden.owner.login_name}'s garden", garden.owner
|
||||
- if can? :edit, garden
|
||||
%a.pull-right{:href => edit_garden_path(garden), :role => "button", :id => "edit_garden_glyphicon"}
|
||||
%span.glyphicon.glyphicon-pencil{:title => "Edit"}
|
||||
.panel-body{:id => "gardens_panel_body"}
|
||||
.row
|
||||
.col-md-4
|
||||
= link_to image_tag((garden.default_photo ? garden.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => garden.name, :class => 'img'), garden
|
||||
.col-md-8
|
||||
%dl.dl-horizontal
|
||||
%dt Name :
|
||||
%dd= link_to garden.name, garden
|
||||
%dt Location :
|
||||
%dd
|
||||
- if garden.location.blank?
|
||||
not specified
|
||||
- else
|
||||
= link_to garden.location, place_path(garden.location)
|
||||
%dt Area :
|
||||
%dd= garden.area.nil? ? "not specified" : pluralize(garden.area, garden.area_unit)
|
||||
%dt Active? :
|
||||
%dd= garden.active ? "Yes" : "No"
|
||||
.col-md-12
|
||||
%b
|
||||
= "#{pluralize(garden.plantings.count, "Planting")} : "
|
||||
= display_garden_plantings(garden.plantings.current)
|
||||
- if garden.plantings.count > 2
|
||||
%br
|
||||
= link_to "See more plantings >>", garden_path(garden)
|
||||
.panel-footer
|
||||
%dt Description
|
||||
%dd
|
||||
= display_garden_description(garden)
|
||||
@@ -14,56 +14,19 @@
|
||||
- else
|
||||
= render :partial => 'shared/signin_signup', :locals => { :to => 'add a new garden' }
|
||||
|
||||
- if @gardens.size > 0
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @gardens, :model => "gardens"
|
||||
= will_paginate @gardens
|
||||
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
- unless @owner
|
||||
%th Owner
|
||||
%th Garden name
|
||||
%th Description
|
||||
%th Location
|
||||
%th Area
|
||||
%th Active?
|
||||
%th Plantings
|
||||
%th
|
||||
%div.pagination
|
||||
= page_entries_info @gardens, :model => "gardens"
|
||||
= will_paginate @gardens
|
||||
|
||||
.row
|
||||
- if @gardens.size > 0
|
||||
- @gardens.each do |garden|
|
||||
%tr
|
||||
- unless @owner
|
||||
%td= link_to garden.owner.login_name, garden.owner
|
||||
%td= link_to garden.name, garden
|
||||
%td= garden.description
|
||||
%td
|
||||
- if ! garden.location.blank?
|
||||
= link_to garden.location, place_path(garden.location)
|
||||
%td
|
||||
- if garden.area
|
||||
= pluralize(garden.area, garden.area_unit)
|
||||
%td= garden.active ? "Yes" : "No"
|
||||
%td
|
||||
- if garden.plantings.empty?
|
||||
None
|
||||
- else
|
||||
%ul
|
||||
- garden.plantings.current.each do |p|
|
||||
%li
|
||||
= p.quantity
|
||||
= link_to p.crop.name, p
|
||||
- if p.planted_at
|
||||
planted on
|
||||
= p.planted_at
|
||||
.col-md-6
|
||||
=render :partial => 'gardens/thumbnail', :locals => {:garden => garden}
|
||||
- else
|
||||
%p There are no gardens to display.
|
||||
|
||||
%td= link_to 'Details', garden, :class => 'btn btn-default btn-xs'
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @gardens, :model => "gardens"
|
||||
= will_paginate @gardens
|
||||
|
||||
- else
|
||||
%p There are no gardens to display.
|
||||
%div.pagination
|
||||
= page_entries_info @gardens, :model => "gardens"
|
||||
= will_paginate @gardens
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
= required_field_help_text
|
||||
|
||||
= form_for(@harvest, :html => {:class => "form-horizontal", :role => :form}) do |f|
|
||||
- if @harvest.errors.any?
|
||||
#error_explanation
|
||||
@@ -6,7 +8,7 @@
|
||||
- @harvest.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :crop, 'What did you harvest?', :class => 'control-label col-md-2'
|
||||
.col-md-4
|
||||
= auto_suggest @harvest, :crop, :class => 'form-control col-md-2', :default => @crop
|
||||
@@ -17,7 +19,7 @@
|
||||
= link_to "Request new crops.", new_crop_path
|
||||
|
||||
.form-group
|
||||
= f.label :harvested_at, 'When?', :class => 'control-label col-md-2'
|
||||
= f.label :harvested_at, 'When?', :class => 'control-label col-md-2', :placeholder => 'optional'
|
||||
.col-md-2
|
||||
= f.text_field :harvested_at, :value => @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', :class => 'add-datepicker form-control'
|
||||
|
||||
@@ -27,20 +29,20 @@
|
||||
-# Some browsers (eg Firefox for Android) assume "number" means
|
||||
-# "integer" unless you specify step="any":
|
||||
-# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/
|
||||
= f.number_field :quantity, :class => 'input-small', :step => 'any', :class => 'form-control'
|
||||
= f.number_field :quantity, :class => 'input-small', :step => 'any', :class => 'form-control', :placeholder => 'optional'
|
||||
.col-md-2
|
||||
= f.select(:unit, Harvest::UNITS_VALUES, {:include_blank => false}, :class => 'input-medium form-control')
|
||||
|
||||
.form-group
|
||||
= f.label :weight_quantity, 'Weighing (in total):', :class => 'control-label col-md-2'
|
||||
.col-md-2
|
||||
= f.number_field :weight_quantity, :class => 'input-small', :step => 'any', :class => 'form-control'
|
||||
= f.number_field :weight_quantity, :class => 'input-small', :step => 'any', :class => 'form-control', :placeholder => 'optional'
|
||||
.col-md-2
|
||||
= f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, {:include_blank => false}, :class => 'form-control')
|
||||
.form-group
|
||||
= f.label :description, 'Notes', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.text_area :description, :rows => 6, :class => 'form-control'
|
||||
= f.text_area :description, :rows => 6, :class => 'form-control', :placeholder => 'optional'
|
||||
|
||||
.form-group
|
||||
.form-actions.col-md-offset-2.col-md-8
|
||||
|
||||
25
app/views/harvests/_thumbnail.html.haml
Normal file
25
app/views/harvests/_thumbnail.html.haml
Normal file
@@ -0,0 +1,25 @@
|
||||
.panel.panel-success
|
||||
.panel-heading
|
||||
%h3.panel-title
|
||||
= link_to "#{harvest.owner.login_name}'s harvest", harvest.owner
|
||||
- if can? :edit, harvest
|
||||
%a.pull-right{:href => edit_harvest_path(harvest), :role => "button", :id => "edit_harvest_glyphicon"}
|
||||
%span.glyphicon.glyphicon-pencil{:title => "Edit"}
|
||||
.panel-body
|
||||
.row
|
||||
.col-md-4
|
||||
= link_to image_tag((harvest.crop.default_photo ? harvest.crop.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => harvest.crop.name, :class => 'img'), harvest.crop
|
||||
.col-md-8
|
||||
%dl.dl-horizontal
|
||||
%dt Crop :
|
||||
%dd= link_to harvest.crop.name, harvest.crop
|
||||
%dt Plant part :
|
||||
%dd= link_to harvest.plant_part, harvest.plant_part
|
||||
%dt Quantity :
|
||||
%dd= display_quantity(harvest)
|
||||
%dt Harvest date :
|
||||
%dd= harvest.harvested_at
|
||||
.panel-footer
|
||||
%dt Description
|
||||
%dd
|
||||
= display_harvest_description(harvest)
|
||||
@@ -23,36 +23,15 @@
|
||||
%div.pagination
|
||||
= page_entries_info @harvests, :model => "harvests"
|
||||
= will_paginate @harvests
|
||||
|
||||
- if @harvests.size > 0
|
||||
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
- unless @owner
|
||||
%th Owner
|
||||
%th Crop
|
||||
%th Plant part
|
||||
%th Date
|
||||
%th Quantity
|
||||
%th Description
|
||||
%th
|
||||
|
||||
.row
|
||||
- if @harvests.size > 0
|
||||
- @harvests.each do |harvest|
|
||||
%tr
|
||||
- unless @owner
|
||||
%td= link_to harvest.owner.login_name, harvest.owner
|
||||
%td= link_to harvest.crop.name, harvest.crop
|
||||
%td
|
||||
- if harvest.plant_part
|
||||
= link_to harvest.plant_part.name, harvest.plant_part
|
||||
%td= harvest.harvested_at
|
||||
%td= display_quantity(harvest)
|
||||
%td= harvest.description
|
||||
%td= link_to 'Details', harvest, :class => 'btn btn-default btn-xs'
|
||||
.col-md-6
|
||||
=render :partial => 'harvests/thumbnail', :locals => {:harvest => harvest}
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @harvests, :model => "harvests"
|
||||
= will_paginate @harvests
|
||||
%div.pagination
|
||||
= page_entries_info @harvests, :model => "harvests"
|
||||
= will_paginate @harvests
|
||||
|
||||
%ul.list-inline
|
||||
%li The data on this page is available in the following formats:
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
.hidden-xs
|
||||
- members = Member.interesting.first(6)
|
||||
- if members.present?
|
||||
%section
|
||||
%h2= t('.title')
|
||||
|
||||
.row
|
||||
.member-cards
|
||||
- members.each do |m|
|
||||
.col-md-4.homepage-members
|
||||
= render :partial => "members/thumbnail", :locals => { :member => m }
|
||||
= render :partial => "members/thumbnail", :locals => { :member => m }
|
||||
|
||||
%p.text-right
|
||||
= link_to "#{t('.view_all')} »", members_path
|
||||
|
||||
@@ -7,3 +7,6 @@
|
||||
!= cms_snippet_content(:footer2)
|
||||
.col-md-4#footer3
|
||||
!= cms_snippet_content(:footer3)
|
||||
%div(style="float: right;")
|
||||
%a(href="http://opendefinition.org/ossd/")
|
||||
%img(src="http://assets.okfn.org/images/ok_buttons/os_80x15_blue.png" alt="")
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
- cache member do
|
||||
.row
|
||||
.member-thumbnail
|
||||
.col-md-3
|
||||
= render :partial => "members/image_with_popover", :locals => { :member => member }
|
||||
.col-md-9
|
||||
%p
|
||||
= link_to member.login_name, member
|
||||
- if ! member.location.blank?
|
||||
%small
|
||||
%br/
|
||||
%i= member.location
|
||||
- if ! member.plantings.empty?
|
||||
%small
|
||||
%br/
|
||||
Recently planted:
|
||||
!= member.plantings.first(3).map{|p| link_to p.crop_name, p }.join(", ")
|
||||
.member-thumbnail.panel
|
||||
%div
|
||||
= render :partial => "members/image_with_popover", :locals => { :member => member }
|
||||
%div
|
||||
%p
|
||||
= link_to member.login_name, member
|
||||
- if ! member.location.blank?
|
||||
%small
|
||||
%br/
|
||||
%i= member.location
|
||||
- if ! member.plantings.empty?
|
||||
%small
|
||||
%br/
|
||||
Recently planted:
|
||||
!= member.plantings.first(3).map{|p| link_to p.crop_name, p }.join(", ")
|
||||
|
||||
@@ -10,11 +10,9 @@
|
||||
= page_entries_info @members, :model => "members"
|
||||
= will_paginate @members
|
||||
|
||||
.row
|
||||
.member-cards
|
||||
- @members.each do |m|
|
||||
.col-md-4.three-across
|
||||
.thumbnail
|
||||
= render :partial => "members/thumbnail", :locals => { :member => m }
|
||||
= render :partial => "members/thumbnail", :locals => { :member => m }
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @members, :model => "members"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
= required_field_help_text
|
||||
|
||||
= form_for(@planting, :html => {:class => "form-horizontal", :role => "form"}) do |f|
|
||||
- if @planting.errors.any?
|
||||
#error_explanation
|
||||
@@ -6,14 +8,14 @@
|
||||
- @planting.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :crop, 'What did you plant?', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= auto_suggest @planting, :crop, :class => 'form-control', :default => @crop
|
||||
%span.help-inline
|
||||
Can't find what you're looking for?
|
||||
= link_to "Request new crops.", new_crop_path
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :garden_id, 'Where did you plant it?', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= collection_select(:planting, :garden_id, Garden.active.where(:owner_id => current_member), :id, :name, {:selected => @planting.garden_id || @garden.id}, {:class => 'form-control'})
|
||||
@@ -21,22 +23,22 @@
|
||||
= link_to "Add a garden.", new_garden_path
|
||||
.form-group
|
||||
= f.label :planted_at, 'When?', :class => 'control-label col-md-2'
|
||||
.col-md-2= f.text_field :planted_at, :value => @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', :class => 'add-datepicker form-control'
|
||||
.col-md-2= f.text_field :planted_at, :value => @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', :class => 'add-datepicker form-control', :placeholder => 'optional'
|
||||
.form-group
|
||||
= f.label :quantity, 'How many?', :class => 'control-label col-md-2'
|
||||
.col-md-2
|
||||
= f.number_field :quantity, :class => 'form-control'
|
||||
= f.number_field :quantity, :class => 'form-control', :placeholder => 'optional'
|
||||
.form-group
|
||||
= f.label :planted_from, 'Planted from:', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.select(:planted_from, Planting::PLANTED_FROM_VALUES, {:include_blank => true}, :class => 'form-control')
|
||||
= f.select(:planted_from, Planting::PLANTED_FROM_VALUES, {:include_blank => 'optional'}, :class => 'form-control')
|
||||
.form-group
|
||||
= f.label :sunniness, 'Sun or shade?', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.select(:sunniness, Planting::SUNNINESS_VALUES, {:include_blank => true}, :class => 'form-control')
|
||||
= f.select(:sunniness, Planting::SUNNINESS_VALUES, {:include_blank => 'optional'}, :class => 'form-control')
|
||||
.form-group
|
||||
= f.label :description, 'Tell us more about it', :class => 'control-label col-md-2'
|
||||
.col-md-8= f.text_area :description, :rows => 6, :class => 'form-control'
|
||||
.col-md-8= f.text_area :description, :rows => 6, :class => 'form-control', :placeholder => 'optional'
|
||||
.form-group
|
||||
= f.label :finished, 'Mark as finished', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
@@ -44,9 +46,9 @@
|
||||
%span.help-block
|
||||
A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise no longer growing in your garden.
|
||||
.form-group
|
||||
= f.label :finished_at, 'Finished date', { :class => 'control-label col-md-2' }
|
||||
= f.label :finished_at, 'Finished date', { :class => 'control-label col-md-2', :placeholder => 'optional' }
|
||||
.col-md-2
|
||||
= f.text_field :finished_at, :value => @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '', :class => 'add-datepicker form-control'
|
||||
= f.text_field :finished_at, :value => @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '', :class => 'add-datepicker form-control', :placeholder => 'optional'
|
||||
.form-group
|
||||
.form-actions.col-md-offset-2.col-md-8
|
||||
= f.submit 'Save', :class => 'btn btn-primary'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
= required_field_help_text
|
||||
|
||||
= form_for(@seed, :html => {:class => "form-horizontal", :role => "form"}) do |f|
|
||||
- if @seed.errors.any?
|
||||
#error_explanation
|
||||
@@ -6,7 +8,7 @@
|
||||
- @seed.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :crop, 'Crop:', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= auto_suggest @seed, :crop, :class => 'form-control', :default => @crop
|
||||
@@ -14,40 +16,40 @@
|
||||
Can't find what you're looking for?
|
||||
= link_to "Request new crops.", new_crop_path
|
||||
.form-group
|
||||
= f.label :quantity, 'Quantity:', :class => 'control-label col-md-2'
|
||||
= f.label :quantity, 'Quantity:', :class => 'control-label col-md-2', :placeholder => 'optional'
|
||||
.col-md-2
|
||||
= f.number_field :quantity, :class => 'form-control'
|
||||
= f.number_field :quantity, :class => 'form-control', placeholder: 'optional'
|
||||
.form-group
|
||||
= f.label :plant_before, 'Plant before:', :class => 'control-label col-md-2'
|
||||
.col-md-2
|
||||
= f.text_field :plant_before, :class => 'add-datepicker form-control', :value => @seed.plant_before ? @seed.plant_before.to_s(:ymd) : ''
|
||||
= f.text_field :plant_before, :class => 'add-datepicker form-control', :value => @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '', placeholder: 'optional'
|
||||
.form-group
|
||||
= f.label :days_until_maturity_min, 'Days until maturity:', :class => 'control-label col-md-2'
|
||||
= f.label :days_until_maturity_min, 'Days until maturity:', :class => 'control-label col-md-2', :placeholder => 'optional'
|
||||
%fieldset
|
||||
.col-md-2
|
||||
= f.number_field :days_until_maturity_min, :class => 'form-control'
|
||||
= f.number_field :days_until_maturity_min, :class => 'form-control', placeholder: 'optional'
|
||||
.col-md-1
|
||||
= f.label :days_until_maturity_max, 'to', :class => 'control-label'
|
||||
.col-md-2
|
||||
= f.number_field :days_until_maturity_max, :class => 'form-control'
|
||||
= f.number_field :days_until_maturity_max, :class => 'form-control', placeholder: 'optional'
|
||||
.col-md-1
|
||||
= f.label :dummy, 'days', :class => 'control-label'
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :organic, 'Organic?', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.select(:organic, Seed::ORGANIC_VALUES, {}, :class => 'form-control', :default => 'unknown')
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :gmo, 'GMO?', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.select(:gmo, Seed::GMO_VALUES, {}, :class => 'form-control', :default => 'unknown')
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :heirloom, 'Heirloom?', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, :class => 'form-control', :default => 'unknown')
|
||||
.form-group
|
||||
= f.label :description, 'Description:', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.text_area :description, :rows => 6, :class => 'form-control'
|
||||
= f.text_area :description, :rows => 6, :class => 'form-control', :placeholder => 'optional'
|
||||
.form-group
|
||||
.col-md-offset-2.col-md-8
|
||||
%span.help-block
|
||||
@@ -56,7 +58,7 @@
|
||||
list your seeds as available for trade, other members can
|
||||
contact you to request seeds. You can list any conditions or
|
||||
other information in the description, above.
|
||||
.form-group
|
||||
.form-group.required
|
||||
= f.label :tradable_to, 'Will trade:', :class => 'control-label col-md-2'
|
||||
.col-md-8
|
||||
= f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {}, :class => 'form-control')
|
||||
|
||||
27
app/views/seeds/_thumbnail.html.haml
Normal file
27
app/views/seeds/_thumbnail.html.haml
Normal file
@@ -0,0 +1,27 @@
|
||||
.panel.panel-success
|
||||
.panel-heading
|
||||
%h3.panel-title
|
||||
= link_to "#{seed.owner.login_name}'s seed", seed.owner
|
||||
- if can? :edit, seed
|
||||
%a.pull-right{:href => edit_seed_path(seed), :role => "button", :id => "edit_seed_glyphicon"}
|
||||
%span.glyphicon.glyphicon-pencil{:title => "Edit"}
|
||||
.panel-body
|
||||
.row
|
||||
.col-md-4
|
||||
= link_to image_tag((seed.crop.default_photo ? seed.crop.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => seed.crop.name, :class => 'img'), seed.crop
|
||||
.col-md-8
|
||||
%dl.dl-horizontal
|
||||
%dt Crop :
|
||||
%dd= link_to seed.crop.name, seed.crop
|
||||
%dt Plant before :
|
||||
%dd= seed.plant_before
|
||||
%dt Quantity :
|
||||
%dd= seed.quantity
|
||||
%dt Will trade to :
|
||||
%dd= seed.tradable_to
|
||||
%dt From location :
|
||||
%dd= seed.owner.location
|
||||
.panel-footer
|
||||
%dt Description
|
||||
%dd
|
||||
= display_seed_description(seed)
|
||||
@@ -23,52 +23,23 @@
|
||||
%div.pagination
|
||||
= page_entries_info @seeds, :model => "seeds"
|
||||
= will_paginate @seeds
|
||||
|
||||
- if @seeds.size > 0
|
||||
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
- unless @owner
|
||||
%th Owner
|
||||
%th Crop
|
||||
%th Description
|
||||
%th Quantity
|
||||
%th Plant before
|
||||
%th Will trade to
|
||||
%th From location
|
||||
%th
|
||||
|
||||
.row
|
||||
- if @seeds.size > 0
|
||||
- @seeds.each do |seed|
|
||||
%tr
|
||||
- unless @owner
|
||||
%td= link_to seed.owner.login_name, seed.owner
|
||||
%td= link_to seed.crop.name, seed.crop
|
||||
%td= seed.description
|
||||
%td= seed.quantity
|
||||
%td= seed.plant_before
|
||||
%td= seed.tradable? ? seed.tradable_to : ''
|
||||
%td
|
||||
- if seed.tradable?
|
||||
- if seed.owner.location.blank?
|
||||
unspecified
|
||||
- else
|
||||
= link_to seed.owner.location, place_path(seed.owner.location)
|
||||
%td
|
||||
= link_to 'Details', seed, :class => 'btn btn-default btn-xs'
|
||||
- if can? :edit, seed
|
||||
= link_to 'Edit', edit_seed_path(seed), :class => 'btn btn-default btn-xs'
|
||||
.col-md-6
|
||||
=render :partial => 'seeds/thumbnail', :locals => {:seed => seed}
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @seeds, :model => "seeds"
|
||||
= will_paginate @seeds
|
||||
%div.pagination
|
||||
= page_entries_info @seeds, :model => "seeds"
|
||||
= will_paginate @seeds
|
||||
|
||||
%ul.list-inline
|
||||
%li The data on this page is available in the following formats:
|
||||
- if @owner
|
||||
%li= link_to "CSV", seeds_by_owner_path(@owner, :format => 'csv')
|
||||
%li= link_to "JSON", seeds_by_owner_path(@owner, :format => 'json')
|
||||
%li= link_to "RSS", seeds_by_owner_path(@owner, :format => 'rss')
|
||||
- else
|
||||
%li= link_to "CSV", seeds_path(:format => 'csv')
|
||||
%li= link_to "JSON", seeds_path(:format => 'json')
|
||||
%li= link_to "RSS", seeds_path(:format => 'rss')
|
||||
%ul.list-inline
|
||||
%li The data on this page is available in the following formats:
|
||||
- if @owner
|
||||
%li= link_to "CSV", seeds_by_owner_path(@owner, :format => 'csv')
|
||||
%li= link_to "JSON", seeds_by_owner_path(@owner, :format => 'json')
|
||||
%li= link_to "RSS", seeds_by_owner_path(@owner, :format => 'rss')
|
||||
- else
|
||||
%li= link_to "CSV", seeds_path(:format => 'csv')
|
||||
%li= link_to "JSON", seeds_path(:format => 'json')
|
||||
%li= link_to "RSS", seeds_path(:format => 'rss')
|
||||
|
||||
@@ -406,7 +406,6 @@ ActiveRecord::Schema.define(version: 20150625224805) do
|
||||
t.datetime "updated_at"
|
||||
t.string "slug"
|
||||
t.integer "forum_id"
|
||||
t.integer "parent_id"
|
||||
end
|
||||
|
||||
add_index "posts", ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id", using: :btree
|
||||
|
||||
@@ -2,7 +2,8 @@ require 'rails_helper'
|
||||
|
||||
feature "account types" do
|
||||
context "admin user" do
|
||||
let(:member) { FactoryGirl.create(:admin_member) }
|
||||
let(:member) { create :admin_member }
|
||||
let(:account_type) { create :account_type }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
@@ -11,38 +12,36 @@ feature "account types" do
|
||||
scenario "navigating to account type admin" do
|
||||
visit root_path
|
||||
click_link "Admin"
|
||||
current_path.should eq admin_path
|
||||
expect(current_path).to eq admin_path
|
||||
click_link "Account types"
|
||||
current_path.should eq account_types_path
|
||||
expect(current_path).to eq account_types_path
|
||||
end
|
||||
|
||||
scenario "adding an account type" do
|
||||
visit account_types_path
|
||||
click_link "New Account type"
|
||||
current_path.should eq new_account_type_path
|
||||
fill_in 'Name', :with => 'Guest'
|
||||
expect(current_path).to eq new_account_type_path
|
||||
fill_in 'Name', with: 'Guest'
|
||||
click_button 'Save'
|
||||
current_path.should eq account_type_path(AccountType.last)
|
||||
page.should have_content 'Account type was successfully created'
|
||||
expect(current_path).to eq account_type_path(AccountType.last)
|
||||
expect(page).to have_content 'Account type was successfully created'
|
||||
end
|
||||
|
||||
scenario 'editing account type' do
|
||||
a = FactoryGirl.create(:account_type)
|
||||
visit account_type_path(a)
|
||||
visit account_type_path account_type
|
||||
click_link 'Edit'
|
||||
fill_in 'Name', :with => 'Something else'
|
||||
fill_in 'Name', with: 'Something else'
|
||||
click_button 'Save'
|
||||
current_path.should eq account_type_path(a)
|
||||
page.should have_content 'Account type was successfully updated'
|
||||
page.should have_content 'Something else'
|
||||
expect(current_path).to eq account_type_path(account_type)
|
||||
expect(page).to have_content 'Account type was successfully updated'
|
||||
expect(page).to have_content 'Something else'
|
||||
end
|
||||
|
||||
scenario 'deleting account type' do
|
||||
a = FactoryGirl.create(:account_type)
|
||||
visit account_type_path(a)
|
||||
visit account_type_path account_type
|
||||
click_link 'Delete'
|
||||
current_path.should eq account_types_path
|
||||
page.should have_content 'Account type was successfully deleted'
|
||||
expect(current_path).to eq account_types_path
|
||||
expect(page).to have_content 'Account type was successfully deleted'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "forums" do
|
||||
context "admin user" do
|
||||
let(:member) { FactoryGirl.create(:admin_member) }
|
||||
context "as an admin user" do
|
||||
let(:member) { create :admin_member }
|
||||
let(:forum) { create :forum }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
@@ -11,43 +12,41 @@ feature "forums" do
|
||||
scenario "navigating to forum admin" do
|
||||
visit root_path
|
||||
click_link "Admin"
|
||||
current_path.should eq admin_path
|
||||
expect(current_path).to eq admin_path
|
||||
within 'ul#admin_links' do
|
||||
click_link "Forums"
|
||||
end
|
||||
current_path.should eq forums_path
|
||||
page.should have_content "New forum"
|
||||
expect(current_path).to eq forums_path
|
||||
expect(page).to have_content "New forum"
|
||||
end
|
||||
|
||||
scenario "adding a forum" do
|
||||
visit forums_path
|
||||
click_link "New forum"
|
||||
current_path.should eq new_forum_path
|
||||
fill_in 'Name', :with => 'Discussion'
|
||||
fill_in 'Description', :with => "this is a new forum"
|
||||
expect(current_path).to eq new_forum_path
|
||||
fill_in 'Name', with: 'Discussion'
|
||||
fill_in 'Description', with: "this is a new forum"
|
||||
click_button 'Save'
|
||||
current_path.should eq forum_path(Forum.last)
|
||||
page.should have_content 'Forum was successfully created'
|
||||
expect(current_path).to eq forum_path(Forum.last)
|
||||
expect(page).to have_content 'Forum was successfully created'
|
||||
end
|
||||
|
||||
scenario 'editing forum' do
|
||||
f = FactoryGirl.create(:forum)
|
||||
visit forum_path(f)
|
||||
visit forum_path forum
|
||||
click_link 'Edit'
|
||||
fill_in 'Name', :with => 'Something else'
|
||||
fill_in 'Name', with: 'Something else'
|
||||
click_button 'Save'
|
||||
f.reload
|
||||
current_path.should eq forum_path(f)
|
||||
page.should have_content 'Forum was successfully updated'
|
||||
page.should have_content 'Something else'
|
||||
forum.reload
|
||||
expect(current_path).to eq forum_path(forum)
|
||||
expect(page).to have_content 'Forum was successfully updated'
|
||||
expect(page).to have_content 'Something else'
|
||||
end
|
||||
|
||||
scenario 'deleting forum' do
|
||||
f = FactoryGirl.create(:forum)
|
||||
visit forum_path(f)
|
||||
visit forum_path forum
|
||||
click_link 'Delete'
|
||||
current_path.should eq forums_path
|
||||
page.should have_content 'Forum was successfully deleted'
|
||||
expect(current_path).to eq forums_path
|
||||
expect(page).to have_content 'Forum was successfully deleted'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,8 @@ require 'rails_helper'
|
||||
|
||||
feature "products" do
|
||||
context "admin user" do
|
||||
let(:member) { FactoryGirl.create(:admin_member) }
|
||||
let(:member) { create :admin_member }
|
||||
let(:product) { create :product }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
@@ -11,30 +12,29 @@ feature "products" do
|
||||
scenario "navigating to product admin" do
|
||||
visit admin_path
|
||||
click_link "Products"
|
||||
current_path.should eq products_path
|
||||
expect(current_path).to eq products_path
|
||||
end
|
||||
|
||||
scenario "adding a product" do
|
||||
visit products_path
|
||||
click_link "New Product"
|
||||
current_path.should eq new_product_path
|
||||
fill_in 'Name', :with => 'Special offer'
|
||||
expect(current_path).to eq new_product_path
|
||||
fill_in 'Name', with: 'Special offer'
|
||||
# note that failing to fill in a mandatory field has a messy error. This is not a priority defect but should be raised at some point.
|
||||
fill_in 'Minimum price', :with => '150'
|
||||
fill_in 'Minimum price', with: '150'
|
||||
click_button 'Save'
|
||||
current_path.should eq product_path(Product.last)
|
||||
page.should have_content 'Product was successfully created'
|
||||
expect(current_path).to eq product_path(Product.last)
|
||||
expect(page).to have_content 'Product was successfully created'
|
||||
end
|
||||
|
||||
scenario 'editing product' do
|
||||
p = FactoryGirl.create(:product)
|
||||
visit product_path(p)
|
||||
visit product_path product
|
||||
click_link 'Edit'
|
||||
fill_in 'Name', :with => 'Something else'
|
||||
fill_in 'Name', with: 'Something else'
|
||||
click_button 'Save'
|
||||
current_path.should eq product_path(p)
|
||||
page.should have_content 'Product was successfully updated'
|
||||
page.should have_content 'Something else'
|
||||
expect(current_path).to eq product_path(product)
|
||||
expect(page).to have_content 'Product was successfully updated'
|
||||
expect(page).to have_content 'Something else'
|
||||
end
|
||||
|
||||
scenario 'deleting product'
|
||||
@@ -1,27 +1,26 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "cms admin" do
|
||||
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:admin_member) { FactoryGirl.create(:admin_member) }
|
||||
let(:member) { create :member }
|
||||
let(:admin_member) { create :admin_member }
|
||||
|
||||
scenario "can't view CMS admin if not signed in" do
|
||||
visit comfy_admin_cms_path
|
||||
current_path.should == root_path
|
||||
page.should have_content("Please sign in as an admin user")
|
||||
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
|
||||
# sign in as an ordinary member
|
||||
login_as member
|
||||
visit comfy_admin_cms_path
|
||||
current_path.should == root_path
|
||||
page.should have_content("Please sign in as an admin user")
|
||||
expect(current_path).to eq root_path
|
||||
expect(page).to have_content "Please sign in as an admin user"
|
||||
end
|
||||
|
||||
scenario "admin members can view CMS admin area" do
|
||||
login_as admin_member
|
||||
visit comfy_admin_cms_path
|
||||
current_path.should match /#{comfy_admin_cms_path}/ # match any CMS admin page
|
||||
expect(current_path).to match /#{comfy_admin_cms_path}/ # match any CMS admin page
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,34 +1,33 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Commenting on a post' do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:post) { FactoryGirl.create(:post, :author => member) }
|
||||
|
||||
let(:member) { create :member }
|
||||
let(:post) { create :post, author: member }
|
||||
|
||||
background do
|
||||
login_as(member)
|
||||
visit new_comment_path(:post_id => post.id)
|
||||
login_as member
|
||||
visit new_comment_path post_id: post.id
|
||||
end
|
||||
|
||||
scenario "creating a comment" do
|
||||
fill_in "comment_body", :with => "This is a sample test for comment"
|
||||
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"
|
||||
expect(page).to have_content "Posted by"
|
||||
end
|
||||
|
||||
context "editing a comment" do
|
||||
let(:existing_comment) { FactoryGirl.create(:comment, :post => post, :author => member) }
|
||||
let(:existing_comment) { create :comment, post: post, author: member }
|
||||
|
||||
background do
|
||||
visit edit_comment_path(existing_comment)
|
||||
visit edit_comment_path existing_comment
|
||||
end
|
||||
|
||||
scenario "saving edit" do
|
||||
fill_in "comment_body", :with => "Testing edit for comment"
|
||||
click_button "Post comment"
|
||||
fill_in "comment_body", with: "Testing edit for comment"
|
||||
click_button "Post comment"
|
||||
expect(page).to have_content "Comment was successfully updated"
|
||||
expect(page).to have_content "Edited by"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Alternate names" do
|
||||
let!(:alternate_eggplant) { FactoryGirl.create(:alternate_eggplant) }
|
||||
let!(:alternate_eggplant) { create :alternate_eggplant }
|
||||
let(:crop) { alternate_eggplant.crop }
|
||||
|
||||
scenario "Display alternate names on crop page" do
|
||||
@@ -16,8 +16,8 @@ feature "Alternate names" do
|
||||
end
|
||||
|
||||
context "User is a crop wrangler" do
|
||||
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
|
||||
let(:member){crop_wranglers.first}
|
||||
let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
|
||||
let(:member) { crop_wranglers.first }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
@@ -28,7 +28,7 @@ feature "Alternate names" do
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to have_content "CROP WRANGLER"
|
||||
expect(page).to have_content alternate_eggplant.name
|
||||
expect(page).to have_link "Edit", :href => edit_alternate_name_path(alternate_eggplant)
|
||||
expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant)
|
||||
within('.alternate_names') { click_on "Edit" }
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
|
||||
@@ -42,7 +42,7 @@ feature "Alternate names" do
|
||||
scenario "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)
|
||||
href: alternate_name_path(alternate_eggplant)
|
||||
within('.alternate_names') { click_on "Delete" }
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to_not have_content alternate_eggplant.name
|
||||
@@ -52,7 +52,7 @@ feature "Alternate names" do
|
||||
scenario "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)
|
||||
href: new_alternate_name_path(crop_id: crop.id)
|
||||
within('.alternate_names') { click_on "Add" }
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
|
||||
@@ -70,17 +70,13 @@ feature "Alternate names" do
|
||||
end
|
||||
|
||||
context "When alternate name is rejected" do
|
||||
let(:rejected_crop) { FactoryGirl.create(:rejected_crop) }
|
||||
let(:pending_alt_name) { FactoryGirl.create(:alternate_name, :crop => rejected_crop) }
|
||||
let(:rejected_crop) { create :rejected_crop }
|
||||
let(:pending_alt_name) { create :alternate_name, crop: rejected_crop }
|
||||
|
||||
scenario "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
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,10 +2,10 @@ require 'rails_helper'
|
||||
|
||||
feature "browse crops" do
|
||||
|
||||
let(:tomato) { FactoryGirl.create(:tomato) }
|
||||
let(:maize) { FactoryGirl.create(:maize) }
|
||||
let(:pending_crop) { FactoryGirl.create(:crop_request) }
|
||||
let(:rejected_crop) { FactoryGirl.create(:rejected_crop) }
|
||||
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
|
||||
visit crops_path
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Crop - " do
|
||||
let!(:crop_wrangler) { FactoryGirl.create(:crop_wrangling_member)}
|
||||
let!(:member) { FactoryGirl.create(:member)}
|
||||
let!(:crop_wrangler) { create :crop_wrangling_member }
|
||||
let!(:member) { create :member }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
visit new_crop_path
|
||||
end
|
||||
|
||||
scenario "creating a crop with multiple scientific and alternate name", :js => true do
|
||||
scenario "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"
|
||||
@@ -27,10 +27,8 @@ feature "Crop - " do
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
save_and_open_page
|
||||
expect(page).to have_content "Crop was successfully requested."
|
||||
expect(page).to have_content "Jasminum sambac 2"
|
||||
expect(page).to have_content "Matsurika"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,11 +1,11 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "crop detail page" do
|
||||
|
||||
let(:crop) { FactoryGirl.create(:crop) }
|
||||
let(:crop) { create :crop }
|
||||
|
||||
subject { visit crop_path(crop) }
|
||||
|
||||
context "varieties" do
|
||||
|
||||
scenario "The crop DOES NOT have varieties" do
|
||||
visit crop_path(crop)
|
||||
|
||||
@@ -16,28 +16,27 @@ feature "crop detail page" do
|
||||
end
|
||||
|
||||
scenario "The crop has one variety" do
|
||||
roma1 = FactoryGirl.create(:crop, :name => 'Roma tomato 1', :parent => crop)
|
||||
create :crop, name: 'Roma tomato 1', parent: crop
|
||||
|
||||
visit crop_path(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)
|
||||
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) { FactoryGirl.create(:crop, :name => 'Roma tomato 1', :parent => crop) }
|
||||
let!(:roma2) { FactoryGirl.create(:crop, :name => 'Roma tomato 2', :parent => crop) }
|
||||
let!(:roma3) { FactoryGirl.create(:crop, :name => 'Roma tomato 3', :parent => crop) }
|
||||
let!(:roma4) { FactoryGirl.create(:crop, :name => 'Roma tomato 4', :parent => crop) }
|
||||
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
|
||||
|
||||
visit crop_path(crop)
|
||||
subject
|
||||
|
||||
within ".varieties" do
|
||||
# It lists all 5 items (note: including the top level item.)
|
||||
@@ -48,9 +47,9 @@ feature "crop detail page" do
|
||||
end
|
||||
|
||||
scenario "The crop has 5 varieties, including grandchild", :js => true do
|
||||
roma_child1 = FactoryGirl.create(:crop, :name => 'Roma tomato child 1', :parent => roma4)
|
||||
create :crop, name: 'Roma tomato child 1', parent: roma4
|
||||
|
||||
visit crop_path(crop)
|
||||
subject
|
||||
|
||||
within ".varieties" do
|
||||
|
||||
@@ -64,7 +63,7 @@ feature "crop detail page" do
|
||||
expect(page).to have_no_selector('button', text: /Show less+/i)
|
||||
|
||||
# Clik "Show all" link
|
||||
page.find('button', :text => /Show all+/).click
|
||||
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
|
||||
@@ -75,7 +74,7 @@ feature "crop detail page" do
|
||||
expect(page).to have_selector('button', text: /Show less+/i)
|
||||
|
||||
# Clik "Show less" link
|
||||
page.find('button', :text => /Show less+/).click
|
||||
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
|
||||
@@ -90,7 +89,7 @@ feature "crop detail page" do
|
||||
end
|
||||
|
||||
context "signed in member" do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:member) { create :member }
|
||||
|
||||
background do
|
||||
login_as(member)
|
||||
@@ -98,27 +97,23 @@ feature "crop detail page" do
|
||||
|
||||
context "action buttons" do
|
||||
|
||||
background do
|
||||
visit crop_path(crop)
|
||||
end
|
||||
background { subject }
|
||||
|
||||
scenario "has a link to plant the crop" do
|
||||
expect(page).to have_link "Plant this", :href => new_planting_path(:crop_id => crop.id)
|
||||
expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id)
|
||||
end
|
||||
scenario "has a link to harvest the crop" do
|
||||
expect(page).to have_link "Harvest this", :href => new_harvest_path(:crop_id => crop.id)
|
||||
expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id)
|
||||
end
|
||||
scenario "has a link to add seeds" do
|
||||
expect(page).to have_link "Add seeds to stash", :href => new_seed_path(:crop_id => crop.id)
|
||||
expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "SEO" do
|
||||
|
||||
background do
|
||||
visit crop_path(crop)
|
||||
end
|
||||
background { subject }
|
||||
|
||||
scenario "has seed heading with SEO" do
|
||||
expect(page).to have_content "Find #{ crop.name } seeds"
|
||||
@@ -145,8 +140,8 @@ feature "crop detail page" do
|
||||
end
|
||||
|
||||
context "seed quantity for a crop" do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:seed) { FactoryGirl.create(:seed, :crop => crop, :quantity => 20, :owner => member)}
|
||||
let(:member) { create :member }
|
||||
let(:seed) { create :seed, crop: crop, quantity: 20, owner: member }
|
||||
|
||||
scenario "User not signed in" do
|
||||
visit crop_path(seed.crop)
|
||||
@@ -166,7 +161,7 @@ feature "crop detail page" do
|
||||
login_as(member)
|
||||
visit crop_path(seed.crop)
|
||||
click_link "View your seeds"
|
||||
current_path.should == seeds_by_owner_path(:owner => member.slug)
|
||||
expect(current_path).to eq seeds_by_owner_path(owner: member.slug)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,16 +2,14 @@ require 'rails_helper'
|
||||
|
||||
feature "crop wranglers" do
|
||||
context "signed in wrangler" do
|
||||
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
|
||||
let(:wrangler){crop_wranglers.first}
|
||||
let!(:crops) { FactoryGirl.create_list(:crop, 2) }
|
||||
let!(:requested_crop) { FactoryGirl.create(:crop_request) }
|
||||
let!(:rejected_crop) { FactoryGirl.create(:rejected_crop) }
|
||||
let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
|
||||
let(:wrangler) { crop_wranglers.first }
|
||||
let!(:crops) { create_list :crop, 2 }
|
||||
let!(:requested_crop) { create :crop_request }
|
||||
let!(:rejected_crop) { create :rejected_crop }
|
||||
|
||||
background { login_as wrangler }
|
||||
|
||||
background do
|
||||
login_as(wrangler)
|
||||
end
|
||||
|
||||
scenario "sees crop wranglers listed on the crop wrangler page" do
|
||||
visit root_path
|
||||
click_link 'Crop Wrangling'
|
||||
@@ -19,11 +17,11 @@ feature "crop wranglers" do
|
||||
within '.crop_wranglers' do
|
||||
expect(page).to have_content 'Crop Wranglers:'
|
||||
crop_wranglers.each do |crop_wrangler|
|
||||
page.should have_link crop_wrangler.login_name, :href => member_path(crop_wrangler)
|
||||
expect(page).to have_link crop_wrangler.login_name, href: member_path(crop_wrangler)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
scenario "can see list of crops with extra detail of who created a crop" do
|
||||
visit root_path
|
||||
click_link 'Crop Wrangling'
|
||||
@@ -31,14 +29,14 @@ feature "crop wranglers" do
|
||||
expect(page).to have_content "#{crops.first.creator.login_name}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
scenario "visiting a crop can see wrangler links" do
|
||||
visit crop_path(crops.first)
|
||||
expect(page).to have_content 'You are a CROP WRANGLER'
|
||||
expect(page).to have_link 'Edit crop'
|
||||
expect(page).to have_link 'Delete crop'
|
||||
end
|
||||
|
||||
|
||||
scenario "can create a new crop" do
|
||||
visit root_path
|
||||
click_link 'Crop Wrangling'
|
||||
@@ -62,21 +60,18 @@ feature "crop wranglers" do
|
||||
expect(page).to have_content "This crop was rejected for the following reason: Totally fake"
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
context "signed in non-wrangler" do
|
||||
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
|
||||
background do
|
||||
login_as(member)
|
||||
end
|
||||
end
|
||||
|
||||
context "signed in non-wrangler" do
|
||||
let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
|
||||
let(:member) { create :member }
|
||||
|
||||
background { login_as member }
|
||||
|
||||
scenario "can't see wrangling page" do
|
||||
visit root_path
|
||||
expect(page).not_to have_link "Crop Wrangling"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,33 +1,28 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "crop wrangling button" do
|
||||
let(:crop_wrangler) { create :crop_wrangling_member }
|
||||
let(:member) { create :member }
|
||||
|
||||
let(:crop_wrangler) { FactoryGirl.create(:crop_wrangling_member) }
|
||||
|
||||
context "crop wrangling button" do
|
||||
|
||||
background do
|
||||
login_as(crop_wrangler)
|
||||
visit crops_path
|
||||
end
|
||||
|
||||
scenario "has a link to crop wrangling page" do
|
||||
expect(page).to have_link "Wrangle Crops", :href => wrangle_crops_path
|
||||
end
|
||||
|
||||
context "crop wrangling button" do
|
||||
background do
|
||||
login_as crop_wrangler
|
||||
visit crops_path
|
||||
end
|
||||
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
|
||||
context "crop wrangling button" do
|
||||
|
||||
background do
|
||||
login_as(member)
|
||||
visit crops_path
|
||||
end
|
||||
|
||||
scenario "has no link to crop wrangling page" do
|
||||
expect(page).to have_no_link "Wrangle Crops", :href => wrangle_crops_path
|
||||
end
|
||||
scenario "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
|
||||
login_as member
|
||||
visit crops_path
|
||||
end
|
||||
|
||||
scenario "has no link to crop wrangling page" do
|
||||
expect(page).to have_no_link "Wrangle Crops", href: wrangle_crops_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
feature "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.
|
||||
@@ -9,5 +8,4 @@ feature "irregular crop inflections" do
|
||||
expect("kale".pluralize).to eq "kale"
|
||||
expect("broccoli".pluralize).to eq "broccoli"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Requesting a new crop" do
|
||||
|
||||
context "As a regular member" do
|
||||
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let!(:wrangler) { FactoryGirl.create(:crop_wrangling_member) }
|
||||
let(:member) { create :member }
|
||||
let!(:wrangler) { create :crop_wrangling_member }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
@@ -18,23 +16,18 @@ feature "Requesting a new crop" do
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Crop was successfully requested."
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "As a crop wrangler" do
|
||||
let(:wrangler) { create :crop_wrangling_member }
|
||||
let!(:crop) { create :crop_request }
|
||||
let!(:already_approved) { create :crop }
|
||||
|
||||
let(:wrangler) { FactoryGirl.create(:crop_wrangling_member) }
|
||||
let!(:crop) { FactoryGirl.create(:crop_request) }
|
||||
let!(:already_approved) { FactoryGirl.create(:crop) }
|
||||
|
||||
background do
|
||||
login_as wrangler
|
||||
end
|
||||
background { login_as wrangler }
|
||||
|
||||
scenario "Approve a request" do
|
||||
visit edit_crop_path(crop)
|
||||
select "approved", from: "Approval status"
|
||||
save_and_open_page
|
||||
click_button "Save"
|
||||
expect(page).to have_content "En wikipedia url is not a valid English Wikipedia URL"
|
||||
fill_in "en_wikipedia_url", with: "http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi"
|
||||
@@ -49,7 +42,5 @@ feature "Requesting a new crop" do
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Crop was successfully updated."
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "follows", :js => true do
|
||||
|
||||
feature "follows", :js do
|
||||
context "when signed out" do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:member) { create :member }
|
||||
|
||||
scenario "follow buttons on member profile page" do
|
||||
visit member_path(member)
|
||||
@@ -13,8 +12,8 @@ feature "follows", :js => true do
|
||||
end
|
||||
|
||||
context "when signed in" do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:other_member) { FactoryGirl.create(:member) }
|
||||
let(:member) { create :member }
|
||||
let(:other_member) { create :member }
|
||||
|
||||
background do
|
||||
login_as(member)
|
||||
@@ -32,13 +31,13 @@ feature "follows", :js => true do
|
||||
end
|
||||
|
||||
scenario "has a follow button" do
|
||||
expect(page).to have_link "Follow", :href => follows_path(:followed_id => other_member.id)
|
||||
expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id)
|
||||
end
|
||||
|
||||
scenario "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))
|
||||
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
|
||||
@@ -48,9 +47,7 @@ feature "follows", :js => true do
|
||||
end
|
||||
|
||||
scenario "does not die when passed an authenticity_token" do
|
||||
visit member_follows_path(
|
||||
member,
|
||||
:params => {:authenticity_token => "Ultima ratio regum"})
|
||||
visit member_follows_path member, params: { authenticity_token: "Ultima ratio regum" }
|
||||
expect(page.status_code).to equal 200
|
||||
end
|
||||
|
||||
@@ -59,7 +56,7 @@ feature "follows", :js => true do
|
||||
click_link 'Unfollow'
|
||||
expect(page).to have_content "Unfollowed #{other_member.login_name}"
|
||||
visit member_path(other_member) # unfollowing redirects to root
|
||||
expect(page).to have_link "Follow", :href => follows_path(:followed_id => other_member.id)
|
||||
expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id)
|
||||
end
|
||||
|
||||
scenario "has member in following list" do
|
||||
@@ -82,8 +79,6 @@ feature "follows", :js => true do
|
||||
visit member_followers_path(other_member)
|
||||
expect(page).to have_content "#{member.login_name}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,11 +2,16 @@ require 'rails_helper'
|
||||
|
||||
feature "footer" do
|
||||
|
||||
before { visit root_path }
|
||||
|
||||
scenario "footer is on home page" do
|
||||
visit root_path
|
||||
expect(page).to have_css 'footer'
|
||||
end
|
||||
|
||||
it 'has the Open Service link and graphic' do
|
||||
expect(page).to have_selector 'a[href="http://opendefinition.org/ossd/"]'
|
||||
end
|
||||
|
||||
# NB: not testing specific content in the footer since I'm going to put them
|
||||
# in the CMS and they'll be variable.
|
||||
end
|
||||
|
||||
37
spec/features/gardens/adding_gardens_spec.rb
Normal file
37
spec/features/gardens/adding_gardens_spec.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Gardens", :js do
|
||||
let(:member) { FactoryGirl.create :member }
|
||||
|
||||
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_selector 'textarea#garden_description[placeholder="optional"]'
|
||||
expect(page).to have_selector 'input#garden_location[placeholder="optional"]'
|
||||
expect(page).to have_selector 'input#garden_area[placeholder="optional"]'
|
||||
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,13 +1,13 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Planting a crop", :js => true do
|
||||
let!(:garden) { FactoryGirl.create(:garden) }
|
||||
let!(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) }
|
||||
let!(:tomato) { FactoryGirl.create(:tomato) }
|
||||
let!(:finished_planting) { FactoryGirl.create(:finished_planting, garden: garden, crop: tomato) }
|
||||
let!(:garden) { create :garden }
|
||||
let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") }
|
||||
let!(:tomato) { create :tomato }
|
||||
let!(:finished_planting) { create :finished_planting, garden: garden, crop: tomato }
|
||||
|
||||
background do
|
||||
login_as(garden.owner)
|
||||
login_as garden.owner
|
||||
end
|
||||
|
||||
scenario "View gardens" do
|
||||
@@ -30,7 +30,7 @@ feature "Planting a crop", :js => true do
|
||||
|
||||
scenario "Create new garden" do
|
||||
visit new_garden_path
|
||||
fill_in "Name", :with => "New garden"
|
||||
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"
|
||||
@@ -38,19 +38,31 @@ feature "Planting a crop", :js => true do
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
context "Clicking edit from the index page" do
|
||||
|
||||
background do
|
||||
visit gardens_path
|
||||
end
|
||||
|
||||
scenario "button on index to edit garden" do
|
||||
first(".panel-title").click_link("edit_garden_glyphicon")
|
||||
expect(page).to have_content 'Edit garden'
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Edit garden" do
|
||||
visit new_garden_path
|
||||
fill_in "Name", :with => "New garden"
|
||||
fill_in "Name", with: "New garden"
|
||||
click_button "Save"
|
||||
click_link "Edit garden"
|
||||
fill_in "Name", :with => "Different name"
|
||||
fill_in "Name", with: "Different name"
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Garden was successfully updated"
|
||||
expect(page).to have_content "Different name"
|
||||
@@ -58,7 +70,7 @@ feature "Planting a crop", :js => true do
|
||||
|
||||
scenario "Delete garden" do
|
||||
visit new_garden_path
|
||||
fill_in "Name", :with => "New garden"
|
||||
fill_in "Name", with: "New garden"
|
||||
click_button "Save"
|
||||
visit garden_path(Garden.last)
|
||||
click_link "Delete garden"
|
||||
@@ -67,7 +79,7 @@ feature "Planting a crop", :js => true do
|
||||
end
|
||||
|
||||
describe "Making a planting inactive from garden show" do
|
||||
let(:path) { garden_path(garden) }
|
||||
let(:path) { garden_path garden }
|
||||
let(:link_text) { "Mark as finished" }
|
||||
it_behaves_like "append date"
|
||||
end
|
||||
@@ -76,5 +88,4 @@ feature "Planting a crop", :js => true do
|
||||
visit gardens_path
|
||||
expect(page).not_to have_content finished_planting.crop_name
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,35 +1,60 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Harvesting a crop", :js => true do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let!(:maize) { FactoryGirl.create(:maize) }
|
||||
feature "Harvesting a crop", :js do
|
||||
let(:member) { create :member }
|
||||
let!(:maize) { create :maize }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
visit new_harvest_path
|
||||
sync_elasticsearch([maize])
|
||||
sync_elasticsearch [maize]
|
||||
end
|
||||
|
||||
it_behaves_like "crop suggest", "harvest", "crop"
|
||||
|
||||
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: "What did you harvest?"
|
||||
expect(page).to have_selector 'input#harvest_quantity[placeholder="optional"]'
|
||||
expect(page).to have_selector 'input#harvest_weight_quantity[placeholder="optional"]'
|
||||
expect(page).to have_selector 'textarea#harvest_description[placeholder="optional"]'
|
||||
end
|
||||
|
||||
scenario "Creating a new harvest", :js => true do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_harvest" do
|
||||
fill_in "When?", :with => "2014-06-15"
|
||||
fill_in "How many?", :with => 42
|
||||
fill_in "Weighing (in total):", :with => 42
|
||||
fill_in "Notes", :with => "It's killer."
|
||||
fill_in "When?", with: "2014-06-15"
|
||||
fill_in "How many?", with: 42
|
||||
fill_in "Weighing (in total):", with: 42
|
||||
fill_in "Notes", with: "It's killer."
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Harvest was successfully created"
|
||||
end
|
||||
|
||||
context "Clicking edit from the index page" do
|
||||
let!(:harvest) { FactoryGirl.create(:harvest, :crop => maize, :owner => member) }
|
||||
|
||||
background do
|
||||
visit harvests_path
|
||||
end
|
||||
|
||||
scenario "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
|
||||
visit harvests_by_owner_path(member)
|
||||
click_link "View #{member}'s profile >>"
|
||||
current_path.should eq member_path(member)
|
||||
expect(current_path).to eq member_path member
|
||||
end
|
||||
|
||||
scenario "Harvesting from crop page" do
|
||||
@@ -45,7 +70,7 @@ feature "Harvesting a crop", :js => true do
|
||||
end
|
||||
|
||||
context "Editing a harvest" do
|
||||
let(:existing_harvest) { FactoryGirl.create(:harvest, :crop => maize, :owner => member) }
|
||||
let(:existing_harvest) { create :harvest, crop: maize, owner: member }
|
||||
|
||||
background do
|
||||
visit harvest_path(existing_harvest)
|
||||
@@ -59,8 +84,5 @@ feature "Harvesting a crop", :js => true do
|
||||
expect(page).to have_content "Harvest was successfully updated"
|
||||
expect(page).to have_content "maize"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -2,15 +2,12 @@ require 'rails_helper'
|
||||
|
||||
feature "Changing locales" do
|
||||
|
||||
after do
|
||||
I18n.locale = :en
|
||||
end
|
||||
after { I18n.locale = :en }
|
||||
|
||||
scenario "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')
|
||||
visit root_path(locale: 'ja')
|
||||
expect(page).to have_content("はガーデナーのコミュニティです。")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "member profile" do
|
||||
|
||||
context "signed out member" do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:member) { create :member }
|
||||
|
||||
scenario "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_css("h1", text: member.login_name)
|
||||
expect(page).to have_content member.bio
|
||||
expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}"
|
||||
expect(page).to have_content "Account type: Free account"
|
||||
expect(page).to have_content "#{member.login_name}'s gardens"
|
||||
expect(page).to have_link "More about this garden...", :href => garden_path(member.gardens.first)
|
||||
expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first)
|
||||
end
|
||||
|
||||
scenario "no bio" do
|
||||
@@ -29,9 +28,9 @@ feature "member profile" do
|
||||
|
||||
context "location" do
|
||||
scenario "member has set location" do
|
||||
london_member = FactoryGirl.create(:london_member)
|
||||
london_member = create :london_member
|
||||
visit member_path(london_member)
|
||||
expect(page).to have_css("h1>small", :text => london_member.location)
|
||||
expect(page).to have_css("h1>small", text: london_member.location)
|
||||
expect(page).to have_css("#membermap")
|
||||
expect(page).to have_content "See other members near #{london_member.location}"
|
||||
end
|
||||
@@ -47,7 +46,7 @@ feature "member profile" do
|
||||
|
||||
context "email privacy" do
|
||||
scenario "public email address" do
|
||||
public_member = FactoryGirl.create(:public_member)
|
||||
public_member = create :public_member
|
||||
visit member_path(public_member)
|
||||
expect(page).to have_content public_member.email
|
||||
end
|
||||
@@ -59,7 +58,7 @@ feature "member profile" do
|
||||
|
||||
context "email privacy" do
|
||||
scenario "public email address" do
|
||||
public_member = FactoryGirl.create(:public_member)
|
||||
public_member = create :public_member
|
||||
visit member_path(public_member)
|
||||
expect(page).to have_content public_member.email
|
||||
end
|
||||
@@ -81,36 +80,35 @@ feature "member profile" do
|
||||
end
|
||||
|
||||
scenario "with some activity" do
|
||||
FactoryGirl.create_list(:planting, 2, :owner => member)
|
||||
FactoryGirl.create_list(:harvest, 3, :owner => member)
|
||||
FactoryGirl.create_list(:seed, 4, :owner => member)
|
||||
FactoryGirl.create_list(:post, 5, :author => member)
|
||||
create_list :planting, 2, owner: member
|
||||
create_list :harvest, 3, owner: member
|
||||
create_list :seed, 4, owner: member
|
||||
create_list :post, 5, author: member
|
||||
visit member_path(member)
|
||||
expect(page).to have_link "2 plantings", :href => plantings_by_owner_path(:owner => member)
|
||||
expect(page).to have_link "3 harvests", :href => harvests_by_owner_path(:owner => member)
|
||||
expect(page).to have_link "4 seeds", :href => seeds_by_owner_path(:owner => member)
|
||||
expect(page).to have_link "5 posts", :href => posts_by_author_path(:author => member)
|
||||
expect(page).to have_link "2 plantings", href: plantings_by_owner_path(owner: member)
|
||||
expect(page).to have_link "3 harvests", href: harvests_by_owner_path(owner: member)
|
||||
expect(page).to have_link "4 seeds", href: seeds_by_owner_path(owner: member)
|
||||
expect(page).to have_link "5 posts", href: posts_by_author_path(author: member)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
scenario "twitter link" do
|
||||
twitter_auth = FactoryGirl.create(:authentication, :member => member)
|
||||
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}"
|
||||
expect(page).to have_link twitter_auth.name, href: "http://twitter.com/#{twitter_auth.name}"
|
||||
end
|
||||
|
||||
scenario "flickr link" do
|
||||
flickr_auth = FactoryGirl.create(:flickr_authentication, :member => member)
|
||||
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}"
|
||||
expect(page).to have_link flickr_auth.name, href: "http://flickr.com/photos/#{flickr_auth.uid}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "signed in member" do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:other_member) { FactoryGirl.create(:member) }
|
||||
let(:member) { create :member }
|
||||
let(:other_member) { create :member }
|
||||
|
||||
background do
|
||||
login_as(member)
|
||||
@@ -122,17 +120,16 @@ feature "member profile" do
|
||||
end
|
||||
|
||||
scenario "has a link to create new garden" do
|
||||
expect(page).to have_link "New Garden", :href => new_garden_path
|
||||
expect(page).to have_link "New Garden", href: new_garden_path
|
||||
end
|
||||
|
||||
scenario "has a button to edit profile" do
|
||||
expect(page).to have_link "Edit profile", :href => edit_member_registration_path
|
||||
expect(page).to have_link "Edit profile", href: edit_member_registration_path
|
||||
end
|
||||
|
||||
scenario "has a button to upgrade account" do
|
||||
expect(page).to have_link "Upgrade account", :href => shop_path
|
||||
expect(page).to have_link "Upgrade account", href: shop_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "someone else's profile page" do
|
||||
@@ -141,9 +138,8 @@ feature "member profile" do
|
||||
end
|
||||
|
||||
scenario "has a private message button" do
|
||||
expect(page).to have_link "Send message", :href => new_notification_path(:recipient_id => other_member.id)
|
||||
expect(page).to have_link "Send message", href: new_notification_path(:recipient_id => other_member.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "home page" do
|
||||
@@ -152,9 +148,8 @@ feature "member profile" do
|
||||
end
|
||||
|
||||
scenario "does not have a button to edit profile" do
|
||||
expect(page).to_not have_link "Edit profile", :href => edit_member_registration_path
|
||||
expect(page).to_not have_link "Edit profile", href: edit_member_registration_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "members list" do
|
||||
|
||||
context "list all members" do
|
||||
let! (:member1) { FactoryGirl.create(:member, :login_name => "Archaeopteryx", :confirmed_at => Time.zone.parse('2013-02-10')) }
|
||||
let! (:member2) { FactoryGirl.create(:member, :login_name => "Zephyrosaurus", :confirmed_at => Time.zone.parse('2014-01-11')) }
|
||||
let! (:member3) { FactoryGirl.create(:member, :login_name => "Testingname", :confirmed_at => Time.zone.parse('2014-05-09')) }
|
||||
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
|
||||
visit members_path
|
||||
@@ -26,10 +25,6 @@ feature "members list" do
|
||||
all_links = page.all("#maincontainer p")
|
||||
expect(all_links.first).to have_text member3.login_name
|
||||
expect(all_links.last).to have_text member1.login_name
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,14 +1,20 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Notifications", :js => true do
|
||||
let(:sender) { FactoryGirl.create(:member) }
|
||||
let(:recipient) { FactoryGirl.create(:member) }
|
||||
|
||||
feature "Notifications", :js do
|
||||
let(:sender) { create :member }
|
||||
let(:recipient) { create :member }
|
||||
|
||||
context "On existing notification" do
|
||||
let!(:notification) { FactoryGirl.create(:notification, sender: sender, recipient: recipient, body: "Notification body", :post_id => nil) }
|
||||
let!(:notification) {
|
||||
create :notification,
|
||||
sender: sender,
|
||||
recipient: recipient,
|
||||
body: "Notification body",
|
||||
post_id: nil
|
||||
}
|
||||
|
||||
background do
|
||||
login_as(recipient)
|
||||
login_as recipient
|
||||
visit notification_path(notification)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,48 +1,42 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "show photo page" do
|
||||
|
||||
let (:photo) { FactoryGirl.create(:photo) }
|
||||
let(:photo) { create :photo }
|
||||
|
||||
context "signed in member" do
|
||||
let (:member) { FactoryGirl.create(:member) }
|
||||
let(:member) { create :member }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
end
|
||||
background { login_as member }
|
||||
|
||||
context "linked to planting" do
|
||||
let (:planting) { FactoryGirl.create(:planting) }
|
||||
let(:planting) { create :planting }
|
||||
|
||||
scenario "shows linkback to planting" do
|
||||
planting.photos << photo
|
||||
visit photo_path(photo)
|
||||
expect(page).to have_link planting, :href => planting_path(planting)
|
||||
expect(page).to have_link planting, href: planting_path(planting)
|
||||
end
|
||||
end
|
||||
|
||||
context "linked to harvest" do
|
||||
let (:harvest) { FactoryGirl.create(:harvest) }
|
||||
let(:harvest) { create :harvest }
|
||||
|
||||
scenario "shows linkback to harvest" do
|
||||
harvest.photos << photo
|
||||
visit photo_path(photo)
|
||||
expect(page).to have_link harvest, :href => harvest_path(harvest)
|
||||
expect(page).to have_link harvest, href: harvest_path(harvest)
|
||||
end
|
||||
end
|
||||
|
||||
context "linked to garden" do
|
||||
let (:garden) { FactoryGirl.create(:garden) }
|
||||
let(:garden) { create :garden }
|
||||
|
||||
scenario "shows linkback to garden" do
|
||||
garden.photos << photo
|
||||
visit photo_path(photo)
|
||||
expect(page).to have_link garden, :href => garden_path(garden)
|
||||
expect(page).to have_link garden, href: garden_path(garden)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,64 +1,61 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.feature "User searches", :type => :feature do
|
||||
let(:member) { FactoryGirl.create(:member, location: "Philippines") }
|
||||
let!(:maize) { FactoryGirl.create(:maize) }
|
||||
let(:garden) { FactoryGirl.create(:garden, owner: member) }
|
||||
let!(:seed1) { FactoryGirl.create(:seed, owner: member) }
|
||||
let!(:planting){ FactoryGirl.create(:planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10")) }
|
||||
feature "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
|
||||
visit places_path
|
||||
search_with("Philippines")
|
||||
expect(page).to have_content "members near Philippines"
|
||||
expect(page).to have_button "search_button"
|
||||
page.has_content?('placesmap')
|
||||
expect(page).to have_content "Nearby members"
|
||||
expect(page).to_not have_content "No results found"
|
||||
end
|
||||
scenario "with a valid place" do
|
||||
visit places_path
|
||||
search_with "Philippines"
|
||||
expect(page).to have_content "members near Philippines"
|
||||
expect(page).to have_button "search_button"
|
||||
expect(page).to have_content "Nearby members"
|
||||
expect(page).to_not have_content "No results found"
|
||||
end
|
||||
|
||||
scenario "with a blank search string" do
|
||||
visit places_path
|
||||
search_with("")
|
||||
expect(page).to have_content "Please enter a valid location"
|
||||
expect(page).to have_button "search_button"
|
||||
page.has_content?('placesmap')
|
||||
end
|
||||
scenario "with a blank search string" do
|
||||
visit places_path
|
||||
search_with ""
|
||||
expect(page).to have_content "Please enter a valid location"
|
||||
expect(page).to have_button "search_button"
|
||||
end
|
||||
|
||||
describe "Nearby plantings, seed, and members" do
|
||||
before(:each) do
|
||||
login_as(member)
|
||||
visit places_path
|
||||
search_with("Philippines")
|
||||
end
|
||||
describe "Nearby plantings, seed, and members" do
|
||||
before do
|
||||
login_as member
|
||||
visit places_path
|
||||
search_with "Philippines"
|
||||
end
|
||||
|
||||
it "should show that there are nearby seeds, plantings, and members" do
|
||||
expect(page).to have_content "Nearby members"
|
||||
expect(page).to have_content "Seeds available for trade near Philippines"
|
||||
expect(page).to have_content "Recent plantings near Philippines"
|
||||
find_link("View all members").visible?
|
||||
find_link("View all seeds").visible?
|
||||
find_link("View all plantings").visible?
|
||||
end
|
||||
it "should show that there are nearby seeds, plantings, and members" do
|
||||
expect(page).to have_content "Nearby members"
|
||||
expect(page).to have_content "Seeds available for trade near Philippines"
|
||||
expect(page).to have_content "Recent plantings near Philippines"
|
||||
end
|
||||
|
||||
it "should go to members' index page" do
|
||||
click_link('View all members >>')
|
||||
current_path.should == members_path
|
||||
end
|
||||
it "should go to members' index page" do
|
||||
click_link 'View all members >>'
|
||||
expect(current_path).to eq members_path
|
||||
end
|
||||
|
||||
it "should go to plantings' index page" do
|
||||
click_link('View all plantings >>')
|
||||
current_path.should == plantings_path
|
||||
end
|
||||
it "should go to plantings' index page" do
|
||||
click_link 'View all plantings >>'
|
||||
expect(current_path).to eq plantings_path
|
||||
end
|
||||
|
||||
it "should go to seeds' index page" do
|
||||
click_link('View all seeds >>')
|
||||
current_path.should == seeds_path
|
||||
end
|
||||
end
|
||||
it "should go to seeds' index page" do
|
||||
click_link 'View all seeds >>'
|
||||
expect(current_path).to eq seeds_path
|
||||
end
|
||||
end
|
||||
|
||||
def search_with(search_string)
|
||||
fill_in "new_place", :with => search_string
|
||||
click_button "search_button"
|
||||
end
|
||||
private
|
||||
|
||||
def search_with(search_string)
|
||||
fill_in "new_place", with: search_string
|
||||
click_button "search_button"
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require 'capybara/email/rspec'
|
||||
|
||||
feature "Planting reminder email", :js => true do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
feature "Planting reminder email", :js do
|
||||
let(:member) { create :member }
|
||||
let(:mail) { Notifier.planting_reminder(member) }
|
||||
|
||||
# Unfortunately, we can't use the default url options for ActionMailer as configured in
|
||||
@@ -23,25 +23,18 @@ feature "Planting reminder email", :js => true do
|
||||
scenario "doesn't list plantings" do
|
||||
expect(mail).not_to have_content "most recent plantings you've told us about"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "when member has some plantings" do
|
||||
before :each do
|
||||
@p1 = FactoryGirl.create(:planting,
|
||||
:garden => member.gardens.first,
|
||||
:owner => member
|
||||
)
|
||||
@p2 = FactoryGirl.create(:planting,
|
||||
:garden => member.gardens.first,
|
||||
:owner => member
|
||||
)
|
||||
end
|
||||
# Bangs are used on the following 2 let blocks in order to ensure that the plantings are present
|
||||
# in the database before the email is generated: otherwise, they won't be present in the email.
|
||||
let!(:p1) { create :planting, garden: member.gardens.first, owner: member }
|
||||
let!(:p2) { create :planting, garden: member.gardens.first, owner: member }
|
||||
|
||||
scenario "lists plantings" do
|
||||
expect(mail).to have_content "most recent plantings you've told us about"
|
||||
expect(mail).to have_link @p1.to_s, planting_url(@p1)
|
||||
expect(mail).to have_link @p2.to_s, planting_url(@p2)
|
||||
expect(mail).to have_link p1.to_s, planting_url(p1)
|
||||
expect(mail).to have_link p2.to_s, planting_url(p2)
|
||||
expect(mail).to have_content "keep your garden records up to date"
|
||||
end
|
||||
end
|
||||
@@ -54,26 +47,19 @@ feature "Planting reminder email", :js => true do
|
||||
scenario "doesn't list plantings" do
|
||||
expect(mail).not_to have_content "the last few things you harvested were"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "when member has some harvests" do
|
||||
before :each do
|
||||
@h1 = FactoryGirl.create(:harvest,
|
||||
:owner => member
|
||||
)
|
||||
@h2 = FactoryGirl.create(:harvest,
|
||||
:owner => member
|
||||
)
|
||||
end
|
||||
# Bangs are used on the following 2 let blocks in order to ensure that the plantings are present
|
||||
# in the database before the spec is run.
|
||||
let!(:h1) { create :harvest, owner: member }
|
||||
let!(:h2) { create :harvest, owner: member }
|
||||
|
||||
scenario "lists harvests" do
|
||||
expect(mail).to have_content "the last few things you harvested were"
|
||||
expect(mail).to have_link @h1.to_s, harvest_url(@h1)
|
||||
expect(mail).to have_link @h2.to_s, harvest_url(@h2)
|
||||
expect(mail).to have_link h1.to_s, harvest_url(h1)
|
||||
expect(mail).to have_link h2.to_s, harvest_url(h2)
|
||||
expect(mail).to have_content "Harvested anything else lately?"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,28 +1,43 @@
|
||||
require "rails_helper"
|
||||
|
||||
feature "Planting a crop", :js => true do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let!(:maize) { FactoryGirl.create(:maize) }
|
||||
let(:garden) { FactoryGirl.create(:garden, owner: member) }
|
||||
let!(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) }
|
||||
feature "Planting a crop", :js do
|
||||
let(:member) { create :member }
|
||||
let!(:maize) { create :maize }
|
||||
let(:garden) { create :garden, owner: member }
|
||||
let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
visit new_planting_path
|
||||
sync_elasticsearch([maize])
|
||||
sync_elasticsearch [maize]
|
||||
end
|
||||
|
||||
it_behaves_like "crop suggest", "planting"
|
||||
|
||||
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: "What did you plant?"
|
||||
expect(page).to have_selector ".form-group.required", text: "Where did you plant it?"
|
||||
expect(page).to have_selector 'input#planting_planted_at[placeholder="optional"]'
|
||||
expect(page).to have_selector 'input#planting_quantity[placeholder="optional"]'
|
||||
expect(page).to have_selector 'select#planting_planted_from option', text: 'optional'
|
||||
expect(page).to have_selector 'select#planting_sunniness option', text: 'optional'
|
||||
expect(page).to have_selector 'textarea#planting_description[placeholder="optional"]'
|
||||
expect(page).to have_selector 'input#planting_finished_at[placeholder="optional"]'
|
||||
end
|
||||
|
||||
scenario "Creating a new planting" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", :with => "2014-06-15"
|
||||
fill_in "How many?", :with => 42
|
||||
select "cutting", :from => "Planted from:"
|
||||
select "semi-shade", :from => "Sun or shade?"
|
||||
fill_in "Tell us more about it", :with => "It's rad."
|
||||
fill_in "When", with: "2014-06-15"
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from:"
|
||||
select "semi-shade", from: "Sun or shade?"
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
@@ -33,26 +48,25 @@ feature "Planting a crop", :js => true do
|
||||
scenario "Clicking link to owner's profile" do
|
||||
visit plantings_by_owner_path(member)
|
||||
click_link "View #{member}'s profile >>"
|
||||
current_path.should eq member_path(member)
|
||||
expect(current_path).to eq member_path(member)
|
||||
end
|
||||
|
||||
describe "Progress bar status on planting creation" do
|
||||
before(:each) do
|
||||
DateTime.stub(:now){DateTime.new(2015, 10, 20, 10, 34)}
|
||||
login_as(member)
|
||||
before do
|
||||
DateTime.stub(:now) { DateTime.new(2015, 10, 20, 10, 34) }
|
||||
login_as member
|
||||
visit new_planting_path
|
||||
sync_elasticsearch([maize])
|
||||
end
|
||||
|
||||
it "should show that it is not planted yet" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", :with => "2015-12-15"
|
||||
fill_in "How many?", :with => 42
|
||||
select "cutting", :from => "Planted from:"
|
||||
select "semi-shade", :from => "Sun or shade?"
|
||||
fill_in "Tell us more about it", :with => "It's rad."
|
||||
fill_in "When", with: "2015-12-15"
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from:"
|
||||
select "semi-shade", from: "Sun or shade?"
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
@@ -61,14 +75,14 @@ feature "Planting a crop", :js => true do
|
||||
end
|
||||
|
||||
it "should show that days before maturity is unknown" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", :with => "2015-9-15"
|
||||
fill_in "How many?", :with => 42
|
||||
select "cutting", :from => "Planted from:"
|
||||
select "semi-shade", :from => "Sun or shade?"
|
||||
fill_in "Tell us more about it", :with => "It's rad."
|
||||
fill_in "When", with: "2015-9-15"
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from:"
|
||||
select "semi-shade", from: "Sun or shade?"
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
@@ -78,15 +92,15 @@ feature "Planting a crop", :js => true do
|
||||
end
|
||||
|
||||
it "should show that planting is in progress" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", :with => "2015-10-15"
|
||||
fill_in "How many?", :with => 42
|
||||
select "cutting", :from => "Planted from:"
|
||||
select "semi-shade", :from => "Sun or shade?"
|
||||
fill_in "Tell us more about it", :with => "It's rad."
|
||||
fill_in "Finished date", :with => "2015-10-30"
|
||||
fill_in "When", with: "2015-10-15"
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from:"
|
||||
select "semi-shade", from: "Sun or shade?"
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
fill_in "Finished date", with: "2015-10-30"
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
@@ -96,14 +110,14 @@ feature "Planting a crop", :js => true do
|
||||
end
|
||||
|
||||
it "should show that planting is 100% complete (no date specified)" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", :with => "2015-10-15"
|
||||
fill_in "How many?", :with => 42
|
||||
select "cutting", :from => "Planted from:"
|
||||
select "semi-shade", :from => "Sun or shade?"
|
||||
fill_in "Tell us more about it", :with => "It's rad."
|
||||
fill_in "When", with: "2015-10-15"
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from:"
|
||||
select "semi-shade", from: "Sun or shade?"
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
check "Mark as finished"
|
||||
click_button "Save"
|
||||
end
|
||||
@@ -115,15 +129,15 @@ feature "Planting a crop", :js => true do
|
||||
end
|
||||
|
||||
it "should show that planting is 100% complete (date specified)" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", :with => "2015-10-15"
|
||||
fill_in "How many?", :with => 42
|
||||
select "cutting", :from => "Planted from:"
|
||||
select "semi-shade", :from => "Sun or shade?"
|
||||
fill_in "Tell us more about it", :with => "It's rad."
|
||||
fill_in "Finished date", :with => "2015-10-19"
|
||||
fill_in "When", with: "2015-10-15"
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from:"
|
||||
select "semi-shade", from: "Sun or shade?"
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
fill_in "Finished date", with: "2015-10-19"
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
@@ -144,11 +158,11 @@ feature "Planting a crop", :js => true do
|
||||
expect(page).to have_content "Planting was successfully created"
|
||||
expect(page).to have_content "maize"
|
||||
end
|
||||
|
||||
|
||||
scenario "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"
|
||||
fill_in "Tell us more about it", with: "Some extra notes"
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Planting was successfully updated"
|
||||
end
|
||||
@@ -158,37 +172,37 @@ feature "Planting a crop", :js => true do
|
||||
expect(page).to have_content "Progress: 0% - Days before maturity unknown"
|
||||
click_link "Edit"
|
||||
check "finished"
|
||||
fill_in "Finished date", :with => "2015-06-25"
|
||||
fill_in "Finished date", with: "2015-06-25"
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Planting was successfully updated"
|
||||
expect(page).to_not have_content "Progress: 0% - Days before maturity unknown"
|
||||
end
|
||||
|
||||
scenario "Marking a planting as finished" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When?", :with => "2014-07-01"
|
||||
fill_in "When?", with: "2014-07-01"
|
||||
check "Mark as finished"
|
||||
fill_in "Finished date", :with => "2014-08-30"
|
||||
fill_in "Finished date", with: "2014-08-30"
|
||||
|
||||
# Trigger click instead of using Capybara"s uncheck
|
||||
# because a date selection widget is overlapping
|
||||
# the checkbox preventing interaction.
|
||||
page.find("#planting_finished").trigger("click")
|
||||
find("#planting_finished").trigger 'click'
|
||||
end
|
||||
|
||||
# Javascript removes the finished at date when the
|
||||
# planting is marked unfinished.
|
||||
expect(page.find("#planting_finished_at").value).to eq("")
|
||||
expect(find("#planting_finished_at").value).to eq("")
|
||||
|
||||
within "form#new_planting" do
|
||||
page.find("#planting_finished").trigger("click")
|
||||
find("#planting_finished").trigger 'click'
|
||||
end
|
||||
|
||||
# The finished at date was cached in Javascript in
|
||||
# case the user clicks unfinished accidentally.
|
||||
expect(page.find("#planting_finished_at").value).to eq("2014-08-30")
|
||||
expect(find("#planting_finished_at").value).to eq("2014-08-30")
|
||||
|
||||
within "form#new_planting" do
|
||||
click_button "Save"
|
||||
@@ -201,7 +215,7 @@ feature "Planting a crop", :js => true do
|
||||
end
|
||||
|
||||
scenario "Marking a planting as finished without a date" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
check "Mark as finished"
|
||||
@@ -214,50 +228,50 @@ feature "Planting a crop", :js => true do
|
||||
|
||||
describe "Planting sunniness" do
|
||||
it "should show the image sunniness_sun.png" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", :with => "2015-10-15"
|
||||
fill_in "How many?", :with => 42
|
||||
select "cutting", :from => "Planted from:"
|
||||
select "sun", :from => "Sun or shade?"
|
||||
fill_in "Tell us more about it", :with => "It's rad."
|
||||
fill_in "When", with: "2015-10-15"
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from:"
|
||||
select "sun", from: "Sun or shade?"
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
check "Mark as finished"
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_css("img[src*='sunniness_sun.png']")
|
||||
page.should have_css("img[alt=sun]")
|
||||
expect(page).to have_css("img[alt=sun]")
|
||||
end
|
||||
|
||||
it "should show the image 'not specified.png'" do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", :with => "2015-10-15"
|
||||
fill_in "How many?", :with => 42
|
||||
select "cutting", :from => "Planted from:"
|
||||
fill_in "Tell us more about it", :with => "It's rad."
|
||||
fill_in "When", with: "2015-10-15"
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from:"
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
check "Mark as finished"
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_css("img[src*='sunniness_not specified.png']")
|
||||
page.should have_css("img[alt='not specified']")
|
||||
expect(page).to have_css("img[alt='not specified']")
|
||||
end
|
||||
end
|
||||
|
||||
describe "Marking a planting as finished from the show page" do
|
||||
let(:path) { planting_path(planting) }
|
||||
let(:path) { planting_path(planting) }
|
||||
let(:link_text) { "Mark as finished" }
|
||||
it_behaves_like "append date"
|
||||
end
|
||||
|
||||
describe "Marking a planting as finished from the list page" do
|
||||
let(:path) { plantings_path }
|
||||
let(:path) { plantings_path }
|
||||
let(:link_text) { "Mark as finished" }
|
||||
|
||||
it_behaves_like "append date"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,34 +1,33 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Post a post' do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:member) { create :member }
|
||||
|
||||
background do
|
||||
login_as(member)
|
||||
login_as member
|
||||
visit new_post_path
|
||||
end
|
||||
|
||||
scenario "creating a post" do
|
||||
fill_in "post_subject", :with => "Testing"
|
||||
fill_in "post_body", :with => "This is a sample test"
|
||||
fill_in "post_subject", with: "Testing"
|
||||
fill_in "post_body", with: "This is a sample test"
|
||||
click_button "Post"
|
||||
expect(page).to have_content "Post was successfully created"
|
||||
expect(page).to have_content "Posted by"
|
||||
end
|
||||
|
||||
context "editing a post" do
|
||||
let(:existing_post) { FactoryGirl.create(:post, :author => member)}
|
||||
let(:existing_post) { create :post, author: member }
|
||||
|
||||
background do
|
||||
visit edit_post_path(existing_post)
|
||||
end
|
||||
|
||||
scenario "saving edit" do
|
||||
fill_in "post_subject", :with => "Testing Edit"
|
||||
click_button "Post"
|
||||
fill_in "post_subject", with: "Testing Edit"
|
||||
click_button "Post"
|
||||
expect(page).to have_content "Post was successfully updated"
|
||||
expect(page).to have_content "Edited by"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'spec_helper'
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Comments RSS feed' do
|
||||
scenario 'The index feed exists' do
|
||||
visit comments_path(:format => 'rss')
|
||||
visit comments_path(format: 'rss')
|
||||
expect(page.status_code).to equal 200
|
||||
end
|
||||
|
||||
scenario 'The index title is what we expect' do
|
||||
visit comments_path(:format => 'rss')
|
||||
visit comments_path(format: 'rss')
|
||||
expect(page).to have_content "Recent comments on all posts (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'spec_helper'
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Crops RSS feed' do
|
||||
scenario 'The index feed exists' do
|
||||
visit crops_path(:format => 'rss')
|
||||
visit crops_path(format: 'rss')
|
||||
expect(page.status_code).to equal 200
|
||||
end
|
||||
|
||||
scenario 'The index title is what we expect' do
|
||||
visit crops_path(:format => 'rss')
|
||||
visit crops_path(format: 'rss')
|
||||
expect(page).to have_content "Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
@@ -1,15 +1,15 @@
|
||||
require 'spec_helper'
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Members RSS feed' do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:member) { create :member }
|
||||
|
||||
scenario 'The show action exists' do
|
||||
visit member_path(member, :format => 'rss')
|
||||
visit member_path(member, format: 'rss')
|
||||
expect(page.status_code).to equal 200
|
||||
end
|
||||
|
||||
scenario 'The show action title is what we expect' do
|
||||
visit member_path(member, :format => 'rss')
|
||||
visit member_path(member, format: 'rss')
|
||||
expect(page).to have_content "#{member.login_name}'s recent posts (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'spec_helper'
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Plantings RSS feed' do
|
||||
scenario 'The index feed exists' do
|
||||
visit plantings_path(:format => 'rss')
|
||||
visit plantings_path(format: 'rss')
|
||||
expect(page.status_code).to equal 200
|
||||
end
|
||||
|
||||
scenario 'The index title is what we expect' do
|
||||
visit plantings_path(:format => 'rss')
|
||||
visit plantings_path(format: 'rss')
|
||||
expect(page).to have_content "Recent plantings from #{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'spec_helper'
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Posts RSS feed' do
|
||||
scenario 'The index feed exists' do
|
||||
visit posts_path(:format => 'rss')
|
||||
visit posts_path(format: 'rss')
|
||||
expect(page.status_code).to equal 200
|
||||
end
|
||||
|
||||
scenario 'The index title is what we expect' do
|
||||
visit posts_path(:format => 'rss')
|
||||
visit posts_path(format: 'rss')
|
||||
expect(page).to have_content "Recent posts from #{ @author ? @author : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'spec_helper'
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Seeds RSS feed' do
|
||||
scenario 'The index feed exists' do
|
||||
visit seeds_path(:format => 'rss')
|
||||
visit seeds_path(format: 'rss')
|
||||
expect(page.status_code).to equal 200
|
||||
end
|
||||
|
||||
scenario 'The index title is what we expect' do
|
||||
visit seeds_path(:format => 'rss')
|
||||
visit seeds_path(format: 'rss')
|
||||
expect(page).to have_content "Recent seeds from #{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Scientific names" do
|
||||
let!(:zea_mays) { FactoryGirl.create(:zea_mays) }
|
||||
let!(:zea_mays) { create :zea_mays }
|
||||
let(:crop) { zea_mays.crop }
|
||||
|
||||
scenario "Display scientific names on crop page" do
|
||||
@@ -17,8 +17,8 @@ feature "Scientific names" do
|
||||
end
|
||||
|
||||
context "User is a crop wrangler" do
|
||||
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
|
||||
let(:member){crop_wranglers.first}
|
||||
let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
|
||||
let(:member) { crop_wranglers.first }
|
||||
|
||||
background do
|
||||
login_as(member)
|
||||
@@ -29,7 +29,7 @@ feature "Scientific names" do
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to have_content "CROP WRANGLER"
|
||||
expect(page).to have_content zea_mays.scientific_name
|
||||
expect(page).to have_link "Edit", :href => edit_scientific_name_path(zea_mays)
|
||||
expect(page).to have_link "Edit", href: edit_scientific_name_path(zea_mays)
|
||||
within('.scientific_names') { click_on "Edit" }
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
|
||||
@@ -42,7 +42,7 @@ feature "Scientific names" do
|
||||
scenario "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)
|
||||
href: scientific_name_path(zea_mays)
|
||||
within('.scientific_names') { click_on "Delete" }
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to_not have_content zea_mays.scientific_name
|
||||
@@ -52,7 +52,7 @@ feature "Scientific names" do
|
||||
scenario "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)
|
||||
href: new_scientific_name_path(crop_id: crop.id)
|
||||
within('.scientific_names') { click_on "Add" }
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
|
||||
@@ -67,12 +67,12 @@ feature "Scientific names" do
|
||||
visit scientific_name_path(zea_mays)
|
||||
expect(page.status_code).to equal 200
|
||||
expect(page).to have_link zea_mays.crop.name,
|
||||
href: crop_path(zea_mays.crop)
|
||||
href: crop_path(zea_mays.crop)
|
||||
end
|
||||
|
||||
context "When scientific name is pending" do
|
||||
let(:pending_crop) { FactoryGirl.create(:crop_request) }
|
||||
let(:pending_sci_name) { FactoryGirl.create(:scientific_name, :crop => pending_crop) }
|
||||
let(:pending_crop) { create :crop_request }
|
||||
let(:pending_sci_name) { create :scientific_name, crop: pending_crop }
|
||||
|
||||
scenario "Displays crop pending message" do
|
||||
visit scientific_name_path(pending_sci_name)
|
||||
|
||||
@@ -1,29 +1,46 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Seeds", :js => true do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let!(:maize) { FactoryGirl.create(:maize) }
|
||||
feature "Seeds", :js do
|
||||
let(:member) { create :member }
|
||||
let!(:maize) { create :maize }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
visit new_seed_path
|
||||
sync_elasticsearch([maize])
|
||||
sync_elasticsearch [maize]
|
||||
end
|
||||
|
||||
it_behaves_like "crop suggest", "seed", "crop"
|
||||
|
||||
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: "Crop:"
|
||||
expect(page).to have_selector 'input#seed_quantity[placeholder="optional"]'
|
||||
expect(page).to have_selector 'input#seed_plant_before[placeholder="optional"]'
|
||||
expect(page).to have_selector 'input#seed_days_until_maturity_min[placeholder="optional"]'
|
||||
expect(page).to have_selector 'input#seed_days_until_maturity_max[placeholder="optional"]'
|
||||
expect(page).to have_selector '.form-group.required', text: 'Organic?'
|
||||
expect(page).to have_selector '.form-group.required', text: 'GMO?'
|
||||
expect(page).to have_selector '.form-group.required', text: 'Heirloom?'
|
||||
expect(page).to have_selector 'textarea#seed_description[placeholder="optional"]'
|
||||
expect(page).to have_selector '.form-group.required', text: 'Will trade:'
|
||||
end
|
||||
|
||||
scenario "Adding a new seed", :js => true do
|
||||
fill_autocomplete "crop", :with => "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_seed" do
|
||||
fill_in "Quantity:", :with => 42
|
||||
fill_in "Plant before:", :with => "2014-06-15"
|
||||
fill_in "Days until maturity:", :with => 999
|
||||
fill_in "to", :with => 1999
|
||||
fill_in "Quantity:", with: 42
|
||||
fill_in "Plant before:", with: "2014-06-15"
|
||||
fill_in "Days until maturity:", with: 999
|
||||
fill_in "to", with: 1999
|
||||
select "certified organic", :from => "Organic?"
|
||||
select "non-certified GMO-free", :from => "GMO?"
|
||||
select "heirloom", :from => "Heirloom?"
|
||||
fill_in "Description", :with => "It's killer."
|
||||
fill_in "Description", with: "It's killer."
|
||||
select "internationally", :from => "Will trade:"
|
||||
click_button "Save"
|
||||
end
|
||||
@@ -48,5 +65,4 @@ feature "Seeds", :js => true do
|
||||
expect(page).to have_content "Successfully added maize seed to your stash"
|
||||
expect(page).to have_content "maize"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,77 +2,75 @@ require 'rails_helper'
|
||||
|
||||
feature "seeds" do
|
||||
context "signed in user" do
|
||||
|
||||
let(:member) { @member = FactoryGirl.create(:member) }
|
||||
let(:crop) { FactoryGirl.create(:crop) }
|
||||
let(:member) { create :member }
|
||||
let(:crop) { create :crop }
|
||||
|
||||
background do
|
||||
login_as member
|
||||
end
|
||||
|
||||
scenario "button on index to edit seed" do
|
||||
seed = FactoryGirl.create(:seed, :owner => @member)
|
||||
seed = create :seed, owner: member
|
||||
visit seeds_path
|
||||
click_link "Edit"
|
||||
current_path.should eq edit_seed_path(seed)
|
||||
page.should have_content 'Editing seeds'
|
||||
click_link "edit_seed_glyphicon"
|
||||
expect(current_path).to eq edit_seed_path(seed)
|
||||
expect(page).to have_content 'Editing seeds'
|
||||
end
|
||||
|
||||
scenario "button on front page to add seeds" do
|
||||
visit root_path
|
||||
click_link "Add seeds"
|
||||
current_path.should eq new_seed_path
|
||||
page.should have_content 'Add seeds'
|
||||
expect(current_path).to eq new_seed_path
|
||||
expect(page).to have_content 'Add seeds'
|
||||
end
|
||||
|
||||
scenario "Clicking link to owner's profile" do
|
||||
visit seeds_by_owner_path(member)
|
||||
click_link "View #{member}'s profile >>"
|
||||
current_path.should eq member_path(member)
|
||||
expect(current_path).to eq member_path(member)
|
||||
end
|
||||
|
||||
|
||||
# actually adding seeds is in spec/features/seeds_new_spec.rb
|
||||
|
||||
scenario "edit seeds" do
|
||||
seed = FactoryGirl.create(:seed, :owner => @member)
|
||||
seed = create :seed, owner: member
|
||||
visit seed_path(seed)
|
||||
click_link 'Edit'
|
||||
current_path.should eq edit_seed_path(seed)
|
||||
fill_in 'Quantity:', :with => seed.quantity * 2
|
||||
expect(current_path).to eq edit_seed_path(seed)
|
||||
fill_in 'Quantity:', with: seed.quantity * 2
|
||||
click_button 'Save'
|
||||
current_path.should eq seed_path(seed)
|
||||
expect(current_path).to eq seed_path(seed)
|
||||
end
|
||||
|
||||
scenario "delete seeds" do
|
||||
seed = FactoryGirl.create(:seed, :owner => @member)
|
||||
seed = create :seed, owner: member
|
||||
visit seed_path(seed)
|
||||
click_link 'Delete'
|
||||
current_path.should eq seeds_path
|
||||
expect(current_path).to eq seeds_path
|
||||
end
|
||||
|
||||
scenario "view seeds with max and min days until maturity" do
|
||||
seed = FactoryGirl.create(:seed, :days_until_maturity_min => 5, :days_until_maturity_max => 7)
|
||||
seed = create :seed, days_until_maturity_min: 5, days_until_maturity_max: 7
|
||||
visit seed_path(seed)
|
||||
expect(page).to have_content "Days until maturity: 5–7"
|
||||
end
|
||||
|
||||
scenario "view seeds with only max days until maturity" do
|
||||
seed = FactoryGirl.create(:seed, :days_until_maturity_max => 7)
|
||||
seed = create :seed, days_until_maturity_max: 7
|
||||
visit seed_path(seed)
|
||||
expect(page).to have_content "Days until maturity: 7"
|
||||
end
|
||||
|
||||
scenario "view seeds with only min days until maturity" do
|
||||
seed = FactoryGirl.create(:seed, :days_until_maturity_min => 5)
|
||||
seed = create :seed, days_until_maturity_min: 5
|
||||
visit seed_path(seed)
|
||||
expect(page).to have_content "Days until maturity: 5"
|
||||
end
|
||||
|
||||
scenario "view seeds with neither max nor min days until maturity" do
|
||||
seed = FactoryGirl.create(:seed)
|
||||
seed = create :seed
|
||||
visit seed_path(seed)
|
||||
expect(page).to have_content "Days until maturity: unknown"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
shared_examples "append date" do
|
||||
let(:this_month) { Date.today.strftime("%B") }
|
||||
let(:this_year) { Date.today.strftime("%Y") }
|
||||
|
||||
background { visit path }
|
||||
|
||||
scenario "Selecting a date with datepicker" do
|
||||
this_month = Date.today.strftime("%B")
|
||||
this_year = Date.today.strftime("%Y")
|
||||
visit path
|
||||
click_link link_text
|
||||
within "div.datepicker" do
|
||||
expect(page).to have_content "#{this_month}"
|
||||
page.find(".datepicker-days td.day", text: "21").click
|
||||
find(".datepicker-days td.day", text: "21").click
|
||||
end
|
||||
expect(page).to have_content "Finished: #{this_month} 21, #{this_year}"
|
||||
end
|
||||
|
||||
scenario "Confirming without selecting date" do
|
||||
visit path
|
||||
click_link link_text
|
||||
click_link "Confirm without date"
|
||||
expect(page).to have_content("Finished: Yes (no date specified) ")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,14 +1,12 @@
|
||||
require 'rails_helper'
|
||||
|
||||
shared_examples "crop suggest" do |resource|
|
||||
let!(:pea) { FactoryGirl.create(:crop, :name => 'pea') }
|
||||
let!(:pear) { FactoryGirl.create(:pear) }
|
||||
let!(:tomato) { FactoryGirl.create(:tomato) }
|
||||
let!(:roma) { FactoryGirl.create(:roma) }
|
||||
let!(:pea) { create :crop, name: 'pea' }
|
||||
let!(:pear) { create :pear }
|
||||
let!(:tomato) { create :tomato }
|
||||
let!(:roma) { create :roma }
|
||||
|
||||
background do
|
||||
sync_elasticsearch([pea, pear, maize, tomato])
|
||||
end
|
||||
background { 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']")
|
||||
@@ -16,21 +14,21 @@ shared_examples "crop suggest" do |resource|
|
||||
|
||||
scenario "typing in the crop name displays suggestions" do
|
||||
within "form#new_#{resource}" do
|
||||
fill_autocomplete "crop", :with => "pe"
|
||||
fill_autocomplete "crop", with: "pe"
|
||||
end
|
||||
|
||||
expect(page).to_not have_content("pear")
|
||||
expect(page).to_not have_content("pea")
|
||||
|
||||
within "form#new_#{resource}" do
|
||||
fill_autocomplete "crop", :with => "pea"
|
||||
fill_autocomplete "crop", with: "pea"
|
||||
end
|
||||
|
||||
expect(page).to have_content("pear")
|
||||
expect(page).to have_content("pea")
|
||||
|
||||
within "form#new_#{resource}" do
|
||||
fill_autocomplete "crop", :with => "pear"
|
||||
fill_autocomplete "crop", with: "pear"
|
||||
end
|
||||
|
||||
expect(page).to have_content("pear")
|
||||
@@ -38,7 +36,7 @@ shared_examples "crop suggest" do |resource|
|
||||
|
||||
scenario "selecting crop from dropdown" do
|
||||
within "form#new_#{resource}" do
|
||||
fill_autocomplete "crop", :with => "pear"
|
||||
fill_autocomplete "crop", with: "pear"
|
||||
end
|
||||
|
||||
select_from_autocomplete("pear")
|
||||
@@ -48,7 +46,7 @@ shared_examples "crop suggest" do |resource|
|
||||
|
||||
scenario "Typing and pausing does not affect input" do
|
||||
within "form#new_#{resource}" do
|
||||
fill_autocomplete "crop", :with => "pea"
|
||||
fill_autocomplete "crop", with: "pea"
|
||||
end
|
||||
|
||||
expect(page).to have_content("pear")
|
||||
@@ -57,7 +55,7 @@ shared_examples "crop suggest" do |resource|
|
||||
|
||||
scenario "Searching for a crop casts a wide net on results" do
|
||||
within "form#new_#{resource}" do
|
||||
fill_autocomplete "crop", :with => "tom"
|
||||
fill_autocomplete "crop", with: "tom"
|
||||
end
|
||||
|
||||
expect(page).to have_content("tomato")
|
||||
@@ -66,11 +64,10 @@ shared_examples "crop suggest" do |resource|
|
||||
|
||||
scenario "Submitting a crop that doesn't exist in the database produces a meaningful error" do
|
||||
within "form#new_#{resource}" do
|
||||
fill_autocomplete "crop", :with => "Ryan Gosling"
|
||||
fill_autocomplete "crop", with: "Ryan Gosling"
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
expect(page).to have_content("Crop must be present and exist in our database")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "signin" do
|
||||
let(:member){FactoryGirl.create(:member)}
|
||||
let(:recipient){FactoryGirl.create(:member)}
|
||||
let(:notification){FactoryGirl.create(:notification)}
|
||||
let(:member) { create :member }
|
||||
let(:recipient) { create :member }
|
||||
let(:notification) { create :notification }
|
||||
|
||||
scenario "redirect to previous page after signin" do
|
||||
visit crops_path # some random page
|
||||
@@ -11,7 +11,7 @@ feature "signin" do
|
||||
fill_in 'Login', with: member.login_name
|
||||
fill_in 'Password', with: member.password
|
||||
click_button 'Sign in'
|
||||
current_path.should eq crops_path
|
||||
expect(current_path).to eq crops_path
|
||||
end
|
||||
|
||||
scenario "don't redirect to devise pages after signin" do
|
||||
@@ -20,34 +20,33 @@ feature "signin" do
|
||||
fill_in 'Login', with: member.login_name
|
||||
fill_in 'Password', with: member.password
|
||||
click_button 'Sign in'
|
||||
current_path.should eq root_path
|
||||
expect(current_path).to eq root_path
|
||||
end
|
||||
|
||||
scenario "redirect to signin page for if not authenticated to view notification" do
|
||||
visit notification_path(notification)
|
||||
current_path.should eq new_member_session_path
|
||||
expect(current_path).to eq new_member_session_path
|
||||
end
|
||||
|
||||
scenario "after signin, redirect to what you were trying to do" do
|
||||
models = %w[plantings harvests posts photos gardens seeds]
|
||||
models.each do |model|
|
||||
visit "/#{model}/new"
|
||||
current_path.should eq new_member_session_path
|
||||
expect(current_path).to eq new_member_session_path
|
||||
fill_in 'Login', with: member.login_name
|
||||
fill_in 'Password', with: member.password
|
||||
click_button 'Sign in'
|
||||
current_path.should eq "/#{model}/new"
|
||||
expect(current_path).to eq "/#{model}/new"
|
||||
click_link 'Sign out'
|
||||
end
|
||||
end
|
||||
|
||||
scenario "after signin, redirect to new notifications page" do
|
||||
visit new_notification_path(recipient: recipient)
|
||||
current_path.should eq new_member_session_path
|
||||
expect(current_path).to eq new_member_session_path
|
||||
fill_in 'Login', with: member.login_name
|
||||
fill_in 'Password', with: member.password
|
||||
click_button 'Sign in'
|
||||
current_path.should eq new_notification_path
|
||||
expect(current_path).to eq new_notification_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "signout" do
|
||||
let(:member){FactoryGirl.create(:member)}
|
||||
|
||||
let(:member) { create :member }
|
||||
|
||||
scenario "redirect to previous page after signout" do
|
||||
visit crops_path # some random page
|
||||
click_link 'Sign in'
|
||||
@@ -10,20 +10,20 @@ feature "signout" do
|
||||
fill_in 'Password', with: member.password
|
||||
click_button 'Sign in'
|
||||
click_link 'Sign out'
|
||||
current_path.should eq crops_path
|
||||
expect(current_path).to eq crops_path
|
||||
end
|
||||
|
||||
scenario "after signout, redirect to signin page if page needs authentication" do
|
||||
models = %w[plantings harvests posts photos gardens seeds]
|
||||
models.each do |model|
|
||||
visit "/#{model}/new"
|
||||
current_path.should eq new_member_session_path
|
||||
expect(current_path).to eq new_member_session_path
|
||||
fill_in 'Login', with: member.login_name
|
||||
fill_in 'Password', with: member.password
|
||||
click_button 'Sign in'
|
||||
current_path.should eq "/#{model}/new"
|
||||
expect(current_path).to eq "/#{model}/new"
|
||||
click_link 'Sign out'
|
||||
current_path.should eq new_member_session_path
|
||||
expect(current_path).to eq new_member_session_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "signup" do
|
||||
|
||||
scenario "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'
|
||||
@@ -11,7 +10,7 @@ feature "signup" do
|
||||
fill_in 'Password confirmation', with: 'abc123'
|
||||
check 'member_tos_agreement'
|
||||
click_button 'Sign up'
|
||||
current_path.should eq root_path
|
||||
expect(current_path).to eq root_path
|
||||
end
|
||||
|
||||
scenario "sign up for new account with existing username" do
|
||||
@@ -23,8 +22,7 @@ feature "signup" do
|
||||
fill_in 'Password confirmation', with: 'abc123'
|
||||
check 'member_tos_agreement'
|
||||
click_button 'Sign up'
|
||||
page.has_content? 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
|
||||
current_path.should eq root_path
|
||||
expect(current_path).to eq root_path
|
||||
first('.signup a').click # click the 'Sign up' button in the middle of the page
|
||||
fill_in 'Login name', with: 'person123'
|
||||
fill_in 'Email', with: 'gardener@example.com'
|
||||
@@ -32,7 +30,6 @@ feature "signup" do
|
||||
fill_in 'Password confirmation', with: 'abc123'
|
||||
check 'member_tos_agreement'
|
||||
click_button 'Sign up'
|
||||
page.has_content? 'Login name has already been taken'
|
||||
end
|
||||
|
||||
scenario "sign up for new account without accepting TOS" do
|
||||
@@ -44,8 +41,6 @@ feature "signup" do
|
||||
fill_in 'Password confirmation', with: 'abc123'
|
||||
# do not check 'member_tos_agreement'
|
||||
click_button 'Sign up'
|
||||
page.has_content? 'Tos agreement must be accepted'
|
||||
current_path.should eq members_path
|
||||
expect(current_path).to eq members_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ require 'rails_helper'
|
||||
require 'capybara/email/rspec'
|
||||
|
||||
feature "unsubscribe" do
|
||||
let(:member) { FactoryGirl.create(:member) }
|
||||
let(:notification) { FactoryGirl.create(:notification) }
|
||||
let(:member) { create :member }
|
||||
let(:notification) { create :notification }
|
||||
|
||||
background do
|
||||
clear_emails
|
||||
|
||||
@@ -12,4 +12,11 @@ describe ApplicationHelper do
|
||||
parse_date('2012-05-12').should eq Date.new(2012, 5, 12)
|
||||
parse_date('may 12th 2012').should eq Date.new(2012, 5, 12)
|
||||
end
|
||||
|
||||
it "shows required field marker help text with proper formatting" do
|
||||
output = required_field_help_text
|
||||
expect(output).to have_selector '.margin-bottom'
|
||||
expect(output).to have_selector '.red', text: '*'
|
||||
expect(output).to have_selector 'em', text: 'denotes a required field'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,4 +82,7 @@ RSpec.configure do |config|
|
||||
# see https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.extend ControllerMacros, :type => :controller
|
||||
|
||||
# Allow just create(:factory) instead of needing to specify FactoryGirl.create(:factory)
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
end
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "gardens/index" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@owner = FactoryGirl.create(:member)
|
||||
@garden = FactoryGirl.create(:garden, :owner => @owner)
|
||||
@finished_planting = FactoryGirl.create(:finished_planting, :garden => @garden)
|
||||
page = 1
|
||||
per_page = 2
|
||||
total_entries = 2
|
||||
gardens = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
|
||||
pager.replace([@garden, @garden])
|
||||
end
|
||||
assign(:gardens, gardens)
|
||||
end
|
||||
|
||||
it "renders a list of gardens" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "tr>td", :text => @garden.name, :count => 2
|
||||
assert_select "tr>td>a", :text => @garden.location, :count => 2
|
||||
assert_select "tr>td", :text => pluralize(@garden.area, @garden.area_unit), :count => 2
|
||||
end
|
||||
|
||||
it "does not show finished plantings" do
|
||||
render
|
||||
expect(rendered).to_not have_content(@finished_planting.crop_name)
|
||||
end
|
||||
end
|
||||
@@ -43,14 +43,6 @@ describe "harvests/index" do
|
||||
render
|
||||
end
|
||||
|
||||
it "renders a list of harvests" do
|
||||
render
|
||||
assert_select "tr>td", :text => @member.login_name
|
||||
assert_select "tr>td", :text => @tomato.name
|
||||
assert_select "tr>td", :text => @maize.name
|
||||
assert_select "tr>td", :text => @pp.name
|
||||
end
|
||||
|
||||
it "provides data links" do
|
||||
render
|
||||
rendered.should have_content "The data on this page is available in the following formats:"
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "seeds/index" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
@seed1 = FactoryGirl.create(:seed, :owner => @member)
|
||||
@page = 1
|
||||
@per_page = 2
|
||||
@total_entries = 2
|
||||
seeds = WillPaginate::Collection.create(@page, @per_page, @total_entries) do |pager|
|
||||
pager.replace([ @seed1, @seed1 ])
|
||||
end
|
||||
assign(:seeds, seeds)
|
||||
end
|
||||
|
||||
it "renders a list of seeds" do
|
||||
render
|
||||
assert_select "tr>td", :text => @seed1.crop.name, :count => 2
|
||||
assert_select "tr>td", :text => @seed1.owner.login_name, :count => 2
|
||||
assert_select "tr>td", :text => @seed1.quantity.to_s, :count => 2
|
||||
end
|
||||
|
||||
context "tradable" do
|
||||
before(:each) do
|
||||
@owner = FactoryGirl.create(:london_member)
|
||||
@seed1 = FactoryGirl.create(:tradable_seed, :owner => @owner)
|
||||
seeds = WillPaginate::Collection.create(@page, @per_page, @total_entries) do |pager|
|
||||
pager.replace([ @seed1, @seed1 ])
|
||||
end
|
||||
assign(:seeds, seeds)
|
||||
render
|
||||
end
|
||||
|
||||
it "shows tradable seeds" do
|
||||
assert_select "tr>td", :text => @seed1.tradable_to, :count => 2
|
||||
end
|
||||
|
||||
it "shows location of seed owner" do
|
||||
assert_select "tr>td", :text => @owner.location, :count => 2
|
||||
assert_select 'a', :href => place_path(@owner.location)
|
||||
end
|
||||
end
|
||||
|
||||
it "provides data links" do
|
||||
render
|
||||
rendered.should have_content "The data on this page is available in the following formats:"
|
||||
assert_select "a", :href => seeds_path(:format => 'csv')
|
||||
assert_select "a", :href => seeds_path(:format => 'json')
|
||||
assert_select "a", :href => seeds_path(:format => 'rss')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user