Skip to content

Commit

Permalink
MiqAeClassController: more style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed Aug 28, 2017
1 parent 035bcd4 commit 3ab7fbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
20 changes: 9 additions & 11 deletions app/controllers/miq_ae_class_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2125,14 +2125,10 @@ def get_method_form_vars
# Get variables from edit form
def get_ns_form_vars
@ae_ns = @edit[:typ].constantize.find_by_id(from_cid(@edit[:ae_ns_id]))
[:ns_name, :ns_description, :enabled].each do |field|
@edit[:new][field] = if field == :enabled
params[:ns_enabled] == "1" if params[:ns_enabled]
elsif params[field].present?
params[field]
else
nil
end
@edit[:new][:enabled] = params[:ns_enabled] == '1' if params[:ns_enabled]
[:ns_name, :ns_description].each do |field|
next unless params[field]
@edit[:new][field] = params[field].blank? ? nil : params[field]
end
@in_a_form = true
end
Expand Down Expand Up @@ -2323,7 +2319,7 @@ def move_selected_fields_down(available_fields, selected_fields, display_name)
consecutive, first_idx, last_idx = selected_consecutive?(available_fields, selected_fields)
if consecutive
if last_idx < available_fields.length - 1
insert_idx = last_idx + 1 # Insert before the element after the last one
insert_idx = last_idx + 1 # Insert before the element after the last one
insert_idx = -1 if last_idx == available_fields.length - 2 # Insert at end if 1 away from end
available_fields[first_idx..last_idx].each do |field|
pulled = available_fields.delete(field)
Expand Down Expand Up @@ -2458,8 +2454,9 @@ def domain_toggle(locked)
javascript_flash
end
domain_toggle_lock(params[:id], locked)
add_flash(_("The selected %{model} were marked as %{action}") % {:model => ui_lookup(:model => "MiqAeDomain"), :action => action},
:info, true) unless flash_errors?
unless flash_errors?
add_flash(_("The selected %{model} were marked as %{action}") % {:model => ui_lookup(:model => "MiqAeDomain"), :action => action}, :info, true)
end
replace_right_cell(:replace_trees => [:ae])
end

Expand Down Expand Up @@ -2547,6 +2544,7 @@ def get_method_node_info(id)
@record = @ae_method = MiqAeMethod.find(from_cid(id[1]))
rescue ActiveRecord::RecordNotFound
set_root_node
return
end

@ae_class = @record.ae_class
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/miq_ae_class_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@

context "when the record exists" do
before do
allow(MiqAeInstance).to receive(:find_by_id).with(123).and_return(miq_ae_instance)
allow(MiqAeInstance).to receive(:find).with(123).and_return(miq_ae_instance)
allow(miq_ae_instance).to receive(:ae_class).and_return(miq_ae_class)
allow(MiqAeInstance).to receive(:get_homonymic_across_domains)
.with(@user, "fqname").and_return([override, override2])
Expand Down Expand Up @@ -348,7 +348,7 @@

context "when the record exists" do
before do
allow(MiqAeClass).to receive(:find_by_id).with(1).and_return(miq_ae_class)
allow(MiqAeClass).to receive(:find).with(1).and_return(miq_ae_class)
allow(MiqAeClass).to receive(:get_homonymic_across_domains)
.with(@user, "cls_fqname").and_return([override, override2])
end
Expand Down Expand Up @@ -380,7 +380,7 @@

context "when the record exists" do
before do
allow(MiqAeMethod).to receive(:find_by_id).with(123).and_return(miq_ae_method)
allow(MiqAeMethod).to receive(:find).with(123).and_return(miq_ae_method)
allow(miq_ae_method).to receive(:location).with(no_args).and_return("inline")
allow(miq_ae_method).to receive(:ae_class).and_return(miq_ae_class)
allow(MiqAeMethod).to receive(:get_homonymic_across_domains)
Expand Down

0 comments on commit 3ab7fbd

Please sign in to comment.