diff options
| -rw-r--r-- | app/models/node.rb | 11 | ||||
| -rw-r--r-- | test/functional/content_controller_test.rb | 3 | ||||
| -rw-r--r-- | test/functional/nodes_controller_test.rb | 102 | ||||
| -rw-r--r-- | test/test_helper.rb | 14 | ||||
| -rw-r--r-- | test/unit/event_test.rb | 3 | ||||
| -rw-r--r-- | test/unit/node_test.rb | 59 | ||||
| -rw-r--r-- | test/unit/page_test.rb | 15 |
7 files changed, 125 insertions, 82 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index 6587585..88a4d68 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -16,9 +16,12 @@ class Node < ActiveRecord::Base | |||
| 16 | after_save :update_unique_names_of_children | 16 | after_save :update_unique_names_of_children |
| 17 | 17 | ||
| 18 | # Validations | 18 | # Validations |
| 19 | validates_length_of :slug, :within => 1..255, :unless => "parent_id.nil?" | 19 | validates_length_of :slug, :within => 1..255, :unless => "parent_id.nil?" |
| 20 | validates_presence_of :slug, :unless => "parent_id.nil?" | 20 | validates_presence_of :slug, :unless => "parent_id.nil?" |
| 21 | validates_uniqueness_of :slug, :scope => :parent_id, :unless => "parent_id.nil?" | 21 | validates_uniqueness_of :slug, :scope => :parent_id, :unless => "parent_id.nil?" |
| 22 | validates_presence_of :parent_id, :unless => "Node.root.nil?" | ||
| 23 | |||
| 24 | validate :borders # This should never ever happen. | ||
| 22 | 25 | ||
| 23 | # Index for Fulltext Search | 26 | # Index for Fulltext Search |
| 24 | define_index do | 27 | define_index do |
| @@ -183,6 +186,12 @@ class Node < ActiveRecord::Base | |||
| 183 | descendant.update_unique_name | 186 | descendant.update_unique_name |
| 184 | end | 187 | end |
| 185 | end | 188 | end |
| 189 | |||
| 190 | def borders | ||
| 191 | if lft && rgt && (lft > rgt) | ||
| 192 | errors.add("Fuck!. lft should never be smaller than rgt") | ||
| 193 | end | ||
| 194 | end | ||
| 186 | end | 195 | end |
| 187 | 196 | ||
| 188 | class LockedByAnotherUser < StandardError; end | 197 | class LockedByAnotherUser < StandardError; end |
diff --git a/test/functional/content_controller_test.rb b/test/functional/content_controller_test.rb index b76e1d5..4fb3035 100644 --- a/test/functional/content_controller_test.rb +++ b/test/functional/content_controller_test.rb | |||
| @@ -94,8 +94,7 @@ class ContentControllerTest < ActionController::TestCase | |||
| 94 | protected | 94 | protected |
| 95 | 95 | ||
| 96 | def create_node_under_root slug | 96 | def create_node_under_root slug |
| 97 | node = Node.create! :slug => slug | 97 | node = Node.root.children.create! :slug => slug |
| 98 | node.move_to_child_of Node.root | ||
| 99 | node | 98 | node |
| 100 | end | 99 | end |
| 101 | 100 | ||
diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb index eca7d93..f8d42da 100644 --- a/test/functional/nodes_controller_test.rb +++ b/test/functional/nodes_controller_test.rb | |||
| @@ -4,8 +4,7 @@ class NodesControllerTest < ActionController::TestCase | |||
| 4 | 4 | ||
| 5 | def test_get_index | 5 | def test_get_index |
| 6 | Node.root.descendants.delete_all | 6 | Node.root.descendants.delete_all |
| 7 | test_node = Node.create :slug => "foo" | 7 | test_node = Node.root.children.create :slug => "foo" |
| 8 | test_node.move_to_child_of Node.root | ||
| 9 | login_as :quentin | 8 | login_as :quentin |
| 10 | get :index | 9 | get :index |
| 11 | assert_response :success | 10 | assert_response :success |
| @@ -111,9 +110,22 @@ class NodesControllerTest < ActionController::TestCase | |||
| 111 | assert_equal "World", node.find_or_create_draft( User.first ).body | 110 | assert_equal "World", node.find_or_create_draft( User.first ).body |
| 112 | end | 111 | end |
| 113 | 112 | ||
| 113 | test "editing a locked node raises LockedByAnotherUser Exception" do | ||
| 114 | login_as :quentin | ||
| 115 | |||
| 116 | node = create_node_with_draft | ||
| 117 | node.lock_owner = User.last | ||
| 118 | node.save | ||
| 119 | |||
| 120 | assert node.locked? | ||
| 121 | |||
| 122 | get :edit, :id => node.id | ||
| 123 | assert_response :redirect | ||
| 124 | assert @response.flash[:error] =~ /Page is locked by another user/ | ||
| 125 | end | ||
| 126 | |||
| 114 | def test_update_a_draft | 127 | def test_update_a_draft |
| 115 | test_node = Node.create! :slug => "test_node" | 128 | test_node = Node.root.children.create! :slug => "test_node" |
| 116 | test_node.move_to_child_of Node.root | ||
| 117 | 129 | ||
| 118 | login_as :quentin | 130 | login_as :quentin |
| 119 | put :update, :id => test_node.id, :page => {:title => "Hello", :body => "There"} | 131 | put :update, :id => test_node.id, :page => {:title => "Hello", :body => "There"} |
| @@ -123,8 +135,7 @@ class NodesControllerTest < ActionController::TestCase | |||
| 123 | end | 135 | end |
| 124 | 136 | ||
| 125 | def test_update_a_draft_with_changing_the_template | 137 | def test_update_a_draft_with_changing_the_template |
| 126 | test_node = Node.create! :slug => "test_node" | 138 | test_node = Node.root.children.create! :slug => "test_node" |
| 127 | test_node.move_to_child_of Node.root | ||
| 128 | 139 | ||
| 129 | login_as :quentin | 140 | login_as :quentin |
| 130 | put :update, { | 141 | put :update, { |
| @@ -146,8 +157,7 @@ class NodesControllerTest < ActionController::TestCase | |||
| 146 | test "publish draft with staged_slug unqueal slug" do | 157 | test "publish draft with staged_slug unqueal slug" do |
| 147 | login_as :quentin | 158 | login_as :quentin |
| 148 | 159 | ||
| 149 | test_node = Node.create! :slug => "test_node", :staged_slug => "peter_pan" | 160 | test_node = Node.root.children.create! :slug => "test_node", :staged_slug => "peter_pan" |
| 150 | test_node.move_to_child_of Node.root | ||
| 151 | 161 | ||
| 152 | put :publish, :id => test_node.id | 162 | put :publish, :id => test_node.id |
| 153 | 163 | ||
| @@ -159,10 +169,8 @@ class NodesControllerTest < ActionController::TestCase | |||
| 159 | test "publish draft with staged_slug with more levels of nodes" do | 169 | test "publish draft with staged_slug with more levels of nodes" do |
| 160 | login_as :quentin | 170 | login_as :quentin |
| 161 | 171 | ||
| 162 | test_node = Node.create! :slug => "test_node", :staged_slug => "peter_pan" | 172 | test_node = Node.root.children.create! :slug => "test_node", :staged_slug => "peter_pan" |
| 163 | test_node.move_to_child_of Node.root | 173 | test_node2 = test_node.children.create! :slug => "test_node2" |
| 164 | test_node2 = Node.create! :slug => "test_node2" | ||
| 165 | test_node2.move_to_child_of test_node | ||
| 166 | 174 | ||
| 167 | put :publish, :id => test_node.id | 175 | put :publish, :id => test_node.id |
| 168 | 176 | ||
| @@ -174,13 +182,10 @@ class NodesControllerTest < ActionController::TestCase | |||
| 174 | test "publish draft with staged_parent_id" do | 182 | test "publish draft with staged_parent_id" do |
| 175 | login_as :quentin | 183 | login_as :quentin |
| 176 | 184 | ||
| 177 | parent = Node.create! :slug => "parent" | 185 | parent = Node.root.children.create! :slug => "parent" |
| 178 | parent.move_to_child_of Node.root | 186 | test_node = Node.root.children.create! :slug => "test_node", :staged_parent_id => parent.id |
| 179 | test_node = Node.create! :slug => "test_node", :staged_parent_id => parent.id | 187 | test_node2 = test_node.children.create! :slug => "test_node2" |
| 180 | test_node.move_to_child_of Node.root | 188 | |
| 181 | test_node2 = Node.create! :slug => "test_node2" | ||
| 182 | test_node2.move_to_child_of test_node | ||
| 183 | |||
| 184 | put :publish, :id => test_node.id | 189 | put :publish, :id => test_node.id |
| 185 | 190 | ||
| 186 | test_node.reload; test_node2.reload | 191 | test_node.reload; test_node2.reload |
| @@ -191,18 +196,15 @@ class NodesControllerTest < ActionController::TestCase | |||
| 191 | test "publish draft with staged_parent_id and staged_slug" do | 196 | test "publish draft with staged_parent_id and staged_slug" do |
| 192 | login_as :quentin | 197 | login_as :quentin |
| 193 | 198 | ||
| 194 | parent = Node.create! :slug => "parent" | 199 | parent = Node.root.children.create! :slug => "parent" |
| 195 | parent.move_to_child_of Node.root | ||
| 196 | 200 | ||
| 197 | test_node = Node.create!( | 201 | test_node = Node.root.children.create!( |
| 198 | :slug => "test_node", | 202 | :slug => "test_node", |
| 199 | :staged_parent_id => parent.id, | 203 | :staged_parent_id => parent.id, |
| 200 | :staged_slug => "peter_pan" | 204 | :staged_slug => "peter_pan" |
| 201 | ) | 205 | ) |
| 202 | test_node.move_to_child_of Node.root | ||
| 203 | 206 | ||
| 204 | test_node2 = Node.create! :slug => "test_node2" | 207 | test_node2 = test_node.children.create! :slug => "test_node2" |
| 205 | test_node2.move_to_child_of test_node | ||
| 206 | 208 | ||
| 207 | put :publish, :id => test_node.id | 209 | put :publish, :id => test_node.id |
| 208 | 210 | ||
| @@ -211,4 +213,54 @@ class NodesControllerTest < ActionController::TestCase | |||
| 211 | assert_equal "parent/peter_pan/test_node2", test_node2.unique_name | 213 | assert_equal "parent/peter_pan/test_node2", test_node2.unique_name |
| 212 | end | 214 | end |
| 213 | 215 | ||
| 216 | test "show node with empty draft" do | ||
| 217 | login_as :quentin | ||
| 218 | assert_not_nil node = create_node_with_draft | ||
| 219 | get :show, :id => node.id | ||
| 220 | assert_response :success | ||
| 221 | end | ||
| 222 | |||
| 223 | test "show node with published draft" do | ||
| 224 | login_as :quentin | ||
| 225 | node = create_node_with_published_page | ||
| 226 | get :show, :id => node.id | ||
| 227 | assert_response :success | ||
| 228 | assert_select "td", :text => "Test", :count => 3 | ||
| 229 | end | ||
| 230 | |||
| 231 | test "unlocking a locked node" do | ||
| 232 | login_as :quentin | ||
| 233 | node = create_node_with_published_page | ||
| 234 | node.find_or_create_draft User.first | ||
| 235 | |||
| 236 | assert node.locked? | ||
| 237 | |||
| 238 | get :unlock, :id => node.id | ||
| 239 | assert_response :redirect | ||
| 240 | assert !node.reload.locked? | ||
| 241 | end | ||
| 242 | |||
| 243 | test "unlocking an already unlocked node" do | ||
| 244 | login_as :quentin | ||
| 245 | node = create_node_with_published_page | ||
| 246 | |||
| 247 | get :unlock, :id => node.id | ||
| 248 | assert_response :redirect | ||
| 249 | assert_equal "Already unlocked", @response.flash[:notice] | ||
| 250 | end | ||
| 251 | |||
| 252 | test "updating a node by changing its parent" do | ||
| 253 | Node.root.descendants.destroy_all | ||
| 254 | login_as :quentin | ||
| 255 | node = create_node_with_published_page | ||
| 256 | node.find_or_create_draft User.first | ||
| 257 | |||
| 258 | other_node = Node.root.children.create( :slug => "other" ) | ||
| 259 | |||
| 260 | node.staged_parent_id = other_node.id | ||
| 261 | node.publish_draft! | ||
| 262 | |||
| 263 | assert Node.valid? | ||
| 264 | |||
| 265 | end | ||
| 214 | end | 266 | end |
diff --git a/test/test_helper.rb b/test/test_helper.rb index 21d4604..023ed96 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb | |||
| @@ -38,4 +38,18 @@ class ActiveSupport::TestCase | |||
| 38 | fixtures :all | 38 | fixtures :all |
| 39 | 39 | ||
| 40 | # Add more helper methods to be used by all tests here... | 40 | # Add more helper methods to be used by all tests here... |
| 41 | |||
| 42 | def create_node_with_published_page | ||
| 43 | node = create_node_with_draft | ||
| 44 | draft = node.draft | ||
| 45 | draft.title = "Test" | ||
| 46 | draft.abstract = "Test" | ||
| 47 | draft.body = "Test" | ||
| 48 | node.publish_draft! | ||
| 49 | node | ||
| 50 | end | ||
| 51 | |||
| 52 | def create_node_with_draft | ||
| 53 | Node.root.children.create :slug => "test_node" | ||
| 54 | end | ||
| 41 | end | 55 | end |
diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb index 78e082c..f310af8 100644 --- a/test/unit/event_test.rb +++ b/test/unit/event_test.rb | |||
| @@ -4,8 +4,7 @@ class EventTest < ActiveSupport::TestCase | |||
| 4 | 4 | ||
| 5 | def setup | 5 | def setup |
| 6 | Page.delete_all | 6 | Page.delete_all |
| 7 | @cal_node = Node.create :slug => "calendar" | 7 | @cal_node = Node.root.children.create! :slug => "calendar" |
| 8 | @cal_node.move_to_child_of Node.root | ||
| 9 | @draft = @cal_node.find_or_create_draft User.first | 8 | @draft = @cal_node.find_or_create_draft User.first |
| 10 | @draft.title = "99C3" | 9 | @draft.title = "99C3" |
| 11 | @draft.abstract = "The 99th Chaos Comunication Congress" | 10 | @draft.abstract = "The 99th Chaos Comunication Congress" |
diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index ee4d71f..92870aa 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb | |||
| @@ -16,8 +16,7 @@ class NodeTest < ActiveSupport::TestCase | |||
| 16 | end | 16 | end |
| 17 | 17 | ||
| 18 | def test_returning_existing_drafts | 18 | def test_returning_existing_drafts |
| 19 | test_node = Node.create! :slug => "test_node" | 19 | test_node = Node.root.children.create! :slug => "test_node" |
| 20 | test_node.move_to_child_of Node.root | ||
| 21 | 20 | ||
| 22 | assert_not_nil test_node.draft | 21 | assert_not_nil test_node.draft |
| 23 | assert_equal 1, test_node.pages.length | 22 | assert_equal 1, test_node.pages.length |
| @@ -39,10 +38,7 @@ class NodeTest < ActiveSupport::TestCase | |||
| 39 | 38 | ||
| 40 | def test_unique_path_returns_an_array | 39 | def test_unique_path_returns_an_array |
| 41 | assert_equal ["first_child"], @first_child.unique_path | 40 | assert_equal ["first_child"], @first_child.unique_path |
| 42 | 41 | new_node = @first_child.children.create! :slug => "third_child" | |
| 43 | new_node = Node.create! :slug => "third_child" | ||
| 44 | new_node.move_to_child_of @first_child | ||
| 45 | |||
| 46 | assert_equal ["first_child", "third_child"], new_node.unique_path | 42 | assert_equal ["first_child", "third_child"], new_node.unique_path |
| 47 | end | 43 | end |
| 48 | 44 | ||
| @@ -87,8 +83,7 @@ class NodeTest < ActiveSupport::TestCase | |||
| 87 | end | 83 | end |
| 88 | 84 | ||
| 89 | def test_created_nodes_have_an_empty_draft_and_no_head | 85 | def test_created_nodes_have_an_empty_draft_and_no_head |
| 90 | node = Node.create :slug => "third_child" | 86 | node = Node.root.children.create! :slug => "third_child_beta" |
| 91 | node.move_to_child_of @root | ||
| 92 | 87 | ||
| 93 | assert !node.pages.empty? | 88 | assert !node.pages.empty? |
| 94 | assert_equal 1, node.pages.length | 89 | assert_equal 1, node.pages.length |
| @@ -98,23 +93,18 @@ class NodeTest < ActiveSupport::TestCase | |||
| 98 | end | 93 | end |
| 99 | 94 | ||
| 100 | def test_create_new_draft_of_published_page | 95 | def test_create_new_draft_of_published_page |
| 101 | node = Node.create :slug => "xyz" | 96 | node = Node.root.children.create :slug => "xyz" |
| 102 | node.move_to_child_of @root | ||
| 103 | |||
| 104 | assert node.publish_draft! | 97 | assert node.publish_draft! |
| 105 | end | 98 | end |
| 106 | 99 | ||
| 107 | def test_find_or_create_draft_if_no_draft_exists | 100 | def test_find_or_create_draft_if_no_draft_exists |
| 108 | node = Node.create :slug => "xyz" | 101 | node = Node.root.children.create :slug => "xyz" |
| 109 | node.move_to_child_of @root | ||
| 110 | node.publish_draft! | 102 | node.publish_draft! |
| 111 | |||
| 112 | assert_not_nil node.find_or_create_draft( @user1 ) | 103 | assert_not_nil node.find_or_create_draft( @user1 ) |
| 113 | end | 104 | end |
| 114 | 105 | ||
| 115 | def test_find_or_create_draft_if_draft_exists_and_is_owned_by_user | 106 | def test_find_or_create_draft_if_draft_exists_and_is_owned_by_user |
| 116 | node = Node.create :slug => "xyz" | 107 | node = Node.root.children.create :slug => "xyz" |
| 117 | node.move_to_child_of @root | ||
| 118 | node.publish_draft! | 108 | node.publish_draft! |
| 119 | 109 | ||
| 120 | node.find_or_create_draft @user1 | 110 | node.find_or_create_draft @user1 |
| @@ -122,8 +112,7 @@ class NodeTest < ActiveSupport::TestCase | |||
| 122 | end | 112 | end |
| 123 | 113 | ||
| 124 | def test_exception_if_draft_exists_but_locked_by_another_user | 114 | def test_exception_if_draft_exists_but_locked_by_another_user |
| 125 | node = Node.create :slug => "xyz" | 115 | node = Node.root.children.create :slug => "xyz" |
| 126 | node.move_to_child_of @root | ||
| 127 | node.publish_draft! | 116 | node.publish_draft! |
| 128 | node.find_or_create_draft @user1 | 117 | node.find_or_create_draft @user1 |
| 129 | assert_equal @user1, node.lock_owner | 118 | assert_equal @user1, node.lock_owner |
| @@ -133,13 +122,11 @@ class NodeTest < ActiveSupport::TestCase | |||
| 133 | end | 122 | end |
| 134 | 123 | ||
| 135 | def test_creation_of_unique_name | 124 | def test_creation_of_unique_name |
| 136 | node = Node.create :slug => 'child' | 125 | node = Node.root.children.create :slug => 'child' |
| 137 | node.move_to_child_of @root | ||
| 138 | node.reload | 126 | node.reload |
| 139 | assert_equal 'child', node.unique_name | 127 | assert_equal 'child', node.unique_name |
| 140 | 128 | ||
| 141 | node = Node.create :slug => 'deep_child' | 129 | node = @first_child.children.create :slug => 'deep_child' |
| 142 | node.move_to_child_of @first_child | ||
| 143 | node.reload | 130 | node.reload |
| 144 | assert_equal 'first_child/deep_child', node.unique_name | 131 | assert_equal 'first_child/deep_child', node.unique_name |
| 145 | end | 132 | end |
| @@ -177,14 +164,9 @@ class NodeTest < ActiveSupport::TestCase | |||
| 177 | end | 164 | end |
| 178 | 165 | ||
| 179 | def test_retrieving_page_current | 166 | def test_retrieving_page_current |
| 180 | updates = Node.create(:slug => 'updates') | 167 | updates = Node.root.children.create(:slug => 'updates') |
| 181 | updates.move_to_child_of @root | 168 | year = updates.children.create(:slug => '2008') |
| 182 | 169 | foo = year.children.create(:slug => 'foo') | |
| 183 | year = Node.create(:slug => '2008') | ||
| 184 | year.move_to_child_of updates | ||
| 185 | |||
| 186 | foo = Node.create(:slug => 'foo') | ||
| 187 | foo.move_to_child_of year | ||
| 188 | 170 | ||
| 189 | assert_not_nil Node.find_by_unique_name('updates/2008/foo') | 171 | assert_not_nil Node.find_by_unique_name('updates/2008/foo') |
| 190 | 172 | ||
| @@ -201,14 +183,9 @@ class NodeTest < ActiveSupport::TestCase | |||
| 201 | end | 183 | end |
| 202 | 184 | ||
| 203 | def test_retrieving_page_by_revision | 185 | def test_retrieving_page_by_revision |
| 204 | updates = Node.create(:slug => 'updates') | 186 | updates = Node.root.children.create(:slug => 'updates') |
| 205 | updates.move_to_child_of @root | 187 | year = updates.children.create(:slug => '2008') |
| 206 | 188 | foo = year.children.create(:slug => 'foo') | |
| 207 | year = Node.create(:slug => '2008') | ||
| 208 | year.move_to_child_of updates | ||
| 209 | |||
| 210 | foo = Node.create(:slug => 'foo') | ||
| 211 | foo.move_to_child_of year | ||
| 212 | 189 | ||
| 213 | assert_not_nil Node.find_by_unique_name('updates/2008/foo') | 190 | assert_not_nil Node.find_by_unique_name('updates/2008/foo') |
| 214 | 191 | ||
| @@ -224,8 +201,7 @@ class NodeTest < ActiveSupport::TestCase | |||
| 224 | # Thats a lengthy test to make sure everything works as it should, it was | 201 | # Thats a lengthy test to make sure everything works as it should, it was |
| 225 | # created during a bug hunt | 202 | # created during a bug hunt |
| 226 | def test_creating_new_draft | 203 | def test_creating_new_draft |
| 227 | test_node = Node.create! :slug => "test_node" | 204 | test_node = Node.root.children.create! :slug => "test_node" |
| 228 | test_node.move_to_child_of Node.root | ||
| 229 | test_node.draft.user = @user1 | 205 | test_node.draft.user = @user1 |
| 230 | test_node.save | 206 | test_node.save |
| 231 | assert test_node.publish_draft! | 207 | assert test_node.publish_draft! |
| @@ -241,8 +217,7 @@ class NodeTest < ActiveSupport::TestCase | |||
| 241 | end | 217 | end |
| 242 | 218 | ||
| 243 | test "restoring a revision" do | 219 | test "restoring a revision" do |
| 244 | test_node = Node.create! :slug => "test_node" | 220 | test_node = Node.root.children.create! :slug => "test_node" |
| 245 | test_node.move_to_child_of Node.root | ||
| 246 | create_revisions( test_node, 3 ) | 221 | create_revisions( test_node, 3 ) |
| 247 | test_node.find_or_create_draft @user1 | 222 | test_node.find_or_create_draft @user1 |
| 248 | test_node.reload | 223 | test_node.reload |
diff --git a/test/unit/page_test.rb b/test/unit/page_test.rb index a2083c0..c2599e3 100644 --- a/test/unit/page_test.rb +++ b/test/unit/page_test.rb | |||
| @@ -9,10 +9,8 @@ class PageTest < ActiveSupport::TestCase | |||
| 9 | 9 | ||
| 10 | def test_aggregation | 10 | def test_aggregation |
| 11 | # Create two nodes and move them beneath the root node | 11 | # Create two nodes and move them beneath the root node |
| 12 | n1 = Node.create! :slug => "one" | 12 | n1 = Node.root.children.create! :slug => "one" |
| 13 | n2 = Node.create! :slug => "two" | 13 | n2 = Node.root.children.create! :slug => "two" |
| 14 | n1.move_to_child_of Node.root | ||
| 15 | n2.move_to_child_of Node.root | ||
| 16 | 14 | ||
| 17 | # get the drafts and assign a user to it | 15 | # get the drafts and assign a user to it |
| 18 | assert_not_nil d1 = n1.find_or_create_draft( @user1 ) | 16 | assert_not_nil d1 = n1.find_or_create_draft( @user1 ) |
| @@ -50,8 +48,7 @@ class PageTest < ActiveSupport::TestCase | |||
| 50 | end | 48 | end |
| 51 | 49 | ||
| 52 | def test_before_save_rewrite_links_in_body | 50 | def test_before_save_rewrite_links_in_body |
| 53 | n = Node.create :slug => "link_test" | 51 | n = Node.root.children.create :slug => "link_test" |
| 54 | n.move_to_child_of Node.root | ||
| 55 | d = n.find_or_create_draft @user1 | 52 | d = n.find_or_create_draft @user1 |
| 56 | 53 | ||
| 57 | before = "<h1>Hello World</h1>\n" \ | 54 | before = "<h1>Hello World</h1>\n" \ |
| @@ -69,8 +66,7 @@ class PageTest < ActiveSupport::TestCase | |||
| 69 | end | 66 | end |
| 70 | 67 | ||
| 71 | def test_before_save_rewrite_links_in_body_if_no_locale_prefix_present | 68 | def test_before_save_rewrite_links_in_body_if_no_locale_prefix_present |
| 72 | n = Node.create :slug => "link_test" | 69 | n = Node.root.children.create :slug => "link_test" |
| 73 | n.move_to_child_of Node.root | ||
| 74 | d = n.find_or_create_draft @user1 | 70 | d = n.find_or_create_draft @user1 |
| 75 | 71 | ||
| 76 | before = "<h1>Hello World</h1>\n" \ | 72 | before = "<h1>Hello World</h1>\n" \ |
| @@ -88,8 +84,7 @@ class PageTest < ActiveSupport::TestCase | |||
| 88 | end | 84 | end |
| 89 | 85 | ||
| 90 | def test_before_save_rewrite_links_skips_on_external_links | 86 | def test_before_save_rewrite_links_skips_on_external_links |
| 91 | n = Node.create :slug => "link_test" | 87 | n = Node.root.children.create :slug => "link_test" |
| 92 | n.move_to_child_of Node.root | ||
| 93 | d = n.find_or_create_draft @user1 | 88 | d = n.find_or_create_draft @user1 |
| 94 | 89 | ||
| 95 | before = "<h1>Hello World</h1>\n" \ | 90 | before = "<h1>Hello World</h1>\n" \ |
