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

Fix specs related to widget set factories #7594

Merged
merged 7 commits into from
Jan 25, 2021

Conversation

lpichler
Copy link
Contributor

@lpichler lpichler commented Jan 21, 2021

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

kbrock and others added 5 commits January 20, 2021 17:31
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
@lpichler
Copy link
Contributor Author

@miq-bot cross-repo-tests ManageIQ/manageiq#20972

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Jan 21, 2021
@lpichler lpichler force-pushed the fix_spec_for_widget_set branch from 33c1402 to c9db235 Compare January 21, 2021 12:29
miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Jan 21, 2021
@lpichler
Copy link
Contributor Author

@miq-bot cross_repo_tests #7594 including ManageIQ/manageiq#20972

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Jan 21, 2021
Copy link
Member

@kbrock kbrock left a 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,
Copy link
Member

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

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
Copy link
Member

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

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

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

@kbrock
Copy link
Member

kbrock commented Jan 21, 2021

This is part of the whole ManageIQ/manageiq#20890 chain

Copy link
Member

@kbrock kbrock left a 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 not owner_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?

@h-kataria
Copy link
Contributor

h-kataria commented Jan 22, 2021

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 not `owner_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 FactoryBot.create(:user_with_group) should take care of that

@miq-bot
Copy link
Member

miq-bot commented Jan 25, 2021

Checked commits lpichler/manageiq-ui-classic@135c397~...ec55b7a with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint
4 files checked, 4 offenses detected

spec/controllers/dashboard_controller_spec.rb

@h-kataria
Copy link
Contributor

@lpichler can you take a look at spec test failures, look related to me.

@lpichler lpichler closed this Jan 25, 2021
@lpichler lpichler reopened this Jan 25, 2021
Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Libor

@h-kataria h-kataria merged commit 37e9605 into ManageIQ:master Jan 25, 2021
@lpichler lpichler deleted the fix_spec_for_widget_set branch January 26, 2021 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants