Adding more unit tests
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:
@@ -114,4 +114,24 @@ RSpec.describe(BenchmarkController) do
|
||||
expect(last_response.body).to(include("#{@benchmark.name}"))
|
||||
end
|
||||
end
|
||||
|
||||
# GET /benchmark/:benchmark_id/edit - page for editing a benchmark model
|
||||
describe 'GET /benchmark/:benchmark_id/edit' do
|
||||
before do
|
||||
@benchmark = Benchmark.create(name: 'Test Benchmark', scoring: 'fps')
|
||||
get "/benchmark/#{@benchmark.id}/edit"
|
||||
end
|
||||
|
||||
it 'Benchmark edit page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it 'Benchmark edit page is an HTML response' do
|
||||
expect(last_response['Content-Type']).to(include('text/html'))
|
||||
end
|
||||
|
||||
it 'Benchmark edit page contains "Editing: <benchmark name>" on page.' do
|
||||
expect(last_response.body).to(include("Editing: #{@benchmark.name}"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -60,7 +60,7 @@ RSpec.describe(HardwareController) do
|
||||
before do
|
||||
request_data = {
|
||||
hardware_name: 'Test Hardware',
|
||||
hardware_type: 'gpu',
|
||||
hardware_type: 'gpu'
|
||||
}
|
||||
post '/hardware/add', request_data
|
||||
end
|
||||
@@ -109,4 +109,24 @@ RSpec.describe(HardwareController) do
|
||||
expect(last_response.body).to(include("#{@hardware.name}"))
|
||||
end
|
||||
end
|
||||
|
||||
# GET /hardware/:hardware_id/edit - page for editing a hardware model
|
||||
describe 'GET /hardware/:hardware_id/edit' do
|
||||
before do
|
||||
@hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
|
||||
get "/hardware/#{@hardware.id}/edit"
|
||||
end
|
||||
|
||||
it 'Hardware edit page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it 'Hardware edit page is an HTML response' do
|
||||
expect(last_response['Content-Type']).to(include('text/html'))
|
||||
end
|
||||
|
||||
it 'Hardware edit page contains "Editing: <hardware name>" on page.' do
|
||||
expect(last_response.body).to(include("Editing: #{@hardware.name}"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -53,4 +53,113 @@ RSpec.describe(TestController) do
|
||||
expect(last_response.body).to(include('Add new test'))
|
||||
end
|
||||
end
|
||||
|
||||
# POST /test/add - backend for adding a test
|
||||
describe 'POST /test/add' do
|
||||
before do
|
||||
@hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
|
||||
@benchmark = Benchmark.create(name: 'Test Benchmark', scoring: 'fps')
|
||||
request_data = {
|
||||
test_name: 'Test Test',
|
||||
test_hardware: @hardware.id,
|
||||
'test_benchmarks[]': [@benchmark.id],
|
||||
test_description: 'Test for testing'
|
||||
}
|
||||
post '/test/add', request_data
|
||||
end
|
||||
|
||||
it 'Test add POST route is a redirect.' do
|
||||
expect(last_response).to(be_redirect)
|
||||
end
|
||||
|
||||
it 'Test add POST route is an HTML response.' do
|
||||
expect(last_response['Content-Type']).to(include('text/html'))
|
||||
end
|
||||
|
||||
it 'Test add POST route Location header points to /test/1' do
|
||||
expect(last_response['Location']).to(eq("#{BASE_URL}/test/1"))
|
||||
end
|
||||
|
||||
it 'Test add POST route creates new Test.' do
|
||||
expect(Test.count).to(eq(1))
|
||||
end
|
||||
|
||||
it 'Test add POST route created test has name.' do
|
||||
expect(Test.first.name).to(eq('Test Test'))
|
||||
end
|
||||
|
||||
it 'Test add POST route created test has hardware.' do
|
||||
expect(Test.first.hardware.id).to(eq(@hardware.id))
|
||||
end
|
||||
|
||||
it 'Test add POST route created test has benchmarks.' do
|
||||
expect(Test.first.benchmarks.length).to(eq(1))
|
||||
end
|
||||
|
||||
it 'Test add POST route created test\'s benchmark can be read.' do
|
||||
expect(Test.first.benchmarks[0].id).to(eq(@benchmark.id))
|
||||
end
|
||||
|
||||
it 'Test add POST route created test has description.' do
|
||||
expect(Test.first.description).to(eq('Test for testing'))
|
||||
end
|
||||
end
|
||||
|
||||
# GET /test/:test_id - page for viewing a test model
|
||||
describe 'GET /test/:test_id' do
|
||||
before do
|
||||
@hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
|
||||
@benchmark = Benchmark.create(name: 'Test Benchmark', scoring: 'fps')
|
||||
@test = Test.create(
|
||||
name: 'Test Test',
|
||||
hardware_id: @hardware.id,
|
||||
description: 'Test for testing'
|
||||
)
|
||||
@test.add_benchmark(@benchmark)
|
||||
get "/test/#{@test.id}"
|
||||
end
|
||||
|
||||
it 'Test view page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it 'Test view page is an HTML response' do
|
||||
expect(last_response['Content-Type']).to(include('text/html'))
|
||||
end
|
||||
|
||||
it 'Test view page contains test name on page.' do
|
||||
expect(last_response.body).to(include("#{@test.name}"))
|
||||
end
|
||||
|
||||
it 'Test view page contains hardware name on page.' do
|
||||
expect(last_response.body).to(include("#{@hardware.name}"))
|
||||
end
|
||||
end
|
||||
|
||||
# GET /test/:test_id/edit - page for editing a test model
|
||||
describe 'GET /test/:test_id/edit' do
|
||||
before do
|
||||
@hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
|
||||
@benchmark = Benchmark.create(name: 'Test Benchmark', scoring: 'fps')
|
||||
@test = Test.create(
|
||||
name: 'Test Test',
|
||||
hardware_id: @hardware.id,
|
||||
description: 'Test for testing'
|
||||
)
|
||||
@test.add_benchmark(@benchmark)
|
||||
get "/test/#{@test.id}/edit"
|
||||
end
|
||||
|
||||
it 'Test edit page returns 200.' do
|
||||
expect(last_response).to(be_ok)
|
||||
end
|
||||
|
||||
it 'Test edit page is an HTML response' do
|
||||
expect(last_response['Content-Type']).to(include('text/html'))
|
||||
end
|
||||
|
||||
it 'Test edit page contains "Editing: <test name>" on page.' do
|
||||
expect(last_response.body).to(include("Editing: #{@test.name}"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user