Skip to content

Commit 2163988

Browse files
committed
add page count to job
1 parent 9200646 commit 2163988

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

app/models/job.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def self.statuses
99
end
1010

1111
validates :status, inclusion: { in: statuses }
12+
validates :page_count, numericality: { greater_than: 0, only_integer: true }, allow_nil: true
1213

1314
def completed?
1415
status == 'completed'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddPageCountToJob < ActiveRecord::Migration[7.2]
2+
def change
3+
add_column :jobs, :page_count, :integer, null: true
4+
end
5+
end

spec/models/job_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
it { is_expected.to have_db_column(:output_object_key).of_type(:text) }
2020
it { is_expected.to have_db_column(:processing_error_message).of_type(:text) }
2121
it { is_expected.to have_db_column(:output_url_expires_at).of_type(:datetime).with_options(null: true) }
22+
it { is_expected.to have_db_column(:page_count).of_type(:integer).with_options(null: true) }
2223
it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(null: false) }
2324
it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(null: false) }
2425

@@ -28,6 +29,7 @@
2829

2930
describe 'validations' do
3031
it { is_expected.to validate_inclusion_of(:status).in_array ['processing', 'completed', 'failed'] }
32+
it { is_expected.to validate_numericality_of(:page_count).is_greater_than(0).only_integer.allow_nil }
3133

3234
context 'when the owner is an APIUSer' do
3335
it 'validates the format of source_url' do

0 commit comments

Comments
 (0)