-
Notifications
You must be signed in to change notification settings - Fork 29
refactor: Files feedback_message without NULL state #3046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -3,15 +3,21 @@ | |||
require 'rails_helper' | |||
|
|||
RSpec.describe CodeOcean::File do | |||
let(:file) { described_class.create.tap {|file| file.update(content: nil, hidden: nil, read_only: nil) } } | |||
let(:file) do | |||
described_class.new.tap do |file| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to make clear that the create
does not create a record here. Therefore, I use assignment and call validate.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3046 +/- ##
=======================================
Coverage 70.08% 70.09%
=======================================
Files 215 215
Lines 6850 6851 +1
=======================================
+ Hits 4801 4802 +1
Misses 2049 2049 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b9620fe
to
67b20ec
Compare
Column type string should not have a null state to avoid logical distinction between NULL and '' case. User defined tests are created without feedback_message. Removing the NULL case allows the new record to render the empty feedback_message. An edge case is resolved when a test for assessment with a feedback_message is transformed to a user defined test. The feedback_message is overwritten, and no validation error for invisible fields is displayed. Resolves #3014
67b20ec
to
456128c
Compare
would adding a spec to test for the bug in #3014 be an option? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not happy to set a blank string as a solution here. This adds further custom code (like a custom validation rather than using a built-in validation), makes analysis of the code files more difficult, and potentially increases data storage requirements.
Which other solutions to the problem did you consider? Why did you decide that way?
If a column can be Thoughtbot includes this in their excellent developing guides. There is also a very famous blog post on the NULL state that explains the ideas on a higher level. These blog posts on the matter are also superb: A good Rails application as an example of this implementation is Mastodon. While this is not a standard that is adopted by everyone I am a big fan. This data normalization avoids conditional logic and makes the code more readable. |
Column type string should not have a null state to avoid logical
distinction between
NULL
and''
case.User defined tests are created without feedback_message. Removing
the NULL case allows the new record to render the empty feedback_message.
An edge case is resolved when a test for assessment with a feedback_message
is transformed to a user defined test. The feedback_message is
overwritten, and no validation error for invisible fields is displayed.
Resolves #3014