Skip to content

Commit

Permalink
Make Save button respond properly on changes in NTP Servers section
Browse files Browse the repository at this point in the history
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1749841

Make the button respond properly while editing an existing Zone.
  • Loading branch information
Hilda Stastna committed Sep 9, 2019
1 parent 6c58f52 commit bb7d490
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/controllers/ops_controller/settings/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,8 @@ def settings_get_form_vars
field = "ntp_server_#{field_num}"
next unless params.key?(field)
@edit[:new][:ntp][field] = params[field]
# remove unnecessary key from @edit[:new][:ntp] if there is no change
@edit[:new][:ntp].except!(field) if params[field] == @edit[:new][:ntp][:server][field_num - 1]
end
end

Expand Down
28 changes: 21 additions & 7 deletions spec/controllers/ops_controller/settings/common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@
@edit = session[:edit]
end

context "#smartproxy_affinity_field_changed" do
before do
expect(controller).to receive(:render)
end
describe "#smartproxy_affinity_field_changed" do
before { expect(controller).to receive(:render) }

it "should select a host when checked" do
controller.params = {:id => "xx-#{@svr1.id}__host_#{@host2.id}", :check => '1'}
Expand Down Expand Up @@ -115,7 +113,7 @@
end
end

context "#smartproxy_affinity_update" do
describe "#smartproxy_affinity_update" do
it "updates the SmartProxy host affinities" do
@svr1.vm_scan_host_affinity = []
@svr2.vm_scan_host_affinity = []
Expand All @@ -138,8 +136,9 @@
end
end

context "#settings_update" do
describe "#settings_update" do
let(:orgs) { [1] }

before do
session[:edit] = {
:key => "settings_rhn_edit__rhn_edit",
Expand Down Expand Up @@ -178,7 +177,7 @@
end
end

context "#settings_get_form_vars" do
describe "#settings_get_form_vars" do
before do
miq_server = FactoryBot.create(:miq_server)
current = ::Settings.to_hash
Expand Down Expand Up @@ -210,6 +209,21 @@
end
end

describe '#settings_get_form_vars_sync_ntp' do
before do
controller.params = {'ntp_server_2' => '1'}
controller.instance_variable_set(:@edit, :current => {:ntp => {:server => ['0', '1', '2']}},
:new => {:ntp => {:server => ['0', '1', '2'], 'ntp_server_2' => ''}})
end

subject { controller.instance_variable_get(:@edit) }

it 'removes unnecessary key from @edit[:new][:ntp]' do
controller.send(:settings_get_form_vars_sync_ntp)
expect(subject[:new]).to eq(subject[:current])
end
end

describe "#pglogical_save_subscriptions" do
before { allow(controller).to receive(:javascript_flash) }

Expand Down

0 comments on commit bb7d490

Please sign in to comment.