-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73e3b64
commit 7bc5dd9
Showing
5 changed files
with
48 additions
and
1 deletion.
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,3 @@ | ||
class CsvUpload < ApplicationRecord | ||
validates_presence_of :data, :original_filename, :parser_class_name | ||
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,10 @@ | ||
class CreateCsvUploads < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :csv_uploads do |t| | ||
t.text :data | ||
t.string :parser_class_name | ||
t.string :original_filename | ||
t.timestamps | ||
end | ||
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,7 @@ | ||
FactoryBot.define do | ||
factory :csv_upload do | ||
data { "123,foo,true" } | ||
original_filename { "sample-data.csv" } | ||
parser_class_name { "SampleParser" } | ||
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,24 @@ | ||
require "rails_helper" | ||
|
||
describe CsvUpload do | ||
describe "validation" do | ||
context "without required attrs" do | ||
it "is invalid" do | ||
csv_upload = CsvUpload.new | ||
expect(csv_upload).to_not be_valid | ||
end | ||
end | ||
|
||
context "with required attrs" do | ||
it "is valid" do | ||
csv_upload = CsvUpload.new( | ||
data: "foo,bar,baz", | ||
original_filename: "dummy-data.csv", | ||
parser_class_name: "DummyParser" | ||
) | ||
|
||
expect(csv_upload).to be_valid | ||
end | ||
end | ||
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