-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Prevent user seeing field length SQL error when creating a search track #2859
Conversation
@@ -70,6 +70,13 @@ | |||
track_thing = TrackThing.create_track_for_search_query('fancy dog', 'bodies') | |||
expect(track_thing.track_query).to match(/variety:authority/) | |||
end | |||
|
|||
it "will check that the query isn't too long to store" do | |||
long_query = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis blandit consequat enim, sit amet facilisis lorem bibendum in. Pellentesque cursus pretium tristique. Mauris nec venenatis justo. Nam facilisis, lectus et blandit eleifend, felis arcu massa nunc. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis blandit consequat enim, sit amet facilisis lorem bibendum in. Pellentesque cursus pretium tristique. Mauris nec venenatis justo. Nam facilisis, lectus et blandit eleifend, felis arcu massa nunc." |
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.
Maybe just "Lorem " * 100
?
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.
oh yes, that's much less horrible - thanks!
let(:ir) { FactoryGirl.create(:info_request, | ||
:title => 'My request', | ||
:url_title => 'myrequest') } | ||
let(:track_thing) { FactoryGirl.create(:request_update_track, |
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.
Avoid using {...}
for multi-line blocks.
e0c6805
to
83ed3c0
Compare
end | ||
|
||
describe TrackController, "when making a search track" do | ||
let(:track_thing) { FactoryGirl.create(:search_track, |
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.
Avoid using {...}
for multi-line blocks.
Nice work on cleaning up the specs. Now that the validation error is displayed in the UI, I can see that there are two things still to fix up here - -flash[:error] = @track_thing.errors.full_messages.join(", ")
+flash[:error] = @track_thing.errors.map{ |attr,message| message }.join(", ") It's always worth checking the results of a PR in a browser before submitting it for review. |
bah, I was hoping (from a too-quick read of the docs) to get a |
2dbaa1f
to
4584689
Compare
it "should send localised alerts" do | ||
# set the time the comment event happened at to within the last week | ||
ire = info_request_events(:silly_comment_event) | ||
ire.created_at = Time.now - 3.days |
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.
Do not use Time.now
without zone. Use one of Time.zone.now
, Time.now.current
, Time.now.in_time_zone
, Time.now.utc
, Time.now.getlocal
, Time.now.iso8601
, Time.now.jisx0301
, Time.now.rfc3339
, Time.now.to_i
, Time.now.to_f
instead.
response.headers['Expires'].should == '0' | ||
end | ||
describe "when making a search track" do | ||
let(:track_thing) { FactoryGirl.create(:search_track, |
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.
Avoid using {...}
for multi-line blocks.
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 think there's an exemption for this rubocop/rubocop#376
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 don't disagree with the rule as it happens – you can still do:
let(:blah) do
# ...
end
If you rebase on develop you should get the updated config that disables hound checks by default, other than the ones we've explicitly enabled though :)
it "should send localised alerts" do | ||
# set the time the comment event happened at to within the last week | ||
ire = info_request_events(:silly_comment_event) | ||
ire.created_at = Time.now - 3.days |
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.
Do not use Time.now
without zone. Use one of Time.zone.now
, Time.now.current
, Time.now.in_time_zone
, Time.now.utc
, Time.now.getlocal
, Time.now.iso8601
, Time.now.jisx0301
, Time.now.rfc3339
, Time.now.to_i
, Time.now.to_f
instead.
610bb1e
to
e26a9f8
Compare
Looks good to me other than the minor comment (#2859 (comment)) – 🚢 |
df63f8d
to
c5be6ad
Compare
c5be6ad
to
928b7ed
Compare
Could also do with a changelog entry btw! :) |
New migration to extend the length of the
track_things.track_query
field from 255 chars to 500Validates that the query fits within the 500 char limit to avoid the user seeing a database error if they exceed the field length
Fixes #937