From aa3cf729c8ae6e28635db3300c438251d2088e2b Mon Sep 17 00:00:00 2001 From: AELOGICA Date: Mon, 13 Jul 2015 08:40:35 +0800 Subject: [PATCH] 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 -