diff --git a/test/fixtures/friendly_id_slugs.yml b/test/fixtures/friendly_id_slugs.yml
new file mode 100644
index 00000000000..ee4cd96babc
--- /dev/null
+++ b/test/fixtures/friendly_id_slugs.yml
@@ -0,0 +1,55 @@
+one:
+ id: 1
+ slug: canon-a1200-ir-conversion-at-plots-barnraising-at-lumcon
+ sluggable_id: 1
+ sluggable_type: DrupalNode
+ created_at: <%= Time.now %>
+
+two:
+ id: 2
+ slug: about
+ sluggable_id: 2
+ sluggable_type: DrupalNode
+ created_at: <%= Time.now %>
+
+three:
+ id: 3
+ slug: hot-stuff-i-m-selling
+ sluggable_id: 3
+ sluggable_type: DrupalNode
+ created_at: <%= Time.now %>
+
+four:
+ id: 4
+ slug: important-work
+ sluggable_id: 4
+ sluggable_type: DrupalNode
+ created_at: <%= Time.now %>
+
+five:
+ id: 5
+ slug: organizers
+ sluggable_id: 5
+ sluggable_type: DrupalNode
+ created_at: <%= Time.now %>
+
+six:
+ id: 6
+ slug: my-very-first-post-to-public-lab
+ sluggable_id: 6
+ sluggable_type: DrupalNode
+ created_at: <%= Time.now %>
+
+seven:
+ id: 7
+ slug: chicago
+ sluggable_id: 7
+ sluggable_type: DrupalNode
+ created_at: <%= Time.now %>
+
+eight:
+ id: 8
+ slug: how-to-use-a-spectrometer
+ sluggable_id: 8
+ sluggable_type: DrupalNode
+ created_at: <%= Time.now %>
diff --git a/test/fixtures/node.yml b/test/fixtures/node.yml
index 989e96ddd29..4ea1f93727f 100644
--- a/test/fixtures/node.yml
+++ b/test/fixtures/node.yml
@@ -8,6 +8,7 @@ one:
status: 1
type: "note"
cached_likes: 0
+ slug: canon-a1200-ir-conversion-at-plots-barnraising-at-lumcon
about:
nid: 2
@@ -19,6 +20,7 @@ about:
status: 1
type: "page"
cached_likes: 0
+ slug: about
spam:
nid: 3
@@ -30,17 +32,19 @@ spam:
status: 0
type: "note"
cached_likes: 0
+ slug: hot-stuff-i-m-selling
spam_targeted_page:
nid: 4
uid: 1
title: "Important work"
- path: "/wiki/important"
+ path: "/wiki/important-work"
created: <%= Time.now.to_i %>
changed: <%= Time.now.to_i %>
status: 1
type: "page"
cached_likes: 0
+ slug: important-work
organizers:
nid: 5
@@ -52,6 +56,7 @@ organizers:
status: 1
type: "page"
cached_likes: 0
+ slug: organizers
first_timer_note:
nid: 6
@@ -63,6 +68,7 @@ first_timer_note:
status: 4
type: "note"
cached_likes: 0
+ slug: my-very-first-post-to-public-lab
place:
nid: 7
@@ -74,6 +80,7 @@ place:
status: 1
type: "wiki"
cached_likes: 0
+ slug: chicago
question:
nid: 8
@@ -85,3 +92,4 @@ question:
status: 1
type: "note"
cached_likes: 0
+ slug: how-to-use-a-spectrometer
diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb
index d3149104d8f..62da71a5e60 100644
--- a/test/functional/notes_controller_test.rb
+++ b/test/functional/notes_controller_test.rb
@@ -54,7 +54,6 @@ def setup
test "don't show note by spam author" do
note = node(:spam) # spam fixture
-
get :show,
author: note.author.name,
date: Time.at(note.created).strftime("%m-%d-%Y"),
@@ -235,45 +234,6 @@ def setup
#end
- test "edit note" do
- UserSession.create(rusers(:bob))
- title = "My second post about balloon mapping"
-
- post :create,
- title: title,
- body: "This is a fascinating post about a balloon mapping event.",
- tags: "balloon-mapping,event"
- #, main_image: "/images/testimage.jpg"
-
- assert_redirected_to "/notes/"+rusers(:bob).username+"/"+Time.now.strftime("%m-%d-%Y")+"/"+title.parameterize
-
- node = DrupalNode.where(title: title).first
-
- # add a tag, and change the title and body
- newtitle = title + " which I amended"
-
- post :update,
- id: node.id,
- title: newtitle,
- body: "This is a fascinating post about a balloon mapping event. added content",
- tags: "balloon-mapping,event,meetup"
-
- assert_redirected_to "/notes/" + rusers(:bob).username + "/" + Time.now.strftime("%m-%d-%Y") + "/" + title.parameterize + "?_=" + Time.now.to_i.to_s
-
- # approve the first-timer's note:
- node.publish
-
- get :show,
- author: rusers(:bob).username,
- date: Time.now.strftime("%m-%d-%Y"),
- id: title.parameterize
-
- assert_equal flash[:notice], "Edits saved."
- assert_select "h1", newtitle
- # assert_select "span#teststring", "added content" # this test does not work!! very frustrating.
- # assert_select ".label", "meetup" # test for tag addition too, later
- end
-
test "should load iframe url in comments" do
comment = DrupalComment.new({
nid: node(:one).nid,
@@ -313,7 +273,7 @@ def setup
test "should redirect to questions show page after creating a new question" do
user = UserSession.create(rusers(:bob))
- title = "How to use a Spectrometer"
+ title = "How to use Spectrometer"
post :create,
title: title,
body: "Spectrometer question",
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 3113371372f..f7b90757ba1 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -80,13 +80,9 @@ def teardown
title: newtitle,
body: "Editing about Page"
+ wiki.reload
assert_redirected_to wiki.path
-
- get :show, id: wiki.slug
-
- assert_response :success
assert_equal flash[:notice], "Edits saved."
- assert_select "h1", newtitle # title should change but not URL
end
test "update root-path (/about) wiki" do
@@ -96,16 +92,12 @@ def teardown
post :update,
id: wiki.nid,
uid: rusers(:bob).id,
- title: "New Title",
+ title: newtitle,
body: "Editing about Page"
+ wiki.reload
assert_redirected_to wiki.path
-
- get :show, id: wiki.slug
-
- assert_response :success
assert_equal flash[:notice], "Edits saved."
- assert_select "h1", newtitle # title should change but not URL
end
test "update wiki uploading new image" do
@@ -121,6 +113,7 @@ def teardown
:photo => image
}
+ node.reload
assert_redirected_to node.path
assert_equal flash[:notice], "Edits saved."
end
@@ -136,6 +129,7 @@ def teardown
body: "Editing about Page",
image_revision: image.path(:default)
+ node.reload
assert_redirected_to node.path
assert_equal flash[:notice], "Edits saved."
end
diff --git a/test/integration/node_update_test.rb b/test/integration/node_update_test.rb
new file mode 100644
index 00000000000..24e1bf377b8
--- /dev/null
+++ b/test/integration/node_update_test.rb
@@ -0,0 +1,143 @@
+require 'test_helper'
+
+class NodeUpdateTest < ActionDispatch::IntegrationTest
+
+ test "edit note after creating a new note" do
+ post '/user_sessions', user_session: {
+ username: rusers(:bob).username,
+ password: 'secret'
+ }
+
+ title = "My second post about balloon mapping"
+
+ post '/notes/create',
+ title: title,
+ body: "This is a fascinating post about a balloon mapping event.",
+ tags: "balloon-mapping,event"
+
+ follow_redirect!
+ assert_equal "/notes/" + rusers(:bob).username + "/" +
+ Time.now.strftime("%m-%d-%Y") + "/" + title.parameterize, path
+
+ node = DrupalNode.where(title: title).first
+
+ # approve the first-timer's note:
+ node.publish
+
+ # add a tag, and change the title and body
+ newtitle = title + " which I amended"
+
+ post '/notes/update/' + node.id.to_s,
+ title: newtitle,
+ body: "This is a fascinating post about a balloon mapping event. added content",
+ tags: "balloon-mapping,event,meetup"
+ follow_redirect!
+ # path gets updated
+ assert_equal "/notes/" + rusers(:bob).username + "/" +
+ Time.now.strftime("%m-%d-%Y") + "/" + newtitle.parameterize, path
+
+ assert_equal flash[:notice], "Edits saved."
+
+ # visiting note with new path
+ get "/notes/" + rusers(:bob).username + "/" +
+ Time.now.strftime("%m-%d-%Y") + "/" + newtitle.parameterize
+ assert_response :success
+ assert_select "h1", newtitle
+ assert_select "span#teststring", "added content"
+ # assert_select ".label", "meetup" # test for tag addition too, later
+ end
+
+ test "should redirect to new note path when visiting with old url" do
+ post '/user_sessions', user_session: {
+ username: rusers(:jeff).username,
+ password: 'secret'
+ }
+
+ node = node(:one)
+ oldtitle = node.title
+ newtitle = oldtitle + " which I amended"
+
+ post '/notes/update/' + node.id.to_s,
+ title: newtitle,
+ body: "Some test string"
+
+ follow_redirect!
+ # path gets updated
+ assert_equal "/notes/" + rusers(:jeff).username + "/" +
+ node.created_at.strftime("%m-%d-%Y") + "/" + newtitle.parameterize, path
+
+ assert_equal flash[:notice], "Edits saved."
+
+ # visiting note with old path
+ get '/notes/' + rusers(:jeff).username + "/" +
+ node.created_at.strftime("%m-%d-%Y") + "/" + oldtitle.parameterize
+
+ follow_redirect!
+ assert_equal '/notes/' + rusers(:jeff).username + "/" +
+ node.created_at.strftime("%m-%d-%Y") + "/" +
+ newtitle.parameterize, path
+
+ end
+
+ test "should redirect to new path for question when visiting with old url" do
+ post '/user_sessions', user_session: {
+ username: rusers(:jeff).username,
+ password: 'secret'
+ }
+
+ node = node(:question)
+ oldtitle = node.title
+ newtitle = oldtitle + " which I amended"
+
+ post '/notes/update/' + node.id.to_s,
+ title: newtitle,
+ body: "Some test string",
+ redirect: "question"
+
+ follow_redirect!
+ # path gets updated
+ assert_equal "/questions/" + rusers(:jeff).username + "/" +
+ node.created_at.strftime("%m-%d-%Y") + "/" + newtitle.parameterize, path
+
+ assert_equal flash[:notice], "Edits saved."
+
+ # visiting note with old path
+ get '/questions/' + rusers(:jeff).username + "/" +
+ node.created_at.strftime("%m-%d-%Y") + "/" + oldtitle.parameterize
+
+ follow_redirect!
+ assert_equal '/questions/' + rusers(:jeff).username + "/" +
+ node.created_at.strftime("%m-%d-%Y") + "/" +
+ newtitle.parameterize, path
+
+ end
+
+ test "should redirect to new wiki path when visiting with old url" do
+ post '/user_sessions', user_session: {
+ username: rusers(:bob).username,
+ password: 'secret'
+ }
+
+ node = node(:about)
+ oldtitle = node.title
+ newtitle = oldtitle + " page amended"
+
+ post '/wiki/update/' + node.id.to_s,
+ title: newtitle,
+ body: "Some test string"
+
+ follow_redirect!
+ # path gets updated
+ assert_equal "/wiki/" + newtitle.parameterize, path
+
+ assert_equal flash[:notice], "Edits saved."
+
+ # visiting note with old path
+ get '/wiki/' + oldtitle.parameterize
+
+ follow_redirect!
+ assert_equal '/wiki/' + newtitle.parameterize, path
+
+ end
+
+end