X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c03649355a1a344dfb31b814699778ac26fd514d..e3c919275818d46a515c183cf373d7a53bc6942a:/test/controllers/diary_entries_controller_test.rb?ds=inline diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index f3ca40f41..d0453bf08 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -81,14 +81,6 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest { :path => "/user/username/diary/1/unhide", :method => :post }, { :controller => "diary_entries", :action => "unhide", :display_name => "username", :id => "1" } ) - assert_routing( - { :path => "/user/username/diary/1/hidecomment/2", :method => :post }, - { :controller => "diary_entries", :action => "hidecomment", :display_name => "username", :id => "1", :comment => "2" } - ) - assert_routing( - { :path => "/user/username/diary/1/unhidecomment/2", :method => :post }, - { :controller => "diary_entries", :action => "unhidecomment", :display_name => "username", :id => "1", :comment => "2" } - ) assert_routing( { :path => "/user/username/diary/1/subscribe", :method => :get }, { :controller => "diary_entries", :action => "subscribe", :display_name => "username", :id => "1" } @@ -744,6 +736,17 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest end end + def test_show_og_image_with_no_image + user = create(:user) + diary_entry = create(:diary_entry, :user => user, :body => "nothing") + + get diary_entry_path(user, diary_entry) + assert_response :success + assert_dom "head meta[property='og:image']" do + assert_dom "> @content", ActionController::Base.helpers.image_url("osm_logo_256.png", :host => root_url) + end + end + def test_show_og_image user = create(:user) diary_entry = create(:diary_entry, :user => user, :body => "![some picture](https://example.com/picture.jpg)") @@ -788,6 +791,17 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest end end + def test_show_og_image_with_invalid_uri + user = create(:user) + diary_entry = create(:diary_entry, :user => user, :body => "![](:)") + + get diary_entry_path(user, diary_entry) + assert_response :success + assert_dom "head meta[property='og:image']" do + assert_dom "> @content", ActionController::Base.helpers.image_url("osm_logo_256.png", :host => root_url) + end + end + def test_hide user = create(:user) diary_entry = create(:diary_entry, :user => user) @@ -850,70 +864,6 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert DiaryEntry.find(diary_entry.id).visible end - def test_hidecomment - user = create(:user) - diary_entry = create(:diary_entry, :user => user) - diary_comment = create(:diary_comment, :diary_entry => diary_entry) - - # Try without logging in - post hide_diary_comment_path(user, diary_entry, diary_comment) - assert_response :forbidden - assert DiaryComment.find(diary_comment.id).visible - - # Now try as a normal user - session_for(user) - post hide_diary_comment_path(user, diary_entry, diary_comment) - assert_redirected_to :controller => :errors, :action => :forbidden - assert DiaryComment.find(diary_comment.id).visible - - # Try as a moderator - session_for(create(:moderator_user)) - post hide_diary_comment_path(user, diary_entry, diary_comment) - assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id - assert_not DiaryComment.find(diary_comment.id).visible - - # Reset - diary_comment.reload.update(:visible => true) - - # Finally try as an administrator - session_for(create(:administrator_user)) - post hide_diary_comment_path(user, diary_entry, diary_comment) - assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id - assert_not DiaryComment.find(diary_comment.id).visible - end - - def test_unhidecomment - user = create(:user) - diary_entry = create(:diary_entry, :user => user) - diary_comment = create(:diary_comment, :diary_entry => diary_entry, :visible => false) - - # Try without logging in - post unhide_diary_comment_path(user, diary_entry, diary_comment) - assert_response :forbidden - assert_not DiaryComment.find(diary_comment.id).visible - - # Now try as a normal user - session_for(user) - post unhide_diary_comment_path(user, diary_entry, diary_comment) - assert_redirected_to :controller => :errors, :action => :forbidden - assert_not DiaryComment.find(diary_comment.id).visible - - # Now try as a moderator - session_for(create(:moderator_user)) - post unhide_diary_comment_path(user, diary_entry, diary_comment) - assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id - assert DiaryComment.find(diary_comment.id).visible - - # Reset - diary_comment.reload.update(:visible => true) - - # Finally try as an administrator - session_for(create(:administrator_user)) - post unhide_diary_comment_path(user, diary_entry, diary_comment) - assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id - assert DiaryComment.find(diary_comment.id).visible - end - def test_subscribe_page user = create(:user) other_user = create(:user)