Skip to content

Commit

Permalink
Correct advanced Rubocop offences
Browse files Browse the repository at this point in the history
New GOV.UK Rubocop rules applied here.
  • Loading branch information
TheDoubleK committed Aug 6, 2024
1 parent 455b365 commit 1a539f9
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 20 deletions.
6 changes: 2 additions & 4 deletions spec/acceptance/import_certificate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def attributes_values_from_database(column, attribute)

before do
allow(Gateway::RegisterApiGateway).to receive(:new).and_return(certificate_gateway)
allow(certificate_gateway).to receive(:fetch).and_return(xml_sample)
allow(certificate_gateway).to receive(:fetch_meta_data).and_return(meta_data_sample)
allow(certificate_gateway).to receive_messages(fetch: xml_sample, fetch_meta_data: meta_data_sample)
queues_gateway.push_to_queue(:assessments, ids)
allow(assessments_country_id_gateway).to receive(:insert)
use_case.execute
Expand Down Expand Up @@ -179,8 +178,7 @@ def attributes_values_from_database(column, attribute)

before do
allow(Gateway::RegisterApiGateway).to receive(:new).and_return(certificate_gateway)
allow(certificate_gateway).to receive(:fetch).and_return(xml_sample)
allow(certificate_gateway).to receive(:fetch_meta_data).and_return(meta_data_sample)
allow(certificate_gateway).to receive_messages(fetch: xml_sample, fetch_meta_data: meta_data_sample)
queues_gateway.push_to_queue(:assessments, ids)
use_case.execute
end
Expand Down
3 changes: 1 addition & 2 deletions spec/shared_context/shared_send_heat_pump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def template_id

def stub_notify_response
response = class_double("response")
allow(response).to receive(:code).and_return(400)
allow(response).to receive(:body).and_return(notify_body.to_s)
allow(response).to receive_messages(code: 400, body: notify_body.to_s)
response
end

Expand Down
4 changes: 1 addition & 3 deletions spec/tasks/email_heat_pump_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@

before do
ENV["NOTIFY_TEMPLATE_ID"] = template_id
allow(Container).to receive(:export_heat_pumps_gateway).and_return export_gateway
allow(Container).to receive(:file_gateway).and_return file_gateway
allow(Container).to receive(:notify_gateway).and_return notify_gateway
allow(Container).to receive_messages(export_heat_pumps_gateway: export_gateway, file_gateway:, notify_gateway:)
end

after do
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/gateway/assessment_attributes_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@

context "when there is no data present" do
it "returns false when cheking a certificate has attribute data" do
expect(gateway.assessment_exists("0000-0000-0000-0000-0001")).to eq(false)
expect(gateway.assessment_exists("0000-0000-0000-0000-0001")).to be(false)
end

it "returns true when we add certificate data" do
Expand All @@ -449,7 +449,7 @@
attribute_name: "transaction_type",
attribute_value: { "description": "marketed sale", "value": "10.0" },
)
expect(gateway.assessment_exists("0000-0000-0000-0000-0001")).to eq(true)
expect(gateway.assessment_exists("0000-0000-0000-0000-0001")).to be(true)
end

context "when deleting an attribute value by name and assessment" do
Expand Down
7 changes: 3 additions & 4 deletions spec/unit/gateway/xsd_config_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@
end

before do
allow(gateway).to receive(:nodes).and_return(nodes)
allow(gateway).to receive(:paths).and_return({ "rdsap" => "/api/schemas/xml/RdSAP**/RdSAP/UDT/*-Domains.xsd",
"sap" => "/api/schemas/xml/SAP**/SAP/UDT/*-Domains.xsd",
"cepc" => "/api/schemas/xml/CEPC**/Reports/Reported-Data.xsd" })
allow(gateway).to receive_messages(nodes:, paths: { "rdsap" => "/api/schemas/xml/RdSAP**/RdSAP/UDT/*-Domains.xsd",
"sap" => "/api/schemas/xml/SAP**/SAP/UDT/*-Domains.xsd",
"cepc" => "/api/schemas/xml/CEPC**/Reports/Reported-Data.xsd" })
end

it "preserves the xsd_path attribute and is not overwritten by the values from the path hash" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/use_case/import_certificate_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
end

it "runs the use case without erroring" do
use_case.execute(assessment_id:, certificate_data:)
expect { use_case.execute(assessment_id:, certificate_data:) }.not_to raise_error
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/unit/use_case/import_json_certificates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
result["attribute_name"] == "asset_rating"
end
expect(arr[0]["attribute_value"]).to eq("80")
expect(arr[0]["parent_name"]).to eq(nil)
expect(arr[0]["parent_name"]).to be_nil
expect(arr[0]["attribute_value_int"]).to eq(80)
end

Expand All @@ -93,7 +93,7 @@
result["attribute_name"] == "current_carbon_emission"
end
expect(arr[0]["attribute_value"]).to eq("2.4")
expect(arr[0]["parent_name"]).to eq(nil)
expect(arr[0]["parent_name"]).to be_nil
expect(arr[0]["attribute_value_float"]).to eq(2.4)
end

Expand Down
3 changes: 1 addition & 2 deletions spec/unit/use_case/send_heat_pump_counts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
allow(Gateway::FileGateway).to receive(:new).and_return(file_gateway)
allow(file_gateway).to receive(:save_csv).with(data, file_name).and_return File
allow(Gateway::NotifyGateway).to receive(:new).with(notify_client).and_return(notify_gateway)
allow(notify_gateway).to receive(:send_email).and_return Notifications::Client::ResponseNotification
allow(notify_gateway).to receive(:check_email_status).and_return client_response
allow(notify_gateway).to receive_messages(send_email: Notifications::Client::ResponseNotification, check_email_status: client_response)
end

it "calls the correct gateway method" do
Expand Down

0 comments on commit 1a539f9

Please sign in to comment.