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

Add control that id is not nil otherwise set it to new #811

Merged
merged 3 commits into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/presenters/tree_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ def add_root_node(nodes)
end
end

def group_id
(@group.present? && @group.id.present?) ? @group.id : 'new'
end

def set_locals_for_render
{
:tree_id => "#{@name}box",
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_belongs_to_hac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def tree_init_options(_tree_name)

def set_locals_for_render
locals = super
locals.merge!(:check_url => "/ops/rbac_group_field_changed/#{@group.present? ? @group.id : "new"}___",
locals.merge!(:check_url => "/ops/rbac_group_field_changed/#{group_id}___",
:oncheck => @edit ? "miqOnCheckUserFilters" : nil,
:checkboxes => true,
:highlight_changes => true,
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def selected_entry_value(category, entry)

def set_locals_for_render
locals = super
locals.merge!(:check_url => "/ops/rbac_group_field_changed/#{@group.present? ? @group.id : "new"}___",
locals.merge!(:check_url => "/ops/rbac_group_field_changed/#{group_id}___",
:oncheck => @edit.nil? ? nil : "miqOnCheckUserFilters",
:checkboxes => true,
:highlight_changes => true,
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/tree_builder_belongs_to_hac_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
true,
:edit => edit,
:filters => {},
:group => group,
:group => nil,
:selected => {})
end

Expand All @@ -80,7 +80,7 @@
expect(subject.send(:set_locals_for_render)).to include(:onclick => false,
:tree_state => true,
:checkboxes => true,
:check_url => "/ops/rbac_group_field_changed/#{group.id || "new"}___",
:check_url => "/ops/rbac_group_field_changed/new___",
:oncheck => nil,
:highlight_changes => true)
end
Expand Down
12 changes: 10 additions & 2 deletions spec/presenters/tree_builder_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
it 'set locals for render correctly' do
locals = @tags_tree.send(:set_locals_for_render)
expect(locals[:checkboxes]).to eq(true)
expect(locals[:check_url]).to eq("/ops/rbac_group_field_changed/#{@group.id || "new"}___")
expect(locals[:check_url]).to eq("/ops/rbac_group_field_changed/#{@group.id}___")
expect(locals[:highlight_changes]).to eq(true)
expect(locals[:oncheck]).to eq(nil)
expect(locals[:cfmeNoClick]).to eq(true)
Expand Down Expand Up @@ -72,7 +72,15 @@
:tag_tree,
{},
true,
:edit => @edit, :filters => @filters, :group => @group)
:edit => @edit, :filters => @filters, :group => nil)
end
it 'set locals for render correctly' do
locals = @tags_tree.send(:set_locals_for_render)
expect(locals[:checkboxes]).to eq(true)
expect(locals[:check_url]).to eq("/ops/rbac_group_field_changed/new___")
expect(locals[:highlight_changes]).to eq(true)
expect(locals[:oncheck]).to eq("miqOnCheckUserFilters")
expect(locals[:cfmeNoClick]).to eq(true)
end
it 'sets second level nodes correctly' do
selected_kid = @tags_tree.send(:x_get_classification_kids, @folder_selected, false)
Expand Down