From fea7da3546f2fccfe6cd265b14afb8cc483a3441 Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 30 Jun 2014 12:14:06 -0700 Subject: [PATCH] rearranged crop page headings and added tests --- app/views/crops/show.html.haml | 13 ++++++++--- spec/views/crops/show.html.haml_spec.rb | 29 +++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 0cee3b1a6..a19421ff1 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -16,9 +16,7 @@ = render :partial => 'photos', :locals => { :crop => @crop } - %h2 Who's planted this crop? - - %p + %h2 - if @crop.plantings.size > 0 = @crop.name.titleize has been planted @@ -27,9 +25,18 @@ - else Nobody is growing this yet. You could be the first! + %p + Only plantings by members who have set their locations are shown on this map. + - if current_member && current_member.location.blank? + = link_to "Set your location.", edit_member_registration_path + + %div#map - if @crop.plantings.size > 0 + + %h2 All plantings + - @crop.plantings.each do |p| = render :partial => "plantings/thumbnail", :locals => { :planting => p, :title => 'owner' } diff --git a/spec/views/crops/show.html.haml_spec.rb b/spec/views/crops/show.html.haml_spec.rb index 4b637cc1d..1805dc7e1 100644 --- a/spec/views/crops/show.html.haml_spec.rb +++ b/spec/views/crops/show.html.haml_spec.rb @@ -33,6 +33,35 @@ describe "crops/show" do end end + context "map" do + it "has a map" do + render + assert_select("div#map") + end + + it "explains what's shown on the map" do + render + rendered.should contain "Only plantings by members who have set their locations are shown on this map" + end + + it "shows a 'set your location' link to people who need to" do + @nowhere = FactoryGirl.create(:member) + sign_in @nowhere + controller.stub(:current_user) { @nowhere } + render + rendered.should contain "Set your location" + end + + it "doesn't show 'set your location' to people who have one" do + @somewhere = FactoryGirl.create(:london_member) + sign_in @somewhere + controller.stub(:current_user) { @somewhere } + render + rendered.should_not contain "Set your location" + end + + end + it "shows the wikipedia URL" do render assert_select("a[href=#{@crop.en_wikipedia_url}]", 'Wikipedia (English)')