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

Correct Apply button states on Import/Import Tags forms #9261

Merged
merged 3 commits into from
Jun 17, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/controllers/ops_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,15 @@ def explorer
@build = nil
@sb[:user] = nil
@ldap_group = nil
else
session[:changed] = @sb[:show_button] if params[:no_refresh] &&
%w(settings_import settings_import_tags).include?(@sb[:active_tab]) # show apply button enabled if this is set
elsif %w(settings_import settings_import_tags).include?(@sb[:active_tab])
session[:changed] = !flash_errors?
end
# setting active record object here again, since they are no longer there due to redirect
@ldap_group = @edit[:ldap_group] if params[:cls_id] && params[:cls_id].split('_')[0] == "lg"
@x_edit_buttons_locals = set_form_locals if @in_a_form
@collapse_c_cell = @in_a_form || @pages ? false : true
@sb[:center_tb_filename] = center_toolbar_filename
edit_changed? if @edit
edit_changed? if @edit && !%w(settings_import settings_import_tags).include?(@sb[:active_tab])
render :layout => "application"
end

Expand Down
37 changes: 37 additions & 0 deletions spec/controllers/ops_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,41 @@
expect(response.body).to include("if (miqDomElementExists('toolbar')) $('#toolbar').show();")
end
end

context "Import Tags and Import forms" do
%w(settings_import settings_import_tags).each do |tab|
render_views

before do
_guid, @miq_server, @zone = EvmSpecHelper.remote_guid_miq_server_zone
allow(controller).to receive(:check_privileges).and_return(true)
allow(controller).to receive(:assert_privileges).and_return(true)
controller.instance_variable_set(:@sb, {})
allow(controller).to receive(:x_active_tree).and_return(:settings_tree)
allow(controller).to receive(:x_node).and_return("root")
controller.x_active_tree = 'settings_tree'
expect(controller).to receive(:render_to_string).with(any_args).twice
post :change_tab, :params => {:tab_id => tab}
end

it "Apply button remains disabled with flash errors" do
post :explorer, :params => {:flash_error => 'true',
:flash_msg => 'Error during upload',
:no_refresh => 'true'}
expect(response.status).to eq(200)
expect(response.body).to_not be_empty
expect(response.body).to include("<div id='buttons_on' style='display: none;'>")
expect(response.body).to include("<div id='buttons_off' style=''>\n<button name=\"button\" type=\"submit\" class=\"btn btn-primary btn-disabled\">Apply</button>")
end

it "Apply button enabled when there are no flash errors" do
controller.instance_variable_set(:@flash_array, [])
post :explorer, :params => {:no_refresh => 'true'}
expect(response.status).to eq(200)
expect(response.body).to_not be_empty
expect(response.body).to include("<div id='buttons_on' style=''>")
expect(response.body).to include("<div id='buttons_off' style='display: none;'>\n<button name=\"button\" type=\"submit\" class=\"btn btn-primary btn-disabled\">Apply</button>")
end
end
end
end