From 46393ff96561d1865da2990204a57ae567376dba Mon Sep 17 00:00:00 2001
From: Diego Araújo + Rafael Manzo
+ <%= link_to 'Destroy', project_path(@project.id), method: :delete, data: { confirm: 'Are you sure?' } %> +
+ +<%= link_to 'Back', projects_path %> diff --git a/features/project.feature b/features/project.feature index f2e57d4..9c6c803 100644 --- a/features/project.feature +++ b/features/project.feature @@ -48,7 +48,7 @@ Feature: Project And the sample project should be there @wip @kalibro_restart - Scenario: Should back to the All Projects page from show project view + Scenario: Should go back to the All Projects page from show project view Given I am a regular user And I am signed in And I have a sample project @@ -64,7 +64,17 @@ Feature: Project And I am at the All Projects page When I click the Edit link Then I should be in the Edit Project page - + + @kalibro_restart + Scenario: Should delete a project + Given I am a regular user + And I am signed in + And I have a sample project + And I am at the Sample Project page + When I click the Destroy link + Then I should be in the All Projects page + And the sample project should not be there + @kalibro_restart Scenario: Should have the content filled in form Given I am a regular user diff --git a/features/step_definitions/project_steps.rb b/features/step_definitions/project_steps.rb index 2621ab0..41d7dd5 100644 --- a/features/step_definitions/project_steps.rb +++ b/features/step_definitions/project_steps.rb @@ -1,3 +1,5 @@ +require 'kalibro_entities/errors' + Given(/^I am at the All Projects page$/) do visit projects_path end @@ -35,6 +37,10 @@ Then(/^I should be in the Edit Project page$/) do page.should have_content("Edit Project") end +Then(/^the sample project should not be there$/) do + expect { Project.find(@project.id) }.to raise_error +end + Then(/^The field "(.*?)" should be filled with the sample project "(.*?)"$/) do |field, value| page.find_field(field).value.should eq(@project.send(value)) end diff --git a/features/support/env.rb b/features/support/env.rb index 5e6e884..4c406f1 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -19,6 +19,9 @@ end # files. require 'cucumber/rails' +require 'capybara/poltergeist' +#Capybara.default_driver = :poltergeist +Capybara.javascript_driver = :poltergeist #require 'kalibro_entities/kalibro_cucumber_helpers/hooks' @@ -79,4 +82,4 @@ require 'kalibro_entities/kalibro_cucumber_helpers/hooks' KalibroEntities::KalibroCucumberHelpers.configure_from_yml("#{__dir__}/kalibro_cucumber_helpers.yml") # Warden test helpers so the user authentication can be as fast as possible -include Warden::Test::Helpers \ No newline at end of file +include Warden::Test::Helpers diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 32f677b..7333a06 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -68,6 +68,21 @@ describe ProjectsController do it { should render_template(:show) } end + describe 'delete' do + before :each do + @subject = FactoryGirl.build(:project) + @subject.expects(:destroy) + Project.expects(:find).with(@subject.id.to_s).returns(@subject) + delete :destroy, :id => @subject.id + end + + it 'should redirect to the projects page' do + response.should redirect_to project_url + end + + it { should respond_with(:redirect) } + end + describe 'index' do before :each do @subject = FactoryGirl.build(:project) @@ -139,4 +154,4 @@ describe ProjectsController do end end -end \ No newline at end of file +end -- libgit2 0.21.2