From 144b18c5db61c53028177680295f3fc9d4e8711d Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 18 Jul 2009 18:17:06 +0200 Subject: Test::Unit Fixtures can't handle globalize2's translated attributes which is why its impossible to set translated attributes via fixtures. Therefor I removed the page fixtures entirely and and made sure that a title is set to "Untitled" when it is not specified otherwise. If a new node is created, its initial draft has "Untitled" set as title automatically. Modified tests accordingly --- test/fixtures/pages.yml | 64 +++++++++++++++++--------------- test/functional/nodes_controller_test.rb | 4 ++ test/unit/node_test.rb | 4 ++ test/unit/page_test.rb | 6 +-- 4 files changed, 46 insertions(+), 32 deletions(-) (limited to 'test') diff --git a/test/fixtures/pages.yml b/test/fixtures/pages.yml index 271c494..686f173 100644 --- a/test/fixtures/pages.yml +++ b/test/fixtures/pages.yml @@ -1,31 +1,37 @@ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -one: - id: 1 - revision: 1 - node_id: 2 - -two: - id: 2 - revision: 1 - node_id: 4 - -draft1: - id: 100 - revision: 1 - node_id: 2 - -draft2: - id: 101 - revision: 1 - node_id: 3 - -draft3: - id: 102 - revision: 1 - node_id: 4 - -draft4: - id: 103 - revision: 1 - node_id: 5 \ No newline at end of file +# one: +# id: 1 +# revision: 1 +# node_id: 2 +# title: "first" +# +# two: +# id: 2 +# revision: 1 +# node_id: 4 +# title: "second" +# +# draft1: +# id: 100 +# revision: 1 +# node_id: 2 +# title: "third" +# +# draft2: +# id: 101 +# revision: 1 +# node_id: 3 +# title: "fourth" +# +# draft3: +# id: 102 +# revision: 1 +# node_id: 4 +# title: "fifth" +# +# draft4: +# id: 103 +# revision: 1 +# node_id: 5 +# title: "sixth" \ No newline at end of file diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb index edc49b6..1c7e607 100644 --- a/test/functional/nodes_controller_test.rb +++ b/test/functional/nodes_controller_test.rb @@ -5,6 +5,7 @@ class NodesControllerTest < ActionController::TestCase include AuthenticatedTestHelper def test_get_index + Node.root.descendants.delete_all login_as :quentin get :index assert_response :success @@ -26,6 +27,9 @@ class NodesControllerTest < ActionController::TestCase login_as :quentin node = Node.find_by_unique_name("fourth_child") + node.pages.create + node.draft = node.pages.last + node.save assert_equal 1, node.pages.length diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index e054887..ef298bb 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb @@ -5,7 +5,11 @@ class NodeTest < ActiveSupport::TestCase def setup @root = Node.find(1) @first_child = Node.find(2) + @first_child.pages.create! :title => "one" + @first_child.draft = @first_child.pages.last + @first_child.save @second_child = Node.find(3) + @second_child.pages.create! :title => "one" @user1 = User.create :login => 'demo', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar' @user2 = User.create :login => 'show', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar' diff --git a/test/unit/page_test.rb b/test/unit/page_test.rb index 8c2fc95..a2083c0 100644 --- a/test/unit/page_test.rb +++ b/test/unit/page_test.rb @@ -22,7 +22,7 @@ class PageTest < ActiveSupport::TestCase d1.tag_list = "update" d1.save n1.publish_draft! - + d2 = n1.find_or_create_draft @user1 n1.publish_draft! @@ -30,7 +30,7 @@ class PageTest < ActiveSupport::TestCase d3.tag_list = "update, pressemitteilung" d3.save n2.publish_draft! - + d4 = n2.find_or_create_draft @user1 n2.publish_draft! @@ -63,7 +63,7 @@ class PageTest < ActiveSupport::TestCase I18n.locale = :de d.body = before - d.save + d.save! assert_equal after, d.body end -- cgit v1.3