Skip to content
Browse files

Merge pull request #3182 from refinery/bugfix/encoded-admin-urls-3179

Use admin_update_page_path to avoid encoded URLs
  • Loading branch information...
2 parents 40e8ff3 + 8628685 commit 394122192d0975b705422662c8529c1b4d24ced8 @bricesanchez bricesanchez committed May 24, 2016
View
2 pages/app/controllers/refinery/admin/pages_controller.rb
@@ -108,7 +108,7 @@ def save_and_continue_locals(page)
nested_url = page.nested_url
{
new_refinery_edit_page_path: refinery.admin_edit_page_path(nested_url),
- new_refinery_page_path: refinery.admin_page_path(nested_url),
+ new_refinery_page_path: refinery.admin_update_page_path(nested_url),
new_page_path: refinery.pages_admin_preview_page_path(nested_url)
}
end
View
35 pages/spec/features/refinery/admin/pages_spec.rb
@@ -193,16 +193,19 @@ module Admin
end
describe "edit/update" do
- before do
- Page.create :title => "Update me"
+ let(:updateable_page_parent) { Page.create title: "Parent page" }
+ let!(:updateable_page) {
+ updateable_page_parent.children.create title: "Update me"
+ }
+ before do
visit refinery.admin_pages_path
expect(page).to have_content("Update me")
end
context 'when saving and returning to index' do
- it "updates page", js:true do
- find('a[tooltip="Edit this page"]').trigger(:click)
+ it "updates page", js: true do
+ find("a[href$='#{updateable_page.slug}/edit']").trigger(:click)
fill_in "Title", :with => "Updated"
find("#submit_button").click
@@ -211,25 +214,33 @@ module Admin
end
end
- context 'when saving and continuing to edit' do
+ context 'when saving and continuing to edit', js: true do
before :each do
- expect(page).to have_selector('a[tooltip^=Edit]', visible: true)
- find('a[tooltip^=Edit]').click
+ expect(page).to have_selector("a[href$='#{updateable_page.slug}/edit']", visible: true)
+ find("a[href$='#{updateable_page.slug}/edit']").click
- fill_in "Title", :with => "Updated"
+ fill_in "Title", :with => "Updated you"
find("#submit_continue_button").click
find('#flash').visible?
end
- it "updates page", js: true do
- expect(page).to have_content("'Updated' was successfully updated.")
+ it "updates page" do
+ expect(page).to have_content("'Updated you' was successfully updated.")
+ end
+
+ # Regression test for https://github.com/refinery/refinerycms/issues/3179
+ # We expect this to end with /updated-you rather than /updated%2Fyou
+ it "doesn't have an encoded URL" do
+ updateable_page.reload # the slug will be different now
+ expect(page).not_to have_selector("form[action$='%2F#{updateable_page.slug}']")
+ expect(page).to have_selector("form[action$='/#{updateable_page.slug}']")
end
# Regression test for https://github.com/refinery/refinerycms/issues/1892
context 'when saving to exit (a second time)' do
- it 'updates page', js: true do
+ it 'updates page' do
find("#submit_button").click
- expect(page).to have_content("'Updated' was successfully updated.")
+ expect(page).to have_content("'Updated you' was successfully updated.")
end
end
end

0 comments on commit 3941221

Please sign in to comment.
Something went wrong with that request. Please try again.