File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,15 @@ def update
39
39
end
40
40
end
41
41
42
+ def destroy
43
+ @project = Project . find ( params [ :id ] )
44
+ @project . destroy
45
+
46
+ flash [ :notice ] = "Project has been destroyed."
47
+
48
+ redirect_to projects_path
49
+ end
50
+
42
51
private
43
52
44
53
def project_params
Original file line number Diff line number Diff line change 1
1
<% title(@project.name, "Projects") %>
2
2
<h2 > <%= @project . name %> </ h2 >
3
3
<%= link_to "Edit Project" , edit_project_path ( @project ) %>
4
+ <%= link_to "Delete Project" ,
5
+ project_path ( @project ) ,
6
+ method : :delete ,
7
+ data : { confirm :
8
+ "Are you sure you want to delete this project?"
9
+ } %>
Original file line number Diff line number Diff line change
1
+ require "rails_helper"
2
+
3
+ feature "Deleting projects" do
4
+ scenario "Deleting a project" do
5
+ FactoryGirl . create ( :project , name : "Sublime Text 3" )
6
+
7
+ visit "/"
8
+ click_link "Sublime Text 3"
9
+ click_link "Delete Project"
10
+
11
+ expect ( page ) . to have_content ( "Project has been destroyed." )
12
+
13
+ visit "/"
14
+
15
+ expect ( page ) . to have_no_content ( "Sublime Text 3" )
16
+ end
17
+ end
You can’t perform that action at this time.
0 commit comments