From 9c469fb217fd8ee388ed84316e300f4c9f1fec84 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 10:05:04 -0400 Subject: [PATCH 01/33] .gitignore additions for users of Rubymine. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6370fea4b..9d8981307 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ custom_plan.rb zeus.json .bundle config/application.yml +.idea/** \ No newline at end of file From fa8b10af58f1c3c1638280958eb9b4fd6edce1e6 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 10:37:54 -0400 Subject: [PATCH 02/33] New contributor! --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 22732495c..3fb5b66f6 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -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) \ No newline at end of file From 30032f552700df48e16c76d92d61396b22c946a8 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 10:38:41 -0400 Subject: [PATCH 03/33] Add a red asterisk via CSS after all .form-group labels with the .required class. --- app/assets/stylesheets/overrides.css.less | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/stylesheets/overrides.css.less b/app/assets/stylesheets/overrides.css.less index 07194ae2b..8dda75bf6 100644 --- a/app/assets/stylesheets/overrides.css.less +++ b/app/assets/stylesheets/overrides.css.less @@ -324,3 +324,8 @@ html, body { #add-sci_name-row, #remove-sci_name-row, #add-alt_name-row, #remove-alt_name-row{ display: none; } + +.form-group.required .control-label:after { + content: " *"; + color: red; +} \ No newline at end of file From a80001ffe704414873a4121c9fcfc8a1695deba0 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 10:39:02 -0400 Subject: [PATCH 04/33] Schema update after migration. --- db/schema.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index be45fa333..4f21ebffd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 From fc33269f472211f99a405e90cc0c8f914d1dd48b Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 10:51:37 -0400 Subject: [PATCH 05/33] Reusable class for adding a 1em bottom margin to a block and .red class for red foreground color. --- app/assets/stylesheets/overrides.css.less | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/overrides.css.less b/app/assets/stylesheets/overrides.css.less index 8dda75bf6..8dc88e715 100644 --- a/app/assets/stylesheets/overrides.css.less +++ b/app/assets/stylesheets/overrides.css.less @@ -325,7 +325,15 @@ html, body { display: none; } -.form-group.required .control-label:after { - content: " *"; +.form-group.required .control-label:before { + content: "* "; + color: red; +} + +.margin-bottom { + margin-bottom: 1em; +} + +.red { color: red; } \ No newline at end of file From 9a6c32fe6dbeeeb9410ec31a12788d34de2d9373 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 10:52:08 -0400 Subject: [PATCH 06/33] Planting form with required fields marked and optional fields with "optional" placeholders or select options. --- app/views/plantings/_form.html.haml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index b16fc2391..5efd62a22 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -1,3 +1,7 @@ +.margin-bottom + %span.red * + %em denotes a required field. + = form_for(@planting, :html => {:class => "form-horizontal", :role => "form"}) do |f| - if @planting.errors.any? #error_explanation @@ -6,14 +10,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 +25,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 +48,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' From a03d044049e09fbbfb6a28ea4ca1a95862925d42 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 10:59:47 -0400 Subject: [PATCH 07/33] Make a reusable helper for the "* denotes a required field" help text and change the Planting form to use the helper. --- app/helpers/application_helper.rb | 6 ++++++ app/views/plantings/_form.html.haml | 4 +--- spec/helpers/application_helper_spec.rb | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5e1264b4a..319a954fd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 5efd62a22..1e347b35e 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -1,6 +1,4 @@ -.margin-bottom - %span.red * - %em denotes a required field. += required_field_help_text = form_for(@planting, :html => {:class => "form-horizontal", :role => "form"}) do |f| - if @planting.errors.any? diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 67d05fc3e..8d1f0e78a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -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 From 96a007ef3be768aac1361df5fe19c64853b51d14 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 11:02:46 -0400 Subject: [PATCH 08/33] Marking required and optional fields on Harvest form. --- app/views/harvests/_form.html.haml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index 21de8e5b6..0b61ae03e 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -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 From 715a004b13be2ae65ee781d5ad66ace852634e2f Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 11:05:21 -0400 Subject: [PATCH 09/33] Marking required and optional fields on Seed form. Purposefully marked required those select fields which have no blank option. --- app/views/seeds/_form.html.haml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index c40a08697..ac3c26df4 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -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,7 +16,7 @@ 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' .form-group @@ -22,7 +24,7 @@ .col-md-2 = f.text_field :plant_before, :class => 'add-datepicker form-control', :value => @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' .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' @@ -32,22 +34,22 @@ = f.number_field :days_until_maturity_max, :class => 'form-control' .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') From 4786e3e087f4a2f5265602afc570e1f5cb8542c9 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 11:07:32 -0400 Subject: [PATCH 10/33] Marking required and optional fields on Garden form. --- app/views/gardens/_form.html.haml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index 1915910db..09c3b99ef 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -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') From 044f62eae25051a60ca0c20413c12df1096db6b7 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 15:54:09 -0400 Subject: [PATCH 11/33] Rubymine .gitignore additions. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6370fea4b..9d8981307 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ custom_plan.rb zeus.json .bundle config/application.yml +.idea/** \ No newline at end of file From fad9eddbc419a317ff55271561e554419b94dc93 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 16:00:45 -0400 Subject: [PATCH 12/33] Addition of guard gem to assist in quicker testing. --- Gemfile | 2 ++ Gemfile.lock | 34 ++++++++++++++++++++++++++++++++++ Guardfile | 20 ++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 Guardfile diff --git a/Gemfile b/Gemfile index bb774b703..745ca273b 100644 --- a/Gemfile +++ b/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 diff --git a/Gemfile.lock b/Gemfile.lock index fef7b8258..39312a659 100644 --- a/Gemfile.lock +++ b/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 diff --git a/Guardfile b/Guardfile new file mode 100644 index 000000000..04f2fd1f3 --- /dev/null +++ b/Guardfile @@ -0,0 +1,20 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +## Uncomment and set this to only include directories you want to watch +directories %w(app lib config spec) \ + .select { |d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist") } + +## Note: if you are using the `directories` clause above and you are not +## watching the project directory ('.'), then you will want to move +## the Guardfile to a watched dir and symlink it back, e.g. +# +# $ mkdir config +# $ mv Guardfile config/ +# $ ln -s config/Guardfile . +# +# and, you'll have to watch "config/Guardfile" instead of "Guardfile" + +guard :rspec, + cmd: 'bundle exec spring rspec --format documentation', + failed_mode: :keep \ No newline at end of file From 5a35a3da01558c183fd16a8aaba1ef9190d7e3e2 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Wed, 22 Jul 2015 19:48:41 -0400 Subject: [PATCH 13/33] Initial rendition of feature test upgrade to Ruby 2.x and Rspec 3.x syntax. --- Guardfile | 31 ++-- spec/features/admin/account_types_spec.rb | 33 ++-- spec/features/admin/forums_spec.rb | 41 +++-- .../admin/{products.rb => products_spec.rb} | 26 +-- spec/features/cms_spec.rb | 17 +- .../comments/commenting_a_comment_spec.rb | 23 ++- spec/features/crops/alternate_name_spec.rb | 20 +-- spec/features/crops/browse_crops_spec.rb | 8 +- spec/features/crops/creating_a_crop_spec.rb | 10 +- spec/features/crops/crop_detail_page_spec.rb | 53 +++--- spec/features/crops/crop_wranglers_spec.rb | 41 +++-- .../crops/crop_wrangling_button_spec.rb | 45 +++--- spec/features/crops/inflections_spec.rb | 2 - spec/features/crops/request_new_crop_spec.rb | 21 +-- spec/features/following_spec.rb | 21 +-- spec/features/gardens_spec.rb | 25 ++- .../harvests/harvesting_a_crop_spec.rb | 26 ++- spec/features/locale_spec.rb | 7 +- spec/features/member_profile_spec.rb | 57 +++---- spec/features/members_list_spec.rb | 13 +- spec/features/notifications_spec.rb | 18 ++- spec/features/photos/show_photo_spec.rb | 24 ++- .../features/places/searching_a_place_spec.rb | 103 ++++++------ spec/features/planting_reminder_spec.rb | 38 ++--- .../plantings/planting_a_crop_spec.rb | 151 +++++++++--------- spec/features/posts/posting_a_post_spec.rb | 15 +- spec/features/rss/comments_spec.rb | 6 +- spec/features/rss/crops_spec.rb | 6 +- spec/features/rss/members_spec.rb | 8 +- spec/features/rss/plantings_spec.rb | 6 +- spec/features/rss/posts_spec.rb | 6 +- spec/features/rss/seeds_spec.rb | 6 +- spec/features/scientific_name_spec.rb | 18 +-- spec/features/seeds/adding_seeds_spec.rb | 25 ++- spec/features/seeds/misc_seeds_spec.rb | 40 +++-- spec/features/shared_examples/append_date.rb | 11 +- spec/features/shared_examples/crop_suggest.rb | 27 ++-- spec/features/signin_spec.rb | 21 ++- spec/features/signout_spec.rb | 12 +- spec/features/signup_spec.rb | 11 +- spec/features/unsubscribing_spec.rb | 4 +- spec/rails_helper.rb | 3 + 42 files changed, 491 insertions(+), 588 deletions(-) rename spec/features/admin/{products.rb => products_spec.rb} (50%) diff --git a/Guardfile b/Guardfile index 04f2fd1f3..edc8164d3 100644 --- a/Guardfile +++ b/Guardfile @@ -1,20 +1,13 @@ -# A sample Guardfile -# More info at https://github.com/guard/guard#readme - -## Uncomment and set this to only include directories you want to watch -directories %w(app lib config spec) \ - .select { |d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist") } - -## Note: if you are using the `directories` clause above and you are not -## watching the project directory ('.'), then you will want to move -## the Guardfile to a watched dir and symlink it back, e.g. -# -# $ mkdir config -# $ mv Guardfile config/ -# $ ln -s config/Guardfile . -# -# and, you'll have to watch "config/Guardfile" instead of "Guardfile" - guard :rspec, - cmd: 'bundle exec spring rspec --format documentation', - failed_mode: :keep \ No newline at end of file + 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 \ No newline at end of file diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb index 01c0040d5..ef0be1139 100644 --- a/spec/features/admin/account_types_spec.rb +++ b/spec/features/admin/account_types_spec.rb @@ -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 diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb index 98c30d6c7..3fe13e087 100644 --- a/spec/features/admin/forums_spec.rb +++ b/spec/features/admin/forums_spec.rb @@ -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 diff --git a/spec/features/admin/products.rb b/spec/features/admin/products_spec.rb similarity index 50% rename from spec/features/admin/products.rb rename to spec/features/admin/products_spec.rb index e24632cd0..0fc9bdb5a 100644 --- a/spec/features/admin/products.rb +++ b/spec/features/admin/products_spec.rb @@ -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' diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb index 3e10faa6b..ad10acd12 100644 --- a/spec/features/cms_spec.rb +++ b/spec/features/cms_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb index e4f2fed21..b39d28618 100644 --- a/spec/features/comments/commenting_a_comment_spec.rb +++ b/spec/features/comments/commenting_a_comment_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index 44bd40c38..586b6622b 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -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 diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 08e0b9247..1345d8738 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -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 diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb index 6c8ba8dbb..d234818b8 100644 --- a/spec/features/crops/creating_a_crop_spec.rb +++ b/spec/features/crops/creating_a_crop_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' feature "Crop - " do - 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 \ No newline at end of file diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index d8738929f..0ed3b3308 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -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) + current_path.should == seeds_by_owner_path(owner: member.slug) end end end diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index 761fb3f47..0e71275c2 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -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 diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb index 26ef46e30..ede88f003 100644 --- a/spec/features/crops/crop_wrangling_button_spec.rb +++ b/spec/features/crops/crop_wrangling_button_spec.rb @@ -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 diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb index 93c1f0e24..244945d35 100644 --- a/spec/features/crops/inflections_spec.rb +++ b/spec/features/crops/inflections_spec.rb @@ -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 diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb index c1d07810b..3d2f76e5f 100644 --- a/spec/features/crops/request_new_crop_spec.rb +++ b/spec/features/crops/request_new_crop_spec.rb @@ -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 diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb index 9654bfa4c..92e0f535c 100644 --- a/spec/features/following_spec.rb +++ b/spec/features/following_spec.rb @@ -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 diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 889fdd220..dab444bfa 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -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,8 +38,8 @@ 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" @@ -47,10 +47,10 @@ feature "Planting a crop", :js => true do 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 +58,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 +67,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 +76,4 @@ feature "Planting a crop", :js => true do visit gardens_path expect(page).not_to have_content finished_planting.crop_name end - end diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 3719164e1..c1a3f2f5c 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -1,25 +1,25 @@ 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" - scenario "Creating a new harvest", :js => true do - fill_autocomplete "crop", :with => "mai" + scenario "Creating a new harvest" 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 @@ -29,7 +29,7 @@ feature "Harvesting a crop", :js => true do 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 +45,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 +59,6 @@ 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 diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index 36b07b5c9..308f9225f 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -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 diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index 2c7343a8d..07d90b151 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -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 diff --git a/spec/features/members_list_spec.rb b/spec/features/members_list_spec.rb index 68cbb6d1f..073572795 100644 --- a/spec/features/members_list_spec.rb +++ b/spec/features/members_list_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index 5135a1c72..ee83f5c17 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -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 diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb index 0bef51587..238e69eda 100644 --- a/spec/features/photos/show_photo_spec.rb +++ b/spec/features/photos/show_photo_spec.rb @@ -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 diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index 4f69c1321..b0c0f931a 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index 3d694c013..e90118359 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -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,16 @@ 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 + 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 +45,17 @@ 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 + 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 diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 808b70880..aec99b57a 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -1,28 +1,28 @@ 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" 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 +33,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 +60,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 +77,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 +95,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 +114,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 +143,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 +157,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 +200,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 +213,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 diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb index dabda1586..a1f32942e 100644 --- a/spec/features/posts/posting_a_post_spec.rb +++ b/spec/features/posts/posting_a_post_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/rss/comments_spec.rb b/spec/features/rss/comments_spec.rb index 3f7ce9dc8..20fb1b9d2 100644 --- a/spec/features/rss/comments_spec.rb +++ b/spec/features/rss/comments_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb index 971ec1b80..bb631347d 100644 --- a/spec/features/rss/crops_spec.rb +++ b/spec/features/rss/crops_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb index 69abb5a25..618beb5bf 100644 --- a/spec/features/rss/members_spec.rb +++ b/spec/features/rss/members_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index 5a0e98371..343678c1a 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index 899c1427b..2eb7d4418 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index e0d016939..fe490bc00 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index af5cc7f2f..9716795bf 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -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) diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 8fa146724..bf580793c 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -1,29 +1,29 @@ 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" - scenario "Adding a new seed", :js => true do - fill_autocomplete "crop", :with => "mai" + scenario "Adding a new seed" 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 +48,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 +end \ No newline at end of file diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 4c02ceecf..1d01e5732 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -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' + 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 diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb index 089680ff9..310e39606 100644 --- a/spec/features/shared_examples/append_date.rb +++ b/spec/features/shared_examples/append_date.rb @@ -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 \ No newline at end of file diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index 5e812e683..9828a7865 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -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 diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb index dced5f2ac..2c268e285 100644 --- a/spec/features/signin_spec.rb +++ b/spec/features/signin_spec.rb @@ -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 diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 00a389069..2d5d1a230 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -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 diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index aa4c9d65f..58b203195 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -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 diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index 2c37f3101..e8242f542 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -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 diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 784cfba6f..2bcf1cf4c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -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 From f5336bd8f8bda2343f2d381caadb12b7a1dcba89 Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Wed, 8 Jul 2015 14:30:22 +0800 Subject: [PATCH 14/33] Created card based template for harvests. --- app/assets/stylesheets/overrides.css.less | 5 +++ app/views/harvests/_thumbnail.html.haml | 23 ++++++++++++++ app/views/harvests/index.html.haml | 35 +++++---------------- spec/views/harvests/index.html.haml_spec.rb | 8 ----- 4 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 app/views/harvests/_thumbnail.html.haml diff --git a/app/assets/stylesheets/overrides.css.less b/app/assets/stylesheets/overrides.css.less index 07194ae2b..fcbf458e7 100644 --- a/app/assets/stylesheets/overrides.css.less +++ b/app/assets/stylesheets/overrides.css.less @@ -324,3 +324,8 @@ html, body { #add-sci_name-row, #remove-sci_name-row, #add-alt_name-row, #remove-alt_name-row{ display: none; } + +.panel-footer{ + height: 80px; + overflow-y: scroll; +} diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml new file mode 100644 index 000000000..25924a40c --- /dev/null +++ b/app/views/harvests/_thumbnail.html.haml @@ -0,0 +1,23 @@ +.panel.panel-success + .panel-heading + %h3.panel-title + = link_to "#{harvest.owner.login_name}'s harvest", harvest.owner + %a.pull-right{:href => edit_harvest_path(harvest), :role => "button"} + %span.glyphicon.glyphicon-pencil{:title => "Edit"} + .panel-body + .row + .col-md-6 + = 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-6 + %dl + %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= harvest.description \ No newline at end of file diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 5d35a40ae..a6ef4d312 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -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: diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index eb5c0491b..0c2dfe5bb 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -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:" From bbe7d967b4ac5a0f92cc5b8a9924c0c64dc55c09 Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Thu, 9 Jul 2015 14:02:02 +0800 Subject: [PATCH 15/33] Changed px to em and used truncate instead of srolling for long harvest descriptions. --- app/assets/stylesheets/overrides.css.less | 3 +-- app/helpers/harvests_helper.rb | 6 ++++++ app/views/harvests/_thumbnail.html.haml | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/overrides.css.less b/app/assets/stylesheets/overrides.css.less index fcbf458e7..ccb462404 100644 --- a/app/assets/stylesheets/overrides.css.less +++ b/app/assets/stylesheets/overrides.css.less @@ -326,6 +326,5 @@ html, body { } .panel-footer{ - height: 80px; - overflow-y: scroll; + height: 6em; } diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index b5f335db9..1c2d5fe60 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -37,4 +37,10 @@ module HarvestsHelper end end + def display_harvest_description(harvest) + output = truncate(harvest.description, length: 120, omission: '... ') + output += link_to('[Read more]', harvest_path(harvest)) if harvest.description.size > 100 + output.html_safe + end + end diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index 25924a40c..a4bcc0044 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -20,4 +20,5 @@ %dd= harvest.harvested_at .panel-footer %dt Description - %dd= harvest.description \ No newline at end of file + %dd + = display_harvest_description(harvest) From c12791e428d23da533c20cb134ccabf363b50f1e Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Thu, 9 Jul 2015 15:27:08 +0800 Subject: [PATCH 16/33] Created card-based thumbnails for Seeds and Gardens page. --- app/helpers/gardens_helper.rb | 32 +++++++++++++ app/helpers/harvests_helper.rb | 10 ++-- app/helpers/seeds_helper.rb | 13 +++++ app/views/gardens/_thumbnail.html.haml | 27 +++++++++++ app/views/gardens/index.html.haml | 61 +++++------------------- app/views/harvests/_thumbnail.html.haml | 6 +-- app/views/seeds/_thumbnail.html.haml | 26 ++++++++++ app/views/seeds/index.html.haml | 63 +++++++------------------ 8 files changed, 137 insertions(+), 101 deletions(-) create mode 100644 app/helpers/gardens_helper.rb create mode 100644 app/helpers/seeds_helper.rb create mode 100644 app/views/gardens/_thumbnail.html.haml create mode 100644 app/views/seeds/_thumbnail.html.haml diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb new file mode 100644 index 000000000..9eb40e21d --- /dev/null +++ b/app/helpers/gardens_helper.rb @@ -0,0 +1,32 @@ +module GardensHelper + + def display_garden_description(garden) + if garden.description.nil? + "no description provided." + else + output = truncate(garden.description, length: 130, omission: '... ') + output += link_to('[Read more]', garden_path(garden)) if garden.description.size > 130 + output.html_safe + end + end + + def display_garden_plantings(garden) + if garden.plantings.empty? + None + else + output = "" + garden.plantings.current.each do |p| + output = p.quantity.nil? ? "0 " : "#{p.quantity} " + output += link_to p.crop.name, p + output = output.html_safe + if p.planted_at + output += ", planted on #{p.planted_at}" + end + end + + output = truncate(output, length: 100, omission: '... ') + output += link_to('[View more plantings]', garden_path(garden)) if output.size > 100 + output.html_safe + end + end +end \ No newline at end of file diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index 1c2d5fe60..7a5848066 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -38,9 +38,13 @@ module HarvestsHelper end def display_harvest_description(harvest) - output = truncate(harvest.description, length: 120, omission: '... ') - output += link_to('[Read more]', harvest_path(harvest)) if harvest.description.size > 100 - output.html_safe + if harvest.description.nil? + "no description provided." + else + output = truncate(harvest.description, length: 130, omission: '... ') + output += link_to('[Read more]', harvest_path(harvest)) if harvest.description.size > 130 + output.html_safe + end end end diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb new file mode 100644 index 000000000..728ed7215 --- /dev/null +++ b/app/helpers/seeds_helper.rb @@ -0,0 +1,13 @@ +module SeedsHelper + + def display_seed_description(seed) + if seed.description.nil? + "no description provided." + else + output = truncate(seed.description, length: 130, omission: '... ') + output += link_to('[Read more]', seed_path(seed)) if seed.description.size > 130 + output.html_safe + end + end + +end \ No newline at end of file diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml new file mode 100644 index 000000000..6c3ff48c0 --- /dev/null +++ b/app/views/gardens/_thumbnail.html.haml @@ -0,0 +1,27 @@ +.panel.panel-success + .panel-heading + %h3.panel-title + = link_to "#{garden.owner.login_name}'s garden", garden.owner + %a.pull-right{:href => edit_garden_path(garden), :role => "button"} + %span.glyphicon.glyphicon-pencil{:title => "Edit"} + .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= 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" + %dt Plantings + %dd + = display_garden_plantings(garden) + .panel-footer + %dt Description + %dd + = display_garden_description(garden) diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index 9fc122b36..12928b051 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -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 diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index a4bcc0044..acc9bbf6c 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -6,10 +6,10 @@ %span.glyphicon.glyphicon-pencil{:title => "Edit"} .panel-body .row - .col-md-6 + .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-6 - %dl + .col-md-8 + %dl.dl-horizontal %dt Crop %dd= link_to harvest.crop.name, harvest.crop %dt Plant part diff --git a/app/views/seeds/_thumbnail.html.haml b/app/views/seeds/_thumbnail.html.haml new file mode 100644 index 000000000..0d9a29c63 --- /dev/null +++ b/app/views/seeds/_thumbnail.html.haml @@ -0,0 +1,26 @@ +.panel.panel-success + .panel-heading + %h3.panel-title + = link_to "#{seed.owner.login_name}'s seed", seed.owner + %a.pull-right{:href => edit_seed_path(seed), :role => "button"} + %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) diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 0554984de..800c48417 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -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') From 7e03ef16871257430a9ff9724508eeecab466e43 Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Fri, 10 Jul 2015 09:56:21 +0800 Subject: [PATCH 17/33] Fixed display of plantings on gardens thumbnail. --- app/assets/stylesheets/overrides.css.less | 4 +++ app/helpers/gardens_helper.rb | 33 +++++++++-------------- app/helpers/harvests_helper.rb | 4 +-- app/helpers/seeds_helper.rb | 4 +-- app/views/gardens/_thumbnail.html.haml | 28 ++++++++++++------- app/views/harvests/_thumbnail.html.haml | 8 +++--- app/views/seeds/_thumbnail.html.haml | 10 +++---- 7 files changed, 46 insertions(+), 45 deletions(-) diff --git a/app/assets/stylesheets/overrides.css.less b/app/assets/stylesheets/overrides.css.less index ccb462404..5be07c494 100644 --- a/app/assets/stylesheets/overrides.css.less +++ b/app/assets/stylesheets/overrides.css.less @@ -328,3 +328,7 @@ html, body { .panel-footer{ height: 6em; } + +#gardens_panel_body{ + height: 20em; +} diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index 9eb40e21d..b4fb49d06 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -4,29 +4,22 @@ module GardensHelper if garden.description.nil? "no description provided." else - output = truncate(garden.description, length: 130, omission: '... ') - output += link_to('[Read more]', garden_path(garden)) if garden.description.size > 130 - output.html_safe + truncate(garden.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", garden_path(garden) } end end - def display_garden_plantings(garden) - if garden.plantings.empty? - None + def display_garden_plantings(plantings) + if plantings.blank? + "None" else - output = "" - garden.plantings.current.each do |p| - output = p.quantity.nil? ? "0 " : "#{p.quantity} " - output += link_to p.crop.name, p - output = output.html_safe - if p.planted_at - output += ", planted on #{p.planted_at}" - end - end - - output = truncate(output, length: 100, omission: '... ') - output += link_to('[View more plantings]', garden_path(garden)) if output.size > 100 - output.html_safe + output = "" + plantings.first(2).each do |planting| + output += "
  • " + output += planting.quantity.nil? ? "0 " : "#{planting.quantity} " + output += link_to planting.crop.name, planting.crop + output += ", planted on #{planting.planted_at}
  • " + end + output.html_safe end end -end \ No newline at end of file +end diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb index 7a5848066..b4c5bead4 100644 --- a/app/helpers/harvests_helper.rb +++ b/app/helpers/harvests_helper.rb @@ -41,9 +41,7 @@ module HarvestsHelper if harvest.description.nil? "no description provided." else - output = truncate(harvest.description, length: 130, omission: '... ') - output += link_to('[Read more]', harvest_path(harvest)) if harvest.description.size > 130 - output.html_safe + truncate(harvest.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", harvest_path(harvest) } end end diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb index 728ed7215..2d4f5a299 100644 --- a/app/helpers/seeds_helper.rb +++ b/app/helpers/seeds_helper.rb @@ -4,9 +4,7 @@ module SeedsHelper if seed.description.nil? "no description provided." else - output = truncate(seed.description, length: 130, omission: '... ') - output += link_to('[Read more]', seed_path(seed)) if seed.description.size > 130 - output.html_safe + truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", seed_path(seed) } end end diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml index 6c3ff48c0..926a9a258 100644 --- a/app/views/gardens/_thumbnail.html.haml +++ b/app/views/gardens/_thumbnail.html.haml @@ -4,23 +4,31 @@ = link_to "#{garden.owner.login_name}'s garden", garden.owner %a.pull-right{:href => edit_garden_path(garden), :role => "button"} %span.glyphicon.glyphicon-pencil{:title => "Edit"} - .panel-body + .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 + %dt Name : %dd= link_to garden.name, garden - %dt Location - %dd= 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" - %dt Plantings + %dt Location : %dd - = display_garden_plantings(garden) + - 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) + - if garden.plantings.count > 2 + %br + = link_to "See more plantings >>", garden_path(garden) .panel-footer %dt Description %dd diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index acc9bbf6c..aeb6e08f2 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -10,13 +10,13 @@ = 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 + %dt Crop : %dd= link_to harvest.crop.name, harvest.crop - %dt Plant part + %dt Plant part : %dd= link_to harvest.plant_part, harvest.plant_part - %dt Quantity + %dt Quantity : %dd= display_quantity(harvest) - %dt Harvest date + %dt Harvest date : %dd= harvest.harvested_at .panel-footer %dt Description diff --git a/app/views/seeds/_thumbnail.html.haml b/app/views/seeds/_thumbnail.html.haml index 0d9a29c63..2bfe5a02c 100644 --- a/app/views/seeds/_thumbnail.html.haml +++ b/app/views/seeds/_thumbnail.html.haml @@ -10,15 +10,15 @@ = 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 + %dt Crop : %dd= link_to seed.crop.name, seed.crop - %dt Plant before + %dt Plant before : %dd= seed.plant_before - %dt Quantity + %dt Quantity : %dd= seed.quantity - %dt Will trade to + %dt Will trade to : %dd= seed.tradable_to - %dt From location + %dt From location : %dd= seed.owner.location .panel-footer %dt Description From a97acfb1ca5f9f557323698fc71210f0fbf07d2a Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Fri, 10 Jul 2015 10:03:03 +0800 Subject: [PATCH 18/33] Fixed display of edit glyphicon based on edit priviledge. --- app/views/gardens/_thumbnail.html.haml | 5 +++-- app/views/harvests/_thumbnail.html.haml | 5 +++-- app/views/seeds/_thumbnail.html.haml | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml index 926a9a258..d3a65e4dd 100644 --- a/app/views/gardens/_thumbnail.html.haml +++ b/app/views/gardens/_thumbnail.html.haml @@ -2,8 +2,9 @@ .panel-heading %h3.panel-title = link_to "#{garden.owner.login_name}'s garden", garden.owner - %a.pull-right{:href => edit_garden_path(garden), :role => "button"} - %span.glyphicon.glyphicon-pencil{:title => "Edit"} + - if can? :edit, garden + %a.pull-right{:href => edit_garden_path(garden), :role => "button"} + %span.glyphicon.glyphicon-pencil{:title => "Edit"} .panel-body{:id => "gardens_panel_body"} .row .col-md-4 diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index aeb6e08f2..62195ac22 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -2,8 +2,9 @@ .panel-heading %h3.panel-title = link_to "#{harvest.owner.login_name}'s harvest", harvest.owner - %a.pull-right{:href => edit_harvest_path(harvest), :role => "button"} - %span.glyphicon.glyphicon-pencil{:title => "Edit"} + - if can? :edit, harvest + %a.pull-right{:href => edit_harvest_path(harvest), :role => "button"} + %span.glyphicon.glyphicon-pencil{:title => "Edit"} .panel-body .row .col-md-4 diff --git a/app/views/seeds/_thumbnail.html.haml b/app/views/seeds/_thumbnail.html.haml index 2bfe5a02c..be710b878 100644 --- a/app/views/seeds/_thumbnail.html.haml +++ b/app/views/seeds/_thumbnail.html.haml @@ -2,8 +2,9 @@ .panel-heading %h3.panel-title = link_to "#{seed.owner.login_name}'s seed", seed.owner - %a.pull-right{:href => edit_seed_path(seed), :role => "button"} - %span.glyphicon.glyphicon-pencil{:title => "Edit"} + - if can? :edit, seed + %a.pull-right{:href => edit_seed_path(seed), :role => "button"} + %span.glyphicon.glyphicon-pencil{:title => "Edit"} .panel-body .row .col-md-4 From 611adc0728f05ddcec90d412e2a8a9970ecd25a8 Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Fri, 10 Jul 2015 10:30:26 +0800 Subject: [PATCH 19/33] Fixed test errors for seeds and garden thumbnails. --- app/views/gardens/_thumbnail.html.haml | 2 +- app/views/seeds/_thumbnail.html.haml | 2 +- spec/features/seeds/misc_seeds_spec.rb | 2 +- spec/views/gardens/index.html.haml_spec.rb | 46 --------------- spec/views/seeds/index.html.haml_spec.rb | 69 ---------------------- 5 files changed, 3 insertions(+), 118 deletions(-) delete mode 100644 spec/views/gardens/index.html.haml_spec.rb delete mode 100644 spec/views/seeds/index.html.haml_spec.rb diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml index d3a65e4dd..4ad75d831 100644 --- a/app/views/gardens/_thumbnail.html.haml +++ b/app/views/gardens/_thumbnail.html.haml @@ -26,7 +26,7 @@ .col-md-12 %b = "#{pluralize(garden.plantings.count, "Planting")} : " - = display_garden_plantings(garden.plantings) + = display_garden_plantings(garden.plantings.current) - if garden.plantings.count > 2 %br = link_to "See more plantings >>", garden_path(garden) diff --git a/app/views/seeds/_thumbnail.html.haml b/app/views/seeds/_thumbnail.html.haml index be710b878..1968ec254 100644 --- a/app/views/seeds/_thumbnail.html.haml +++ b/app/views/seeds/_thumbnail.html.haml @@ -3,7 +3,7 @@ %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"} + %a.pull-right{:href => edit_seed_path(seed), :role => "button", :id => "edit_seed_glyphicon"} %span.glyphicon.glyphicon-pencil{:title => "Edit"} .panel-body .row diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 4c02ceecf..b7a4c4541 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -13,7 +13,7 @@ feature "seeds" do scenario "button on index to edit seed" do seed = FactoryGirl.create(:seed, :owner => @member) visit seeds_path - click_link "Edit" + click_link "edit_seed_glyphicon" current_path.should eq edit_seed_path(seed) page.should have_content 'Editing seeds' end diff --git a/spec/views/gardens/index.html.haml_spec.rb b/spec/views/gardens/index.html.haml_spec.rb deleted file mode 100644 index f776d6052..000000000 --- a/spec/views/gardens/index.html.haml_spec.rb +++ /dev/null @@ -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 diff --git a/spec/views/seeds/index.html.haml_spec.rb b/spec/views/seeds/index.html.haml_spec.rb deleted file mode 100644 index 0cf2ade0b..000000000 --- a/spec/views/seeds/index.html.haml_spec.rb +++ /dev/null @@ -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 From aa3cf729c8ae6e28635db3300c438251d2088e2b Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Mon, 13 Jul 2015 08:40:35 +0800 Subject: [PATCH 20/33] Added feature tests for on gardens, seeds and harvests for the card based thumbnails --- app/views/gardens/_thumbnail.html.haml | 2 +- app/views/harvests/_thumbnail.html.haml | 2 +- spec/features/gardens_spec.rb | 12 ++++++++++++ .../features/harvests/harvesting_a_crop_spec.rb | 17 ++++++++++++----- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml index 4ad75d831..c622098c9 100644 --- a/app/views/gardens/_thumbnail.html.haml +++ b/app/views/gardens/_thumbnail.html.haml @@ -3,7 +3,7 @@ %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"} + %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 diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index 62195ac22..fbf482079 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -3,7 +3,7 @@ %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"} + %a.pull-right{:href => edit_harvest_path(harvest), :role => "button", :id => "edit_harvest_glyphicon"} %span.glyphicon.glyphicon-pencil{:title => "Edit"} .panel-body .row diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 889fdd220..2d21a94ca 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -45,6 +45,18 @@ feature "Planting a crop", :js => true do 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") + page.should have_content 'Edit garden' + end + end + scenario "Edit garden" do visit new_garden_path fill_in "Name", :with => "New garden" diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 3719164e1..0f0d25f7e 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -26,10 +26,18 @@ feature "Harvesting a crop", :js => true do expect(page).to have_content "Harvest was successfully created" 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) + 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" + current_path.should eq edit_harvest_path(harvest) + page.should have_content 'Editing harvest' + end end scenario "Harvesting from crop page" do @@ -63,4 +71,3 @@ feature "Harvesting a crop", :js => true do end end - From 33f28d1727bbb49d8da3e9e98cd9c66415620be4 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Thu, 23 Jul 2015 10:07:10 -0400 Subject: [PATCH 21/33] Two tests required bangs on let statements in order to pass after refactoring. --- spec/features/planting_reminder_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index e90118359..10a723c90 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -26,8 +26,8 @@ feature "Planting reminder email", :js do end context "when member has some plantings" do - let(:p1) { create :planting, garden: member.gardens.first, owner: member } - let(:p2) { create :planting, garden: member.gardens.first, owner: member } + 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" @@ -48,8 +48,8 @@ feature "Planting reminder email", :js do end context "when member has some harvests" do - let(:h1) { create :harvest, owner: member } - let(:h2) { create :harvest, owner: member } + 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" @@ -58,4 +58,4 @@ feature "Planting reminder email", :js do expect(mail).to have_content "Harvested anything else lately?" end end -end +end \ No newline at end of file From ccde5b230b35c7b77916f0693b774404cd0e82fa Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Thu, 23 Jul 2015 10:12:03 -0400 Subject: [PATCH 22/33] Comments for reasoning behind adding bangs to let statements. --- spec/features/planting_reminder_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index 10a723c90..ad2173387 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -26,6 +26,8 @@ feature "Planting reminder email", :js do end context "when member has some plantings" do + # 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!(:p1) { create :planting, garden: member.gardens.first, owner: member } let!(:p2) { create :planting, garden: member.gardens.first, owner: member } @@ -48,6 +50,8 @@ feature "Planting reminder email", :js do end context "when member has some harvests" do + # 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 } From 19adabc55f973d647b4bcc91fb71ffc32f92e1c9 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Thu, 23 Jul 2015 11:27:17 -0400 Subject: [PATCH 23/33] Test for required and optional field display on Planting form. --- spec/features/plantings/planting_a_crop_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 808b70880..38a9e2672 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -14,6 +14,21 @@ feature "Planting a crop", :js => true do 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" select_from_autocomplete "maize" From efd63284360041ef155f9c15c460450e2df9000d Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Thu, 23 Jul 2015 11:32:06 -0400 Subject: [PATCH 24/33] Test for required and optional field display on Harvest form. --- spec/features/harvests/harvesting_a_crop_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 3719164e1..70d914ccb 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -12,6 +12,17 @@ feature "Harvesting a crop", :js => true do 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" From bc058b915298788ca7e9d3f34c4bbbfe818db8e6 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Thu, 23 Jul 2015 11:36:40 -0400 Subject: [PATCH 25/33] Missed a few optional field placeholders on Seed form. --- app/views/seeds/_form.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index ac3c26df4..e4682c862 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -18,20 +18,20 @@ .form-group = 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', :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.required From 69cb87fd0f5e236ee2e6bea3ed0497bff094a4b6 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Thu, 23 Jul 2015 11:36:54 -0400 Subject: [PATCH 26/33] Test that required and optional fields are displaying properly on Seed form. --- spec/features/seeds/adding_seeds_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 8fa146724..d8933f594 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -12,6 +12,23 @@ feature "Seeds", :js => true do 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" From 5a33b2b7545233f2f8dc4b7c502f6a83f759cfcf Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Thu, 23 Jul 2015 11:42:04 -0400 Subject: [PATCH 27/33] Creating a directory for gardens under spec/features (to stay consistent with other features) and moving the creation specs from spec/gardens_spec.rb to spec/gardens/adding_gardens_spec.rb. Also added the required and optional field tests for Garden form. --- spec/features/gardens/adding_gardens_spec.rb | 37 ++++++++++++++++++++ spec/features/gardens_spec.rb | 19 +--------- 2 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 spec/features/gardens/adding_gardens_spec.rb diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb new file mode 100644 index 000000000..2f2822c05 --- /dev/null +++ b/spec/features/gardens/adding_gardens_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 889fdd220..dfa67165c 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' feature "Planting a crop", :js => true do - let!(:garden) { FactoryGirl.create(:garden) } + 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) } @@ -28,23 +28,6 @@ feature "Planting a crop", :js => true do expect(page).not_to have_content "Mark as inactive" end - scenario "Create new garden" do - visit new_garden_path - 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 - scenario "Edit garden" do visit new_garden_path fill_in "Name", :with => "New garden" From b0d4f9c731e44152fc103d713f6e46f9e55d44f1 Mon Sep 17 00:00:00 2001 From: Mackenzie Morgan Date: Thu, 23 Jul 2015 13:56:07 -0400 Subject: [PATCH 28/33] switch homepage and members/ page member thumbnails to be a flexbox layout so it's more responsive. Fixes #780 --- app/assets/stylesheets/overrides.css.less | 21 ++++++++++++--- app/views/home/_members.html.haml | 6 ++--- app/views/members/_thumbnail.html.haml | 31 +++++++++++------------ app/views/members/index.html.haml | 6 ++--- 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/app/assets/stylesheets/overrides.css.less b/app/assets/stylesheets/overrides.css.less index 5be07c494..bf1943fd1 100644 --- a/app/assets/stylesheets/overrides.css.less +++ b/app/assets/stylesheets/overrides.css.less @@ -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 { diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index cca5829d6..aea526c21 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -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 diff --git a/app/views/members/_thumbnail.html.haml b/app/views/members/_thumbnail.html.haml index c90faba8a..5f0f9c58d 100644 --- a/app/views/members/_thumbnail.html.haml +++ b/app/views/members/_thumbnail.html.haml @@ -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(", ") diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index 36ba70887..0fa659ede 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -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" From e3738ca0c67ef6808d207b2c4ebcabcf2161e39f Mon Sep 17 00:00:00 2001 From: Mackenzie Morgan Date: Thu, 23 Jul 2015 13:56:23 -0400 Subject: [PATCH 29/33] whitespace tab/space correction --- app/helpers/gardens_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index b4fb49d06..dfd0a2582 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -1,7 +1,7 @@ module GardensHelper def display_garden_description(garden) - if garden.description.nil? + if garden.description.nil? "no description provided." else truncate(garden.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", garden_path(garden) } From 9e2e93b5449bbf2712c395ee0d5305ac65ee4996 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Thu, 23 Jul 2015 21:57:22 +0100 Subject: [PATCH 30/33] Remove the last few .shoulds from spec/features --- spec/features/crops/crop_detail_page_spec.rb | 2 +- spec/features/gardens_spec.rb | 6 +++--- spec/features/harvests/harvesting_a_crop_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 0ed3b3308..e0232793d 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -161,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 diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 813140062..8ae4aa1da 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -46,14 +46,14 @@ feature "Planting a crop", :js => true do 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") - page.should have_content 'Edit garden' + expect(page).to have_content 'Edit garden' end end diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 8d7a2d26f..7d61cf68c 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -35,8 +35,8 @@ feature "Harvesting a crop", :js do scenario "button on index to edit harvest" do click_link "edit_harvest_glyphicon" - current_path.should eq edit_harvest_path(harvest) - page.should have_content 'Editing harvest' + expect(current_path).to eq edit_harvest_path(harvest) + expect(page).to have_content 'Editing harvest' end end From 48649d19868152610c4e2603b8128c91627e6553 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Thu, 23 Jul 2015 22:00:06 +0100 Subject: [PATCH 31/33] Clarify comment on an order-dependent feature test --- spec/features/planting_reminder_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb index ad2173387..2891b690e 100644 --- a/spec/features/planting_reminder_spec.rb +++ b/spec/features/planting_reminder_spec.rb @@ -27,7 +27,7 @@ feature "Planting reminder email", :js do context "when member has some plantings" do # 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. + # 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 } @@ -62,4 +62,4 @@ feature "Planting reminder email", :js do expect(mail).to have_content "Harvested anything else lately?" end end -end \ No newline at end of file +end From f970fc4db27628a8107ebcbba0e6063b977e27d8 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Fri, 24 Jul 2015 11:09:22 +0100 Subject: [PATCH 32/33] Fix another whitespace problem. --- app/helpers/gardens_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/gardens_helper.rb b/app/helpers/gardens_helper.rb index dfd0a2582..57f0c7bc6 100644 --- a/app/helpers/gardens_helper.rb +++ b/app/helpers/gardens_helper.rb @@ -2,7 +2,7 @@ module GardensHelper def display_garden_description(garden) if garden.description.nil? - "no description provided." + "no description provided." else truncate(garden.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", garden_path(garden) } end From 9d62c012f1088f3d6417092ecd33f3c4ea613f8f Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sat, 25 Jul 2015 13:34:16 -0400 Subject: [PATCH 33/33] Resolves #617 - Open Service graphic link in footer --- app/views/layouts/_footer.html.haml | 3 +++ spec/features/footer_spec.rb | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index 946f45529..75e93f27f 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -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="") diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb index 400b153a4..6c0c7cead 100644 --- a/spec/features/footer_spec.rb +++ b/spec/features/footer_spec.rb @@ -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