Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
apricot13 committed Nov 13, 2024
1 parent 253e326 commit 5e690ba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/tasks/data_import/services/import_services.rake
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace :import do
def import_service_meta(type, service_id, fields_for_import, row)
fields_for_import.map do |t|
# Find the existing custom field to add this service meta to
custom_field = CustomField.where(field_type: type).find{|cf| cf.key.downcase.delete("^a-zA-Z0-9 ").gsub(' ', '_') === t}
custom_field = CustomField.where(field_type: type).find{|cf| cf.label.downcase.delete("^a-zA-Z0-9 ").gsub(' ', '_') === t}

unless custom_field.present?
Rails.logger.info("🟠 Custom field \"#{t}\" of type #{type} does not exist. Please check the field name or create the custom field in order to add this service data. Perhaps you have forgotten to run the custom field import?")
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/service_meta.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :service_meta do
key { Faker::Lorem.sentence }
label { Faker::Lorem.sentence }
value { Faker::Number.number }
end
end
4 changes: 2 additions & 2 deletions spec/models/custom_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe CustomField, type: :model do
subject { FactoryBot.build :custom_field }

it { should validate_presence_of :key }
it { should validate_uniqueness_of :key }
it { should validate_presence_of :label }
it { should validate_uniqueness_of :label }
it { should validate_presence_of :field_type }
end
4 changes: 2 additions & 2 deletions spec/models/service_meta_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
RSpec.describe ServiceMeta, type: :model do
subject { FactoryBot.create :service_meta, service: FactoryBot.create(:service) }

it { should validate_presence_of(:key) }
it { should validate_uniqueness_of(:key).scoped_to(:service_id) }
it { should validate_presence_of(:label) }
it { should validate_uniqueness_of(:label).scoped_to(:service_id) }
end

0 comments on commit 5e690ba

Please sign in to comment.