Skip to content
Open
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
25 changes: 15 additions & 10 deletions app/controllers/connections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,25 @@ def update
authorize!

from_port = Port.find(params[:connection][:from_port_id])
to_port = Port.find(params[:connection][:to_port_id])

from_port.connect_to_port(to_port,
params[:connection][:cablename],
params[:connection][:color],
params[:connection][:vlans],
params[:connection][:special_case],
params[:connection][:comments])
to_port_id = params[:connection][:to_port_id]

if to_port_id.present?
to_port = Port.find(to_port_id)
@to_server = to_port.server

from_port.connect_to_port(to_port,
params[:connection][:cablename],
params[:connection][:color],
params[:connection][:vlans],
params[:connection][:special_case],
params[:connection][:comments])
else
from_port.update(vlans: params[:connection][:vlans])
end

@from_server = from_port.server
@from_pdu = from_port.circuit&.record unless @from_server

@to_server = to_port.server

respond_to do |format|
format.html do
redirect_to connections_edit_path(from_port_id: from_port.id), notice: t(".flashes.updated")
Expand Down
15 changes: 5 additions & 10 deletions spec/requests/connections_controller_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,12 @@
end
end

# context "without attributes" do
# let(:params) { { connection: {} } }
context "without to_port_id" do
let(:params) { { connection: { from_port_id: "1" } } }
let(:records) { [connections(:one), cables(:one), connections(:two)] }

# it { expect { response }.to raise_error(ActionController::ParameterMissing) }
# end

# context "without parameters" do
# let(:params) { {} }

# it { expect { response }.to raise_error(ActionController::ParameterMissing) }
# end
it { expect(response).to have_http_status(:redirect) }
end

context "with invalid parameters" do
let(:params) { { connection: invalid_attributes } }
Expand Down
Loading