X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/00c2589374f9b9ed93de707322dbefbd3cd6c634..224550518539523c04a9b676571a0d37be81ad14:/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..24475fc80 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -119,9 +119,9 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1 assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1 assert_select "input[name=commit][type=submit][value=Publish]", :count => 1 - assert_select "input[name=commit][type=submit][value=Edit]", :count => 1 - assert_select "input[name=commit][type=submit][value=Preview]", :count => 1 - assert_select "input", :count => 6 + assert_select "button[type=button]", :text => "Edit", :count => 1 + assert_select "button[type=button]", :text => "Preview", :count => 1 + assert_select "input", :count => 4 end end end @@ -272,9 +272,9 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1 assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1 assert_select "input[name=commit][type=submit][value=Update]", :count => 1 - assert_select "input[name=commit][type=submit][value=Edit]", :count => 1 - assert_select "input[name=commit][type=submit][value=Preview]", :count => 1 - assert_select "input", :count => 7 + assert_select "button[type=button]", :text => "Edit", :count => 1 + assert_select "button[type=button]", :text => "Preview", :count => 1 + assert_select "input", :count => 5 end end @@ -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)