-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class AssertionResultsController < ApplicationController | ||
before_action :set_test_result | ||
|
||
def index | ||
@assertion_results = @test_result.assertion_results | ||
end | ||
|
||
private | ||
|
||
def set_test_result | ||
@test_result = current_user.test_results.find(params[:test_result_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
json.extract! assertion_result, :id, :test_result_id, :assertion_id, :state, :created_at, :updated_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
json.array! @assertion_results, partial: 'assertion_results/assertion_result', as: :assertion_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
json.extract! test_result, :id, :result, :content, :time, :rating, :status, :created_at, :updated_at | ||
json.extract! test_result, :id, :result, :time, :rating, :status, :created_at, :updated_at | ||
json.url test_result_url(test_result, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
json.partial! 'test_results/test_result', test_result: @test_result | ||
json.assertion_results @test_result.assertion_result_ids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
json.extract! test_run, :id, :name, :created_at, :updated_at | ||
json.test_result_ids test_run.test_result_ids | ||
json.url prompt_url(test_run, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe AssertionResultsController, type: :controller do | ||
let(:user) { create(:user) } | ||
let(:prompt) { create(:prompt, user:) } | ||
let(:test_run) { create(:test_run, prompt:) } | ||
let(:model) { create(:model, user:) } | ||
let(:model_version) { create(:model_version, model:) } | ||
let(:test_model_version_run) { create(:test_model_version_run, test_run:, model_version:) } | ||
let(:test_result) { create(:test_result, test_model_version_run:) } | ||
|
||
before do | ||
sign_in user | ||
end | ||
|
||
describe 'GET #index' do | ||
it 'returns a success response' do | ||
get :index, params: { test_result_id: test_result.id }, format: :json | ||
expect(response).to be_successful | ||
end | ||
|
||
it 'sets the correct test_result' do | ||
get :index, params: { test_result_id: test_result.id }, format: :json | ||
expect(assigns(:test_result)).to eq(test_result) | ||
end | ||
|
||
it 'sets the correct assertion_results' do | ||
get :index, params: { test_result_id: test_result.id }, format: :json | ||
expect(assigns(:assertion_results)).to eq(test_result.assertion_results) | ||
end | ||
end | ||
end |