1 Commits

Author SHA1 Message Date
Gregory Ballantine
2884b94b7f [Issue #16] - Finished updating Test controller routes that used to reference Benchmarks
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-10-09 15:43:53 -04:00
7 changed files with 24 additions and 34 deletions

View File

@@ -1,27 +1,16 @@
FROM ruby:3.4-slim
FROM ruby:3.4
# 1. Install essential build tools for gems like 'pg' or 'sqlite3'
RUN apt-get update -qq && apt-get install -y \
build-essential \
libpq-dev \
curl \
git
RUN gem install bundler
WORKDIR /usr/src/game-data
# 2. Set environment variables for the Gem volume we discussed
ENV BUNDLE_PATH=/usr/local/bundle \
BUNDLE_BIN=/usr/local/bundle/bin \
PATH=/usr/local/bundle/bin:$PATH
COPY Gemfile Gemfile.l*ck ./
# 3. Copy Gemfile first to leverage layer caching
COPY Gemfile Gemfile.lock ./
RUN bundle install
RUN bundle check || bundle install
RUN gem install rake
# 4. Copy the application code
COPY . ./
# 5. Make sure your entrypoint script is executable
RUN chmod +x entrypoints/dev.sh
ENTRYPOINT ["bash", "entrypoints/dev.sh"]

View File

@@ -1,9 +1,7 @@
#!/bin/bash
# Run the migrations to make sure the DB is up-to-date
echo 'Checking database status...'
if [ ! -f ./data/gamedata.db ]; then
rake db:migrate
fi
# Start the HTTP server
echo 'Starting development server...'
rake server:dev

View File

@@ -59,10 +59,11 @@ RSpec.describe(TestController) do
before do
@hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
@benchmark = Benchmark.create(name: 'Test Benchmark', scoring: 'fps')
@benchmark_profile = BenchmarkProfile.create(label: 'Test Benchmark Profile', settings: '{}', benchmark_id: @benchmark.id)
request_data = {
test_name: 'Test Test',
test_hardware: @hardware.id,
'test_benchmarks[]': [@benchmark.id],
'test_benchmarks[]': [@benchmark_profile.id],
test_description: 'Test for testing'
}
post '/test/add', request_data
@@ -93,11 +94,11 @@ RSpec.describe(TestController) do
end
it 'Test add POST route created test has benchmarks.' do
expect(Test.first.benchmarks.length).to(eq(1))
expect(Test.first.benchmark_profiles.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))
expect(Test.first.benchmark_profiles[0].id).to(eq(@benchmark.id))
end
it 'Test add POST route created test has description.' do
@@ -110,12 +111,13 @@ RSpec.describe(TestController) do
before do
@hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
@benchmark = Benchmark.create(name: 'Test Benchmark', scoring: 'fps')
@benchmark_profile = BenchmarkProfile.create(label: 'Test Benchmark Profile', settings: '{}', benchmark_id: @benchmark.id)
@test = Test.create(
name: 'Test Test',
hardware_id: @hardware.id,
description: 'Test for testing'
)
@test.add_benchmark(@benchmark)
@test.add_benchmark_profile(@benchmark_profile)
get "/test/#{@test.id}"
end
@@ -141,12 +143,13 @@ RSpec.describe(TestController) do
before do
@hardware = Hardware.create(name: 'Test Hardware', type: 'gpu')
@benchmark = Benchmark.create(name: 'Test Benchmark', scoring: 'fps')
@benchmark_profile = BenchmarkProfile.create(label: 'Test Benchmark Profile', settings: '{}', benchmark_id: @benchmark.id)
@test = Test.create(
name: 'Test Test',
hardware_id: @hardware.id,
description: 'Test for testing'
)
@test.add_benchmark(@benchmark)
@test.add_benchmark_profile(@benchmark_profile)
get "/test/#{@test.id}/edit"
end

View File

@@ -12,7 +12,7 @@ class ResultController < BaseController
Result.create(
test_id: params[:result_test],
benchmark_profile_id: params[:result_benchmark],
benchmark_id: params[:result_benchmark],
avg_score: params[:result_average],
min_score: result_minimum,
max_score: result_maximum

View File

@@ -7,8 +7,8 @@ class Test < Sequel::Model
many_to_one :hardware
many_to_many :benchmark_profiles
def benchmark?(benchmark_id)
return benchmark_profiles_dataset.where(Sequel[:benchmark_profiles][:id] => benchmark_id).any?
def benchmark?(benchmark_profile_id)
return benchmark_profiles_dataset.where(Sequel[:benchmark_profiles][:id] => benchmark_profile_id).any?
end
end

View File

@@ -29,7 +29,7 @@
<select id="test_benchmarks" class="form-select" name="test_benchmarks[]" multiple>
<% for b in benchmarks %>
<% for bp in b.benchmark_profiles %>
<option value="<%= bp.id %>"><%= bp.display_name %></option>
<option value="<%= bp.id %>"><%= b.display_name() %></option>
<% end %>
<% end %>
</select>

View File

@@ -71,8 +71,8 @@
</tr>
</thead>
<tbody>
<% test.benchmark_profiles.each do |bp| %>
<tr data-benchmark-id="<%= bp.id %>"></tr>
<% test.benchmark_profiles.each do |benchmark| %>
<tr data-benchmark-id="<%= benchmark.id %>"></tr>
<% end %>
</tbody>
</table>