From 77d1d067fa0fa6d74accda5f54795633574ff579 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Sat, 18 Oct 2014 15:35:57 +0100 Subject: [PATCH] Crop wranglers can add alternate names --- app/views/crops/show.html.haml | 3 +++ spec/features/crop_spec.rb | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 5d74f6d8a..ad5abab1b 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -81,6 +81,9 @@ = link_to 'Edit', edit_alternate_name_path(an), { :class => 'btn btn-default btn-xs' } - if can? :destroy, an = link_to 'Delete', an, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs' + %p + - if can? :edit, @crop + = link_to 'Add', new_alternate_name_path( :crop_id => @crop.id ), { :class => 'btn btn-default btn-xs' } = render :partial => 'varieties', :locals => { :crop => @crop } diff --git a/spec/features/crop_spec.rb b/spec/features/crop_spec.rb index 9f825015f..52620da81 100644 --- a/spec/features/crop_spec.rb +++ b/spec/features/crop_spec.rb @@ -34,6 +34,12 @@ feature "Alternate names" do href: alternate_name_path(alternate_eggplant) end + scenario "Crop wranglers can add alternate names" do + crop = alternate_eggplant.crop + visit crop_path(crop) + expect(page).to have_link "Add", + href: new_alternate_name_path(crop_id: crop.id) + end end end