-
Notifications
You must be signed in to change notification settings - Fork 898
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
test relationship.filtered #10314
test relationship.filtered #10314
Conversation
Checked commit kbrock@5284e9e with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 |
vms.map(&:save!) | ||
hosts.map(&:save!) | ||
storages.map(&:save!) | ||
filtered_results = Relationship.filtered(%w(Host VmOrTemplate), %w(Storage)) |
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.
why not...
let!(:storages) { FactoryGirl.create_list(:relationship_storage_vmware, 1) }
let!(:vms) { FactoryGirl.create_list(:relationship_vm_vmware, 1) }
let!(:hosts) { FactoryGirl.create_list(:relationship_host_vmware, 1) }
let(:filtered_results) { described_class.filtered(%w(Host VmOrTemplate), %w(Storage))
it "scopes" do
expect(filtered_results).to match_array(vms + hosts)
end
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've been avoiding let!
- want to be obvious in the test what data exists.
the !
is so subtle and makes this hidden. It also creates objects and people refactoring don't know if it is necessary or if someone was just paying attention when adding a test.
Removing the let!(:storage) would still pass the tests, but it would not be testing that storages
are not being brought back. So the test would become useless.
Marked darga/yes because the previous PR #10288 is marked yes |
test relationship.filtered (cherry picked from commit 4c76438)
Darga backport details:
|
added tests for relationship#filtered
per #10288 (comment)