Skip to content

Commit 3fea949

Browse files
authored
Merge pull request #233 from psu-libraries/231-add-job-pages
add page count to job
2 parents b02cba5 + 19574e3 commit 3fea949

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
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

db/schema.rb

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)