-
Notifications
You must be signed in to change notification settings - Fork 356
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
Fix specs related to widget set factories #7594
Conversation
After changes, we want to ensure all records have an owner and the proper set_data There is a new requirement that a widget set contains at least one widget and that there is a group assigned to all widget sets
widget sets need widgets and those need reports Also, to have proper date time, a server needs to be present
@miq-bot cross-repo-tests ManageIQ/manageiq#20972 |
From Pull Request: ManageIQ/manageiq-ui-classic#7594
33c1402
to
c9db235
Compare
From Pull Request: ManageIQ/manageiq-ui-classic#7594
@miq-bot cross_repo_tests #7594 including ManageIQ/manageiq#20972 |
From Pull Request: ManageIQ/manageiq-ui-classic#7594
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.
Thanks @lpichler
:set_data => {:last_group_db_updated => Time.now.utc, :col1 => [1], :col2 => [], :col3 => []}) | ||
:name => @user.userid.to_s, | ||
:owner => @user, | ||
:group_id => @user.current_group_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.
Does this mean we should fix the before validation in the model to work with users?
Thinking having a user_with_group
may be what we want
let(:ws1) do | ||
FactoryBot.create(:miq_widget_set, | ||
:name => 'A', | ||
:owner_id => group.id, | ||
:set_data => {:col1 => [], :col2 => [], :col3 => []}) | ||
:set_data => {:col1 => [widget.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.
I noticed that a lot of these sets were incomplete which made me uncomfortable. That is where the smarter factory with encapsulation came into play. An alternative would be to put the setter into the actual model and treat these like fields (which is probably the correct schema/interface)
@@ -88,6 +88,8 @@ | |||
end | |||
|
|||
it 'renders list of Dashboards in Dashboards tree' do |
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.
Not thrilled about these but had trouble seeding a widget set without valid data. I guess manually creating the default would have worked as well
it 'renders show of Dashboards in Dashboards tree' do | ||
ApplicationController.handle_exceptions = true | ||
|
||
MiqWidgetSet.seed | ||
widget_set = FactoryBot.create(:miq_widget_set, :group_id => user.current_group.id) | ||
widget_set = FactoryBot.create(:miq_widget_set, :set_data => {:col1 => [miq_widget.id]}, :owner_id => user.current_group.id, :group_id => user.current_group.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.
there are a bunch of places where the owner_type
is not set - for this reason the group was passed in. if you pass owner (or owner_id and owner_type) then group will get set correctly
controller.instance_variable_set(:@edit, :new => new_hash, :db_id => miq_widget_set.id, :current => current) | ||
new_widget = FactoryBot.create(:miq_widget) | ||
new_hash = {:name => "New Name", :description => "New Description", :col1 => [new_widget.id], :col2 => [], :col3 => []} | ||
controller.instance_variable_set(:@edit, :new => new_hash, :db_id => miq_widget_set.id, :current => miq_widget_set.set_data) |
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.
wasn't sure if this needed a deep clone. One thing is for certain, setting this to an invalid hash (with no widgets at all) was not productive
This is part of the whole ManageIQ/manageiq#20890 chain |
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.
While I'm not thrilled with the whole set_data
stuff, we can save that for another PR
my main 2 sticking points:
- passing
owner_id
and notowner_type
. - passing
owner => user
and having to manually set the group.
on that second one in particular, I thought the purpose of these PRs were to auto set the group.
In the controllers, do we work the same way?
creating a user with |
Checked commits lpichler/manageiq-ui-classic@135c397~...ec55b7a with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint spec/controllers/dashboard_controller_spec.rb
|
@lpichler can you take a look at spec test failures, look related to me. |
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.
thanks Libor
Continuation of #7593,
where all changes from #7593 were added and
in addition other fixes added to fix specs.
cc @kbrock
Needs core PR: ManageIQ/manageiq#20972
Links