From 55e3f90dd47bd96970cd0d9e55fb56e70dd8cc75 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 8 Jan 2025 11:27:54 +0000 Subject: [PATCH] Show diary entry after creation This allows users to review their post and use the social share buttons more easily. Refs #1391 --- app/controllers/diary_entries_controller.rb | 2 +- test/controllers/diary_entries_controller_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index 760c9a3012..27099cd9cf 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -123,7 +123,7 @@ def create # Subscribe user to diary comments @diary_entry.subscriptions.create(:user => current_user) - redirect_to :action => "index", :display_name => current_user.display_name + redirect_to diary_entry_path(@diary_entry.user, @diary_entry) else render :action => "new" end diff --git a/test/controllers/diary_entries_controller_test.rb b/test/controllers/diary_entries_controller_test.rb index 91e2a58d94..a1c22fff82 100644 --- a/test/controllers/diary_entries_controller_test.rb +++ b/test/controllers/diary_entries_controller_test.rb @@ -159,8 +159,8 @@ def test_create post diary_entries_path(:diary_entry => { :title => "New Title", :body => "This is a new body for the diary entry", :latitude => "1.1", :longitude => "2.2", :language_code => "en" }) end - assert_redirected_to :action => :index, :display_name => user.display_name entry = DiaryEntry.last + assert_redirected_to diary_entry_path(user, entry) assert_equal user.id, entry.user_id assert_equal "New Title", entry.title assert_equal "This is a new body for the diary entry", entry.body @@ -184,8 +184,8 @@ def test_create_german post diary_entries_path(:diary_entry => { :title => "New Title", :body => "This is a new body for the diary entry", :latitude => "1.1", :longitude => "2.2", :language_code => "de" }) end - assert_redirected_to :action => :index, :display_name => user.display_name entry = DiaryEntry.last + assert_redirected_to diary_entry_path(user, entry) assert_equal user.id, entry.user_id assert_equal "New Title", entry.title assert_equal "This is a new body for the diary entry", entry.body @@ -211,8 +211,8 @@ def test_new_spammy assert_difference "DiaryEntry.count", 1 do post diary_entries_path(:diary_entry => { :title => spammy_title, :body => spammy_body, :language_code => "en" }) end - assert_redirected_to :action => :index, :display_name => user.display_name entry = DiaryEntry.last + assert_redirected_to diary_entry_path(user, entry) assert_equal user.id, entry.user_id assert_equal spammy_title, entry.title assert_equal spammy_body, entry.body