Adding a model association test
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2025-08-13 11:06:55 -04:00
parent bd822664b0
commit 05c20b5811
2 changed files with 15 additions and 2 deletions

View File

@@ -19,4 +19,18 @@ RSpec.describe(Test) do
expect(tst.name).to(eq('Test Test')) expect(tst.name).to(eq('Test Test'))
end end
end end
describe 'Test one-to-many association with Hardware' do
it 'Test model has Hardware associated with it.' do
hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
tst = Test.create(name: 'Test Test', hardware_id: hardware.id)
expect(tst.hardware).to(eq(hardware))
end
it 'Test model\'s hardware has name set.' do
hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
tst = Test.create(name: 'Test Test', hardware_id: hardware.id)
expect(tst.hardware.name).to(eq('Test Hardware'))
end
end
end end

View File

@@ -24,8 +24,7 @@ RSpec.configure do |config|
config.include(RSpecMixin) config.include(RSpecMixin)
config.before(:suite) do config.before(:suite) do
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end end
config.around(:each) do |suite| config.around(:each) do |suite|