Skip to content

Commit

Permalink
Show diary entry after creation
Browse files Browse the repository at this point in the history
This allows users to review their post and use the social share
buttons more easily.

Refs #1391
  • Loading branch information
gravitystorm committed Jan 8, 2025
1 parent c20160d commit 5abd806
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/diary_entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/controllers/diary_entries_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ 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
assert_redirected_to diary_entry_path(user, user.diary_entries.last)
entry = DiaryEntry.last
assert_equal user.id, entry.user_id
assert_equal "New Title", entry.title
Expand All @@ -184,7 +184,7 @@ 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
assert_redirected_to diary_entry_path(user, user.diary_entries.last)
entry = DiaryEntry.last
assert_equal user.id, entry.user_id
assert_equal "New Title", entry.title
Expand All @@ -211,7 +211,7 @@ 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
assert_redirected_to diary_entry_path(user, user.diary_entries.last)
entry = DiaryEntry.last
assert_equal user.id, entry.user_id
assert_equal spammy_title, entry.title
Expand Down

0 comments on commit 5abd806

Please sign in to comment.