diff --git a/app/controllers/file_controller.rb b/app/controllers/file_controller.rb index 203fd2d3..aa0dc9aa 100644 --- a/app/controllers/file_controller.rb +++ b/app/controllers/file_controller.rb @@ -18,7 +18,7 @@ class FileController < ApplicationController new_file = @web.wiki_files.create(params['file']) if new_file.valid? flash[:info] = "File '#{@file_name}' successfully uploaded" - redirect_to_page(@page_name) + redirect_to(params['referring_page']) else # pass the file with errors back into the form @file = new_file diff --git a/app/views/file/file.rhtml b/app/views/file/file.rhtml index 3cb0cfcc..f4ab96ec 100644 --- a/app/views/file/file.rhtml +++ b/app/views/file/file.rhtml @@ -1,6 +1,7 @@ <%- @title = "Upload #{h @file_name}" @hide_navigation = false + @referring_page ||= request.env["HTTP_REFERER"] -%> <%= error_messages_for 'file' %> @@ -8,6 +9,7 @@ <% form_tag({ :controller => 'file', :web => @web_name, :action => 'file' }, { 'multipart' => true , 'accept-charset' => 'utf-8' }) do %>
+ <%= hidden_field 'file', 'file_name' %>
@@ -15,7 +17,7 @@
Please note that the file you are uploading will be named <%= h @file_name %> on the wiki - regardless of how it is named on your computer. To change the wiki name of the file, please go - <%= link_to :back %> and edit the wiki page that refers to the file. + <%= link_to("back", @referring_page) %> and edit the wiki page that refers to the file.
diff --git a/public/favicon.ico b/public/favicon.ico index 041f7a0f..35c8dd1f 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/test/functional/file_controller_test.rb b/test/functional/file_controller_test.rb index 2abc1edd..dbc82f9c 100755 --- a/test/functional/file_controller_test.rb +++ b/test/functional/file_controller_test.rb @@ -89,10 +89,10 @@ class FileControllerTest < ActionController::TestCase end def test_pic_upload_end_to_end - # edit and re-render home page so that it has an "unknown file" link to 'rails-e2e.gif' + # edit and re-render a page so that it has an "unknown file" link to 'rails-e2e.gif' PageRenderer.setup_url_generator(StubUrlGenerator.new) renderer = PageRenderer.new - @wiki.revise_page('wiki1', 'HomePage', '[[rails-e2e.gif:pic]]', + @wiki.revise_page('wiki1', 'Oak', '[[rails-e2e.gif:pic]]', Time.now, 'AnonymousBrave', renderer) assert_equal "

rails-e2e.gif" + "?

", @@ -112,14 +112,15 @@ class FileControllerTest < ActionController::TestCase # updated from post to get - post fails the spam protection (no javascript) # Moron! If substituting GET for POST actually works, you # have much, much bigger problems. - r = get :file, :web => 'wiki1', + r = get :file, :web => 'wiki1', :referring_page => '/wiki1/show/Oak', :file => {:file_name => 'rails-e2e.gif', :content => StringIO.new(picture), :description => 'Rails, end-to-end'} + assert_redirected_to '/wiki1/show/Oak' assert @web.has_file?('rails-e2e.gif') assert_equal(picture, WikiFile.find_by_file_name('rails-e2e.gif').content) PageRenderer.setup_url_generator(StubUrlGenerator.new) - @wiki.revise_page('wiki1', 'HomePage', 'Try [[rails-e2e.gif:pic]] again.', + @wiki.revise_page('wiki1', 'Oak', 'Try [[rails-e2e.gif:pic]] again.', Time.now, 'AnonymousBrave', renderer) assert_equal "

Try Rails, end-to-end again.

", renderer.display_content diff --git a/vendor/rails/actionpack/lib/action_controller/response.rb b/vendor/rails/actionpack/lib/action_controller/response.rb index 27860a62..5138717b 100644 --- a/vendor/rails/actionpack/lib/action_controller/response.rb +++ b/vendor/rails/actionpack/lib/action_controller/response.rb @@ -144,7 +144,6 @@ module ActionController # :nodoc: set_content_length! convert_content_type! convert_language! - convert_expires! convert_cookies! end @@ -244,10 +243,6 @@ module ActionController # :nodoc: headers["Content-Language"] = headers.delete("language") if headers["language"] end - def convert_expires! - headers["Expires"] = headers.delete("") if headers["expires"] - end - def convert_cookies! headers['Set-Cookie'] = Array(headers['Set-Cookie']).compact end