Browse Source

Update tests

pull/2539/head
Manny Dinssa 2 years ago
parent
commit
9e1c706ddb
  1. 4
      spec/lib/tasks/log_variable_definitions_spec.rb
  2. 18
      spec/services/imports/variable_definitions_service_spec.rb

4
spec/lib/tasks/log_variable_definitions_spec.rb

@ -14,7 +14,7 @@ RSpec.describe "log_variable_definitions" do
end
it "adds CsvVariableDefinition records from each file in the specified directory" do
expect { task.invoke(path) }.to change(CsvVariableDefinition, :count).by(419)
expect { task.invoke(path) }.to change(CsvVariableDefinition, :count).by(416)
end
it "handles an empty directory without errors" do
@ -34,7 +34,7 @@ RSpec.describe "log_variable_definitions" do
task.invoke(path)
second_run_count = CsvVariableDefinition.count
expect(first_run_count).to eq(initial_count + 419)
expect(first_run_count).to eq(initial_count + 416)
expect(second_run_count).to eq(first_run_count)
end
end

18
spec/services/imports/variable_definitions_service_spec.rb

@ -40,23 +40,5 @@ RSpec.describe Imports::VariableDefinitionsService, type: :service do
}.to change(CsvVariableDefinition, :count).by(3)
end
end
context "when existing record with user_type support" do
let!(:existing_record) { create(:csv_variable_definition, variable: "id", definition: "Log ID", log_type: "lettings", user_type: "support") }
it "updates the user_type to user" do
service.send(:process_file, file)
expect(existing_record.reload.user_type).to eq("user")
end
end
context "when existing record with user_type user" do
let!(:existing_record) { create(:csv_variable_definition, variable: "id", definition: "Log ID", log_type: "lettings", user_type: "user") }
it "does not update the user_type" do
service.send(:process_file, file)
expect(existing_record.reload.user_type).to eq("user")
end
end
end
end

Loading…
Cancel
Save