Commit 46393ff96561d1865da2990204a57ae567376dba
Committed by
Rafael Manzo
1 parent
f526e692
Exists in
colab
and in
4 other branches
Project destroy.
In order to get acceptance test running, poltergeist has been installed.
Showing
8 changed files
with
64 additions
and
5 deletions
Show diff stats
Gemfile
@@ -76,6 +76,7 @@ group :cucumber do | @@ -76,6 +76,7 @@ group :cucumber do | ||
76 | #Fixed the cumcumber version since the version 1.3.4 causes tests failure | 76 | #Fixed the cumcumber version since the version 1.3.4 causes tests failure |
77 | gem 'cucumber', '1.3.2' | 77 | gem 'cucumber', '1.3.2' |
78 | gem 'database_cleaner' | 78 | gem 'database_cleaner' |
79 | + gem 'poltergeist', '~> 1.3.0' | ||
79 | end | 80 | end |
80 | 81 | ||
81 | # Use ActiveModel has_secure_password | 82 | # Use ActiveModel has_secure_password |
Gemfile.lock
@@ -76,6 +76,7 @@ GEM | @@ -76,6 +76,7 @@ GEM | ||
76 | warden (~> 1.2.3) | 76 | warden (~> 1.2.3) |
77 | diff-lcs (1.2.4) | 77 | diff-lcs (1.2.4) |
78 | erubis (2.7.0) | 78 | erubis (2.7.0) |
79 | + eventmachine (1.0.3) | ||
79 | execjs (1.4.0) | 80 | execjs (1.4.0) |
80 | multi_json (~> 1.0) | 81 | multi_json (~> 1.0) |
81 | factory_girl (4.2.0) | 82 | factory_girl (4.2.0) |
@@ -83,12 +84,15 @@ GEM | @@ -83,12 +84,15 @@ GEM | ||
83 | factory_girl_rails (4.2.1) | 84 | factory_girl_rails (4.2.1) |
84 | factory_girl (~> 4.2.0) | 85 | factory_girl (~> 4.2.0) |
85 | railties (>= 3.0.0) | 86 | railties (>= 3.0.0) |
87 | + faye-websocket (0.4.7) | ||
88 | + eventmachine (>= 0.12.0) | ||
86 | gherkin (2.12.1) | 89 | gherkin (2.12.1) |
87 | multi_json (~> 1.3) | 90 | multi_json (~> 1.3) |
88 | gyoku (1.1.0) | 91 | gyoku (1.1.0) |
89 | builder (>= 2.1.2) | 92 | builder (>= 2.1.2) |
90 | highline (1.6.19) | 93 | highline (1.6.19) |
91 | hike (1.2.3) | 94 | hike (1.2.3) |
95 | + http_parser.rb (0.5.3) | ||
92 | httpi (2.1.0) | 96 | httpi (2.1.0) |
93 | rack | 97 | rack |
94 | rubyntlm (~> 0.3.2) | 98 | rubyntlm (~> 0.3.2) |
@@ -122,6 +126,10 @@ GEM | @@ -122,6 +126,10 @@ GEM | ||
122 | nori (2.3.0) | 126 | nori (2.3.0) |
123 | orm_adapter (0.4.0) | 127 | orm_adapter (0.4.0) |
124 | pg (0.16.0) | 128 | pg (0.16.0) |
129 | + poltergeist (1.3.0) | ||
130 | + capybara (~> 2.1.0) | ||
131 | + faye-websocket (>= 0.4.4, < 0.5.0) | ||
132 | + http_parser.rb (~> 0.5.3) | ||
125 | polyglot (0.3.3) | 133 | polyglot (0.3.3) |
126 | rack (1.5.2) | 134 | rack (1.5.2) |
127 | rack-test (0.6.2) | 135 | rack-test (0.6.2) |
@@ -230,6 +238,7 @@ DEPENDENCIES | @@ -230,6 +238,7 @@ DEPENDENCIES | ||
230 | mocha | 238 | mocha |
231 | modernizr-rails | 239 | modernizr-rails |
232 | pg (~> 0.16.0) | 240 | pg (~> 0.16.0) |
241 | + poltergeist (~> 1.3.0) | ||
233 | rails (= 4.0.0) | 242 | rails (= 4.0.0) |
234 | rspec-rails | 243 | rspec-rails |
235 | rvm-capistrano | 244 | rvm-capistrano |
app/controllers/projects_controller.rb
@@ -48,6 +48,17 @@ class ProjectsController < ApplicationController | @@ -48,6 +48,17 @@ class ProjectsController < ApplicationController | ||
48 | end | 48 | end |
49 | end | 49 | end |
50 | 50 | ||
51 | + # DELETE /project/1 | ||
52 | + # DELETE /project/1.json | ||
53 | + def destroy | ||
54 | + set_project | ||
55 | + @project.destroy | ||
56 | + respond_to do |format| | ||
57 | + format.html { redirect_to projects_url } | ||
58 | + format.json { head :no_content } | ||
59 | + end | ||
60 | + end | ||
61 | + | ||
51 | private | 62 | private |
52 | # Use callbacks to share common setup or constraints between actions. | 63 | # Use callbacks to share common setup or constraints between actions. |
53 | def set_project | 64 | def set_project |
app/views/projects/show.html.erb
@@ -8,4 +8,8 @@ | @@ -8,4 +8,8 @@ | ||
8 | <%= @project.description %> | 8 | <%= @project.description %> |
9 | </p> | 9 | </p> |
10 | 10 | ||
11 | -<%= link_to 'Back', root_path %> | 11 | +<p> |
12 | + <%= link_to 'Destroy', project_path(@project.id), method: :delete, data: { confirm: 'Are you sure?' } %> | ||
13 | +</p> | ||
14 | + | ||
15 | +<%= link_to 'Back', projects_path %> |
features/project.feature
@@ -48,7 +48,7 @@ Feature: Project | @@ -48,7 +48,7 @@ Feature: Project | ||
48 | And the sample project should be there | 48 | And the sample project should be there |
49 | 49 | ||
50 | @wip @kalibro_restart | 50 | @wip @kalibro_restart |
51 | - Scenario: Should back to the All Projects page from show project view | 51 | + Scenario: Should go back to the All Projects page from show project view |
52 | Given I am a regular user | 52 | Given I am a regular user |
53 | And I am signed in | 53 | And I am signed in |
54 | And I have a sample project | 54 | And I have a sample project |
@@ -64,7 +64,17 @@ Feature: Project | @@ -64,7 +64,17 @@ Feature: Project | ||
64 | And I am at the All Projects page | 64 | And I am at the All Projects page |
65 | When I click the Edit link | 65 | When I click the Edit link |
66 | Then I should be in the Edit Project page | 66 | Then I should be in the Edit Project page |
67 | - | 67 | + |
68 | + @kalibro_restart | ||
69 | + Scenario: Should delete a project | ||
70 | + Given I am a regular user | ||
71 | + And I am signed in | ||
72 | + And I have a sample project | ||
73 | + And I am at the Sample Project page | ||
74 | + When I click the Destroy link | ||
75 | + Then I should be in the All Projects page | ||
76 | + And the sample project should not be there | ||
77 | + | ||
68 | @kalibro_restart | 78 | @kalibro_restart |
69 | Scenario: Should have the content filled in form | 79 | Scenario: Should have the content filled in form |
70 | Given I am a regular user | 80 | Given I am a regular user |
features/step_definitions/project_steps.rb
1 | +require 'kalibro_entities/errors' | ||
2 | + | ||
1 | Given(/^I am at the All Projects page$/) do | 3 | Given(/^I am at the All Projects page$/) do |
2 | visit projects_path | 4 | visit projects_path |
3 | end | 5 | end |
@@ -35,6 +37,10 @@ Then(/^I should be in the Edit Project page$/) do | @@ -35,6 +37,10 @@ Then(/^I should be in the Edit Project page$/) do | ||
35 | page.should have_content("Edit Project") | 37 | page.should have_content("Edit Project") |
36 | end | 38 | end |
37 | 39 | ||
40 | +Then(/^the sample project should not be there$/) do | ||
41 | + expect { Project.find(@project.id) }.to raise_error | ||
42 | +end | ||
43 | + | ||
38 | Then(/^The field "(.*?)" should be filled with the sample project "(.*?)"$/) do |field, value| | 44 | Then(/^The field "(.*?)" should be filled with the sample project "(.*?)"$/) do |field, value| |
39 | page.find_field(field).value.should eq(@project.send(value)) | 45 | page.find_field(field).value.should eq(@project.send(value)) |
40 | end | 46 | end |
features/support/env.rb
@@ -19,6 +19,9 @@ end | @@ -19,6 +19,9 @@ end | ||
19 | # files. | 19 | # files. |
20 | 20 | ||
21 | require 'cucumber/rails' | 21 | require 'cucumber/rails' |
22 | +require 'capybara/poltergeist' | ||
23 | +#Capybara.default_driver = :poltergeist | ||
24 | +Capybara.javascript_driver = :poltergeist | ||
22 | 25 | ||
23 | #require 'kalibro_entities/kalibro_cucumber_helpers/hooks' | 26 | #require 'kalibro_entities/kalibro_cucumber_helpers/hooks' |
24 | 27 | ||
@@ -79,4 +82,4 @@ require 'kalibro_entities/kalibro_cucumber_helpers/hooks' | @@ -79,4 +82,4 @@ require 'kalibro_entities/kalibro_cucumber_helpers/hooks' | ||
79 | KalibroEntities::KalibroCucumberHelpers.configure_from_yml("#{__dir__}/kalibro_cucumber_helpers.yml") | 82 | KalibroEntities::KalibroCucumberHelpers.configure_from_yml("#{__dir__}/kalibro_cucumber_helpers.yml") |
80 | 83 | ||
81 | # Warden test helpers so the user authentication can be as fast as possible | 84 | # Warden test helpers so the user authentication can be as fast as possible |
82 | -include Warden::Test::Helpers | ||
83 | \ No newline at end of file | 85 | \ No newline at end of file |
86 | +include Warden::Test::Helpers |
spec/controllers/projects_controller_spec.rb
@@ -68,6 +68,21 @@ describe ProjectsController do | @@ -68,6 +68,21 @@ describe ProjectsController do | ||
68 | it { should render_template(:show) } | 68 | it { should render_template(:show) } |
69 | end | 69 | end |
70 | 70 | ||
71 | + describe 'delete' do | ||
72 | + before :each do | ||
73 | + @subject = FactoryGirl.build(:project) | ||
74 | + @subject.expects(:destroy) | ||
75 | + Project.expects(:find).with(@subject.id.to_s).returns(@subject) | ||
76 | + delete :destroy, :id => @subject.id | ||
77 | + end | ||
78 | + | ||
79 | + it 'should redirect to the projects page' do | ||
80 | + response.should redirect_to project_url | ||
81 | + end | ||
82 | + | ||
83 | + it { should respond_with(:redirect) } | ||
84 | + end | ||
85 | + | ||
71 | describe 'index' do | 86 | describe 'index' do |
72 | before :each do | 87 | before :each do |
73 | @subject = FactoryGirl.build(:project) | 88 | @subject = FactoryGirl.build(:project) |
@@ -139,4 +154,4 @@ describe ProjectsController do | @@ -139,4 +154,4 @@ describe ProjectsController do | ||
139 | end | 154 | end |
140 | end | 155 | end |
141 | 156 | ||
142 | -end | ||
143 | \ No newline at end of file | 157 | \ No newline at end of file |
158 | +end |