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

Make Save button respond properly on changes in NTP Servers section while editing a Zone #6162

Merged
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
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