Improving test coverage for gardens

This commit is contained in:
Skud committed 2014-08-30 11:28:52 +10:00
1 parent 4ebc184188
commit fbeafd4299
2 files changed
+40 -2

No files matched your search

+1 -1
View File
@@ -85,7 +85,7 @@ class GardensController < ApplicationController
@garden.destroy
respond_to do |format|
format.html { redirect_to @garden.owner, notice: 'Garden was successfully deleted.' }
format.html { redirect_to gardens_by_owner_path(:owner => @garden.owner), notice: 'Garden was successfully deleted.' }
format.json { head :no_content }
end
end
+39 -1
View File
@@ -5,10 +5,19 @@ feature "Planting a crop", :js => true do
background do
login_as(garden.owner)
visit garden_path(garden)
end
scenario "View gardens" do
visit gardens_path
expect(page).to have_content "Everyone's gardens"
click_link "View your gardens"
expect(page).to have_content "#{garden.owner.login_name}'s gardens"
click_link "View everyone's gardens"
expect(page).to have_content "Everyone's gardens"
end
scenario "Marking a garden as inactive" do
visit garden_path(garden)
click_link "Mark as inactive"
expect(page).to have_content "Garden was successfully updated"
expect(page).to have_content "This garden is inactive"
@@ -16,4 +25,33 @@ feature "Planting a crop", :js => true do
expect(page).not_to have_content "Mark as inactive"
end
scenario "Create new garden" do
visit new_garden_path
fill_in "Name", :with => "New garden"
click_button "Save"
expect(page).to have_content "Garden was successfully created"
expect(page).to have_content "New garden"
end
scenario "Edit garden" do
visit new_garden_path
fill_in "Name", :with => "New garden"
click_button "Save"
click_link "Edit garden"
fill_in "Name", :with => "Different name"
click_button "Save"
expect(page).to have_content "Garden was successfully updated"
expect(page).to have_content "Different name"
end
scenario "Delete garden" do
visit new_garden_path
fill_in "Name", :with => "New garden"
click_button "Save"
visit garden_path(Garden.last)
click_link "Delete garden"
expect(page).to have_content "Garden was successfully deleted"
expect(page).to have_content "#{garden.owner}'s gardens"
end
end