Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Activity: Ensure days is not an empty string.
Browse files Browse the repository at this point in the history
References #52.
  • Loading branch information
ybakos committed Sep 8, 2020
1 parent 69f68b6 commit 229e6fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Activity < ApplicationRecord
message: 'must start with http or https'
}, if: -> { url.present? }
validate :end_date_after_start_date
validates :days, presence: true, allow_nil: true

enum state: [:pending, :active, :denied]

Expand Down
1 change: 1 addition & 0 deletions spec/models/activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

describe 'validations' do
specify { expect(activity).to validate_presence_of(:title) }
specify { expect(activity).to validate_presence_of(:days).allow_nil }
it 'url format' do
expect(activity).to allow_value('http://fake.com').for(:url)
expect(activity).to allow_value('https://fake.com').for(:url)
Expand Down

0 comments on commit 229e6fb

Please sign in to comment.