diff options
| -rw-r--r-- | app/views/nodes/show.html.erb | 2 | ||||
| -rw-r--r-- | test/controllers/nodes_controller_test.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index 5756649..07cb5d1 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | form: { data: { confirm: "Publish this draft?" }, class: 'button_to state_changing' } %> | 49 | form: { data: { confirm: "Publish this draft?" }, class: 'button_to state_changing' } %> |
| 50 | </div> | 50 | </div> |
| 51 | <% end %> | 51 | <% end %> |
| 52 | <% if @node.draft || @node.autosave %> | 52 | <% if @node.autosave || (@node.draft && @node.head) %> |
| 53 | <div class="node_info_item"> | 53 | <div class="node_info_item"> |
| 54 | <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'), | 54 | <%= button_to (@node.draft && !@node.autosave ? 'Destroy Draft' : 'Discard Autosave'), |
| 55 | revert_node_path(@node), method: :put, | 55 | revert_node_path(@node), method: :put, |
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index 37091d5..b563d4d 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb | |||
| @@ -463,4 +463,12 @@ class NodesControllerTest < ActionController::TestCase | |||
| 463 | put :revert, params: { :id => node.id } | 463 | put :revert, params: { :id => node.id } |
| 464 | assert_redirected_to edit_node_path(node) | 464 | assert_redirected_to edit_node_path(node) |
| 465 | end | 465 | end |
| 466 | |||
| 467 | test "nodes#show does not offer to destroy the only draft of a never-published node" do | ||
| 468 | node = Node.root.children.create!(:slug => "draft_only_test") | ||
| 469 | login_as :quentin | ||
| 470 | get :show, params: { :id => node.id } | ||
| 471 | assert_response :success | ||
| 472 | assert_select "form.destructive", :count => 0 | ||
| 473 | end | ||
| 466 | end | 474 | end |
