diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index fa206bf..13e8afa 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -53,6 +53,7 @@ def new
end
def edit
+ @show_date = true
@settings = SettingsController.get_setting
@post = Post.find(params[:id])
verify_can_modify_post(@post)
diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb
index 7957a6b..68a461a 100644
--- a/app/views/posts/_form.html.erb
+++ b/app/views/posts/_form.html.erb
@@ -1,7 +1,7 @@
<%= form_with model: @post, local: true do |form| %>
- <%= form.date_field :date, :style => 'display:inline;', :value => @post.datetime.strftime("%Y-%m-%d"), type: (@settings.show_post_date ? :date : :hidden) %>
- <%= form.time_field :time, :style => 'display:inline;', :value => @post.datetime.strftime("%H:%M"), type: (@settings.show_post_date ? :time : :hidden) %>
+ <%= form.date_field :date, :style => 'display:inline;', :value => @post.datetime.strftime("%Y-%m-%d"), type: (@show_date ? :date : :hidden) %>
+ <%= form.time_field :time, :style => 'display:inline;', :value => @post.datetime.strftime("%H:%M"), type: (@show_date ? :time : :hidden) %>
<%= form.text_area :content, :rows => 10, :dir => "auto", :style => 'display:block;width:100%;', :oninput => "doRender();", :value => @post.content %>
<%= form.file_field :pic, :accept => "image/*,.mp4,.mp3", :style => "display:inline;" %>
<%= form.submit :value => "Upload Selected Image", data: {disable_with: "Upload Selected Image"}, :style => "display:inline;" %>
diff --git a/test/system/editing_posts_test.rb b/test/system/editing_posts_test.rb
index aa4e9de..dee8c87 100644
--- a/test/system/editing_posts_test.rb
+++ b/test/system/editing_posts_test.rb
@@ -53,6 +53,35 @@ class EditingPostsTest < ApplicationSystemTestCase
click_on "Save Post"
assert_text m3
click_on "Logout"
+ end
+
+ test "can_edit_post_date_but_not_visible_on_post_creation" do
+ log_in_with test_users[:jackson] #publisher
+ click_on "New Post Button"
+ ## ensure we cannot edit the date and time of the post
+ assert_no_selector 'input[id="post_date"][type="date"]'
+ assert_no_selector 'input[id="post_time"][type="time"]'
+
+ m = "#{rand} I cannot tell a lie"
+ fill_in "post_content", with: m
+ click_on "Save Post"
+ assert_text m # page previw shows post content
+
+ click_on "Edit"
+ ## ensure we can edit the date and time of the post
+ assert_selector 'input[id="post_date"][type="date"]'
+ assert_selector 'input[id="post_time"][type="time"]'
+
+ ## edit the date/time and see it persist
+ fill_in "post_date", with: "01022023"
+ fill_in "post_time", with: "0123p"
+ click_on "Save Post"
+ assert_text "January 02, 2023"
+ click_on "Edit"
+ assert_selector 'input[id="post_date"][type="date"][value="2023-01-02"]'
+ assert_selector 'input[id="post_time"][type="time"][value="13:23"]'
+
+ click_on "Logout"
end
end