rearranged crop page headings and added tests

This commit is contained in:
Skud
2014-06-30 12:14:06 -07:00
parent f8cb7248b7
commit fea7da3546
2 changed files with 39 additions and 3 deletions

View File

@@ -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' }

View File

@@ -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)')