Adding a model association test
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -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
|
||||||
|
@@ -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|
|
||||||
|
Reference in New Issue
Block a user