Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

dmitri-d
Copy link
Member

@dmitri-d dmitri-d commented Jul 1, 2014

No description provided.

@@ -1,6 +1,10 @@
require 'test_helper'

class FilterTest < ActiveSupport::TestCase
before do
User.current = users :admin
Copy link
Contributor

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

@dmitri-d
Copy link
Member Author

dmitri-d commented Jul 3, 2014

@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])
Copy link
Member

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. 😄

Copy link
Member

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.

@dmitri-d
Copy link
Member Author

dmitri-d commented Jul 7, 2014

@elobato: ping

f.reload
assert f.valid?
assert f.unlimited?
assert_nil f.taxonomy_search
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 👍

@dLobatog
Copy link
Member

dLobatog commented Jul 7, 2014

Merged as 0545fd1, thanks @witlessbird !

@dLobatog dLobatog closed this Jul 7, 2014
@dmitri-d dmitri-d deleted the 5235 branch December 13, 2017 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants