From 3b35b3a0bba7991a243eb794303b838ae90bb69c Mon Sep 17 00:00:00 2001 From: hukl Date: Mon, 2 Nov 2009 22:19:32 +0100 Subject: add tests --- test/functional/nodes_controller_test.rb | 26 +++++++++++++++++++++++++- test/test_helper.rb | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb index 8710c0b..4088986 100644 --- a/test/functional/nodes_controller_test.rb +++ b/test/functional/nodes_controller_test.rb @@ -283,7 +283,31 @@ class NodesControllerTest < ActionController::TestCase put :update, :id => node.id, :page => {:user_id => users(:aaron).id} assert_response :redirect assert_equal "aaron", node.reload.draft.user.login - + end + + test "updating an existing page should not modify published_at" do + login_as :quentin + Node.root.descendants.destroy_all + node = create_node_with_published_page + + get :edit, :id => node.id + assert_response :success + put :publish, :id => node.id + + node.reload + assert_equal node.pages[0].published_at, node.pages[1].published_at + end + + test "updating an exisiting page should not alter the author" do + login_as :aaron + Node.root.descendants.destroy_all + node = create_node_with_published_page + get :edit, :id => node.id + + put :publish, :id => node.id + + node.reload + assert_equal node.pages[0].user, node.pages[1].user end end diff --git a/test/test_helper.rb b/test/test_helper.rb index cda54bc..22747bb 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -42,6 +42,7 @@ class ActiveSupport::TestCase def create_node_with_published_page node = create_node_with_draft draft = node.draft + draft.published_at = Time.now draft.title = "Test" draft.abstract = "Test" draft.body = "Test" -- cgit v1.3