-
Notifications
You must be signed in to change notification settings - Fork 983
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
fixes #5235: it's impossible to create filters with invaid searches #1552
Conversation
@@ -1,6 +1,10 @@ | |||
require 'test_helper' | |||
|
|||
class FilterTest < ActiveSupport::TestCase | |||
before do | |||
User.current = users :admin |
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.
There's an as_admin helper which is preferable if you need it
@domcleal: ping? |
assert_not_include f.taxonomy_search, ' or ' | ||
as_admin do | ||
o = Factory.create :organization | ||
f = Factory.build(:filter, :search => '', :unlimited => '1', :organization_ids => [o.id]) |
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.
Asserts need not to be in the as_admin block, also 1-character variables could be changed to organization/filter. 😄
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.
Same for the rest of the tests, I'd say include them in a context and refactor the common parts, like some assertions, some objects created.
@elobato: ping |
f.reload | ||
assert f.valid? | ||
assert f.unlimited? | ||
assert_nil f.taxonomy_search |
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.
It'd be good to include a
teardown do
assert f.valid?
end
since that assertion is done everywhere within this context, and is not specific to each test.
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 that'd reduce test readability -- I'd rather not do that.
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.
Fair enough, maybe after
would be more readable. Anyway this is up to discussion, I'll merge this for the moment and search for a way to discuss test standards 👍
Merged as 0545fd1, thanks @witlessbird ! |
No description provided.