X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/392d3d12264c83d7ab03d34471792476fac31cf6..5b118c68289ed4b6474975c602f13f6dc45da0d9:/test/controllers/diary_entries_controller_test.rb diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index 9acd72c67..bb6c25781 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -336,6 +336,29 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_select "span[class=translation_missing]", false, "Missing translation in edit diary entry" end + def test_update + user = create(:user) + other_user = create(:user) + diary_entry = create(:diary_entry, :language_code => "en", :user => user, :title => "Original Title") + + put diary_entry_path(user, diary_entry, :diary_entry => { :title => "Updated Title" }) + assert_response :forbidden + diary_entry.reload + assert_equal "Original Title", diary_entry.title + + session_for(other_user) + put diary_entry_path(user, diary_entry, :diary_entry => { :title => "Updated Title" }) + assert_redirected_to diary_entry_path(user, diary_entry) + diary_entry.reload + assert_equal "Original Title", diary_entry.title + + session_for(user) + put diary_entry_path(user, diary_entry, :diary_entry => { :title => "Updated Title" }) + assert_redirected_to diary_entry_path(user, diary_entry) + diary_entry.reload + assert_equal "Updated Title", diary_entry.title + end + def test_index_all diary_entry = create(:diary_entry) geo_entry = create(:diary_entry, :latitude => 51.50763, :longitude => -0.10781)