From c244ca672fd1cbde38a0ca011c822b6c22121187 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Sun, 11 Jan 2015 11:06:36 +0000 Subject: [PATCH 1/3] Add tests for SEO of crop detail page --- spec/features/crops/crop_detail_page_spec.rb | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index a9740c131..437d3e786 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -28,5 +28,34 @@ feature "crop detail page" do end end + + context "SEO" do + + background do + visit crop_path(crop) + end + + scenario "has seed heading with SEO" do + expect(page).to have_content "Find #{ crop.name } seeds" + end + + scenario "has harvest heading with SEO" do + expect(page).to have_content "#{ crop.name.capitalize } harvests" + end + + scenario "has planting heading with SEO" do + expect(page).to have_content "See who's planted #{ crop.name.pluralize }" + end + + scenario "has planting advice with SEO" do + expect(page).to have_content "How to grow #{ crop.name }" + end + + scenario "has a link to Wikipedia with SEO" do + expect(page).to have_content "Learn more about #{ crop.name }" + expect(page).to have_link "Wikipedia (English)", crop.en_wikipedia_url + end + + end end end From d6314ea9a164785ae55575ad0795df8e37fcc3f6 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Sun, 11 Jan 2015 10:14:06 +0000 Subject: [PATCH 2/3] SEO: add crop name everywhere --- app/views/crops/_find_seeds.html.haml | 2 +- app/views/crops/_harvests.html.haml | 2 +- app/views/crops/_plantings.html.haml | 2 +- app/views/crops/show.html.haml | 20 +++++++++++--------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index 9b7797144..66990ed69 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -1,4 +1,4 @@ -%h4 Find seeds +%h4 Find #{ crop.name } seeds - if crop.seeds.empty? %p There are no seeds available to trade. diff --git a/app/views/crops/_harvests.html.haml b/app/views/crops/_harvests.html.haml index bac61e580..003e72bfa 100644 --- a/app/views/crops/_harvests.html.haml +++ b/app/views/crops/_harvests.html.haml @@ -1,4 +1,4 @@ -%h4 Harvests +%h4 #{ crop.name.capitalize } harvests - if crop.harvests.empty? %p Nobody has harvested this crop yet. diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml index 85a2ff88a..621a6d125 100644 --- a/app/views/crops/_plantings.html.haml +++ b/app/views/crops/_plantings.html.haml @@ -1,4 +1,4 @@ -%h4 Plantings +%h4 See who's planted #{ crop.name.pluralize } - if crop.plantings.empty? %p Nobody has planted this crop yet. diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 7aae050c7..144172b69 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -13,6 +13,8 @@ .row .col-md-9 + - unless current_member + Learn how to grow #{ @crop.name.pluralize } from growers around the world. #{ ENV['GROWSTUFF_SITE_NAME'] } has tips and advice from real-life growers, including when to plant #{ @crop.name.pluralize }, how to harvest #{ @crop.name.pluralize }, and more. = render :partial => 'photos', :locals => { :crop => @crop } @@ -49,22 +51,22 @@ .col-md-3 = render :partial => 'wrangle', :locals => { :crop => @crop } - = render :partial => 'scientific_names', :locals => { :crop => @crop } - = render :partial => 'alternate_names', :locals => { :crop => @crop } - %h4 Planting advice + %h4 How to grow #{ @crop.name.pluralize } = render :partial => 'grown_for', :locals => { :crop => @crop } = render :partial => 'planting_advice', :locals => { :crop => @crop } - %h4 Varieties + = render :partial => 'scientific_names', :locals => { :crop => @crop } + = render :partial => 'alternate_names', :locals => { :crop => @crop } + + %h4 #{ @crop.name.capitalize } varieties = render :partial => 'varieties', :locals => { :crop => @crop } - - %h4 More information - %ul - %li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url - = render :partial => 'plantings', :locals => { :crop => @crop } = render :partial => 'harvests', :locals => { :crop => @crop } = render :partial => 'find_seeds', :locals => { :crop => @crop } + + %h4 Learn more about #{ @crop.name.pluralize } + %ul + %li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url From a5edb6497c8e3bae33e9b8d87ae2c89983230248 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Sun, 11 Jan 2015 10:26:35 +0000 Subject: [PATCH 3/3] Display lack-of-posts nicely on crop page. --- app/views/crops/show.html.haml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 144172b69..8ef425ecd 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -36,17 +36,26 @@ %div#cropmap %a{:name => 'posts'} - %div.pagination - = page_entries_info @posts, :model => "posts" - = will_paginate @posts, :params => {:anchor => "posts"} + %h2 What people are saying about #{ @crop.name.pluralize } - - unless @posts.empty? + - if @posts.empty? + %p + Nobody has posted about #{ @crop.name.pluralize } yet. + %p + - if can? :create, Post + = link_to "Post something", new_post_path, :class => 'btn btn-default' + - else + = render :partial => "shared/signin_signup", :locals => { :to => "post your tips and experiences growing #{ @crop.name.pluralize }" } + - else + %div.pagination + = page_entries_info @posts, :model => "posts" + = will_paginate @posts, :params => {:anchor => "posts"} - @posts.each do |post| = render :partial => "posts/single", :locals => { :post => post, :subject => true } - %div.pagination - = page_entries_info @posts, :model => "posts" - = will_paginate @posts, :params => {:anchor => "posts"} + %div.pagination + = page_entries_info @posts, :model => "posts" + = will_paginate @posts, :params => {:anchor => "posts"} .col-md-3