-
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.
Allow creation of a failure object through api
This allows the creation of a failure object which contains file, line number, test name and the test failure message
- Loading branch information
Showing
4 changed files
with
38 additions
and
0 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,19 @@ | ||
class FailuresController < ApplicationController | ||
skip_before_action :verify_authenticity_token | ||
|
||
def create | ||
failure = Failure.new(failure_params) | ||
|
||
if failure.save | ||
render json: failure | ||
else | ||
render json: { error: 'Unable to create failure' } | ||
end | ||
end | ||
|
||
private | ||
|
||
def failure_params | ||
params.permit(:test_file, :test_name, :line_number, :failure) | ||
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,2 @@ | ||
class Failure < ApplicationRecord | ||
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,5 @@ | ||
Rails.application.routes.draw do | ||
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html | ||
|
||
resource :failures, only: :create | ||
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,12 @@ | ||
class CreateFailures < ActiveRecord::Migration[6.1] | ||
def change | ||
create_table :failures do |t| | ||
t.string :test_file | ||
t.string :test_name | ||
t.integer :line_number | ||
t.text :failure | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |