From e9a5925ab96e4bfbe43d059c279e05943a563955 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Tue, 18 Oct 2016 14:01:02 -0400 Subject: [PATCH] fixed and test for node images (#905) --- app/controllers/notes_controller.rb | 4 ++-- test/functional/notes_controller_test.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index bf8f136a34..d8a23916e0 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -122,9 +122,9 @@ def image params[:size] = params[:size] || :large node = DrupalNode.find(params[:id]) if node.main_image - redirect_to image.path(params[:size]) + redirect_to node.main_image.path(params[:size]) else - return "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" + redirect_to "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" end end diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index d53c925bba..6eb5d0ffae 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -83,6 +83,15 @@ def teardown assert_response :success end + test "should show main image for node, returning blank image if it has none" do + node = node(:one) + + get :image, id: node.id + + assert_response :redirect + assert_redirected_to "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" + end + test "should get tools" do get :tools @@ -398,4 +407,5 @@ def teardown assert_equal I18n.t('notes_controller.research_note_published'), flash[:notice] end end + end