Skip to content

Commit

Permalink
fixed and test for node images (publiclab#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren authored Oct 18, 2016
1 parent a058b6c commit e9a5925
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions test/functional/notes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -398,4 +407,5 @@ def teardown
assert_equal I18n.t('notes_controller.research_note_published'), flash[:notice]
end
end

end

0 comments on commit e9a5925

Please sign in to comment.