Commit 08f5a54342b3633f1addc23fd91f1f8c3e530e34
Committed by
Antonio Terceiro
1 parent
b924e05f
Exists in
master
and in
29 other branches
ActionItem929: fixed image editing back_url
Showing
2 changed files
with
33 additions
and
2 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -204,7 +204,7 @@ class CmsController < MyProfileController | @@ -204,7 +204,7 @@ class CmsController < MyProfileController | ||
204 | if params[:back_to] == 'control_panel' | 204 | if params[:back_to] == 'control_panel' |
205 | redirect_to :controller => 'profile_editor', :profile => @profile.identifier | 205 | redirect_to :controller => 'profile_editor', :profile => @profile.identifier |
206 | elsif params[:back_to] == 'public_view' | 206 | elsif params[:back_to] == 'public_view' |
207 | - redirect_to @article.url | 207 | + redirect_to @article.url.merge(:view => @article.image?) |
208 | elsif @article.parent | 208 | elsif @article.parent |
209 | redirect_to :action => 'view', :id => @article.parent | 209 | redirect_to :action => 'view', :id => @article.parent |
210 | else | 210 | else |
@@ -214,9 +214,10 @@ class CmsController < MyProfileController | @@ -214,9 +214,10 @@ class CmsController < MyProfileController | ||
214 | 214 | ||
215 | def record_coming_from_public_view | 215 | def record_coming_from_public_view |
216 | referer = request.referer | 216 | referer = request.referer |
217 | + referer.gsub!(/\?.*/, '') unless referer.nil? | ||
217 | if (maybe_ssl(url_for(@article.url)).include?(referer)) || (@article == profile.home_page && maybe_ssl(url_for(profile.url)).include?(referer)) | 218 | if (maybe_ssl(url_for(@article.url)).include?(referer)) || (@article == profile.home_page && maybe_ssl(url_for(profile.url)).include?(referer)) |
218 | @back_to = 'public_view' | 219 | @back_to = 'public_view' |
219 | - @back_url = @article.url | 220 | + @back_url = @article.url.merge(:view => @article.image?) |
220 | end | 221 | end |
221 | end | 222 | end |
222 | 223 |
test/functional/cms_controller_test.rb
@@ -866,4 +866,34 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -866,4 +866,34 @@ class CmsControllerTest < Test::Unit::TestCase | ||
866 | assert_template nil | 866 | assert_template nil |
867 | assert_redirected_to folder.url | 867 | assert_redirected_to folder.url |
868 | end | 868 | end |
869 | + | ||
870 | + should 'record when coming from public view on edit files with view true' do | ||
871 | + file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
872 | + | ||
873 | + @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}/#{file.slug}?view=true").at_least_once | ||
874 | + | ||
875 | + get :edit, :profile => profile.identifier, :id => file.id | ||
876 | + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } | ||
877 | + assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/#{profile.identifier}\/#{file.slug}?.*view=true/ } | ||
878 | + end | ||
879 | + | ||
880 | + should 'detect when comming from home page to edit files with view true' do | ||
881 | + file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
882 | + profile.expects(:home_page).returns(file).at_least_once | ||
883 | + | ||
884 | + @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}?view=true").at_least_once | ||
885 | + @controller.stubs(:profile).returns(profile) | ||
886 | + get :edit, :profile => profile.identifier, :id => file.id | ||
887 | + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } | ||
888 | + assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => /^https?:\/\/colivre.net\/#{profile.identifier}\/#{profile.home_page.slug}?.*view=true$/ } | ||
889 | + end | ||
890 | + | ||
891 | + should 'go back to public view when edit files coming from there with view true' do | ||
892 | + file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | ||
893 | + @request.expects(:referer).returns("http://colivre.net/#{profile.identifier}/#{file.slug}?view=true").at_least_once | ||
894 | + | ||
895 | + post :edit, :profile => profile.identifier, :id => file.id, :back_to => 'public_view', :article => {:abstract => 'some description'} | ||
896 | + assert_template nil | ||
897 | + assert_redirected_to file.url.merge(:view => true) | ||
898 | + end | ||
869 | end | 899 | end |