Sha256: 19daee14af7d410ecac5562c91574ec4284caacd129105061e777410104f86ce

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

require "spec_helper"

describe Crono::CronoJob do
  let(:valid_attrs) do
    {
      job_id: "Perform TestJob every 3 days"
    }
  end

  it "should validate presence of job_id" do
    @crono_job = Crono::CronoJob.new()
    expect(@crono_job).not_to be_valid
    expect(@crono_job.errors.added?(:job_id, :blank)).to be true
  end

  it "should validate uniqueness of job_id" do
    Crono::CronoJob.create!(job_id: "TestJob every 2 days")
    @crono_job = Crono::CronoJob.create(job_id: "TestJob every 2 days")
    expect(@crono_job).not_to be_valid
    expect(@crono_job.errors.added?(:job_id, :taken)).to be true
  end

  it "should save job_id to DB" do
    Crono::CronoJob.create!(valid_attrs)
    @crono_job = Crono::CronoJob.find_by(job_id: valid_attrs[:job_id])
    expect(@crono_job).to be_present
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
crono-0.7.0 spec/orm/active_record/crono_job_spec.rb
crono-0.6.1 spec/orm/active_record/crono_job_spec.rb