Don't nil publication info if article is already published - #5448
Merged
just1602 merged 1 commit intoJul 1, 2026
Merged
Conversation
Bargraph6
requested review from
astronaut-wannabe,
bookis,
eliduke,
evanphx,
guitsaru,
just1602 and
veganstraightedge
as code owners
June 29, 2026 09:38
4 tasks
* app/controllers/admin/articles_controller.rb (Admin::ArticlesController): updated the permitted_params logic for articles to delete nil publication date info if the article is already published.
* spec/requests/article_datetime_settings_spec.rb: Updated spec to allow for separate expected values for the update and create controller actions.
I don't think this is a situation that ever really happens in
practice, however while updating the `article_datetime_settings_spec`,
it was discovered that it was technically possible to pass `nil` to
the update action of the articles controller.
This would result in an error further down the line as `Article#path`
would try to `strftime` the `nil`:
```sh
NoMethodError:
undefined method 'strftime' for nil
Shared Example Group: "handles the publication date" called from ./spec/requests/article_datetime_settings_spec.rb:61
# ./app/models/article.rb:56:in '
# ./app/models/article.rb:150:in 'Article#update_or_create_redirect'
# ./app/controllers/admin/articles_controller.rb:56:in 'Admin::ArticlesController#update'
# ...
```
This change just updates the `article_params` method to remove the
`published_at` and `published_at_tz` params from the permitted params
if the article is already published and the params are `nil`.
Bargraph6
force-pushed
the
push_kptxxmkxmqrl
branch
from
June 29, 2026 09:48
b0d023f to
ac93659
Compare
just1602
approved these changes
Jul 1, 2026
just1602
pushed a commit
that referenced
this pull request
Jul 23, 2026
just1602
pushed a commit
that referenced
this pull request
Jul 27, 2026
just1602
pushed a commit
that referenced
this pull request
Jul 28, 2026
just1602
pushed a commit
that referenced
this pull request
Aug 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this pull request do?
Is there any background context you want to provide for reviewers?
I don't think this is a situation that ever really happens in practice, however while updating the
article_datetime_settings_spec, it was discovered that it was technically possible to passnilto the update action of the articles controller.This would result in an error further down the line as
Article#pathwould try tostrftimethenil:NoMethodError: undefined method 'strftime' for nil Shared Example Group: "handles the publication date" called from ./spec/requests/article_datetime_settings_spec.rb:61 # ./app/models/article.rb:56:in ' # ./app/models/article.rb:150:in 'Article#update_or_create_redirect' # ./app/controllers/admin/articles_controller.rb:56:in 'Admin::ArticlesController#update' # ...This change just updates the
article_paramsmethod to remove thepublished_atandpublished_at_tzparams from the permitted params if the article is already published and the params arenil.related_to: #5391