Sha256: 8843a8af47d1c6e6464f2c5195905aadc985b6bc120661e07b6c70eeea0ecf93

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'temping'
require 'has_siblings'

ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT) if ENV["DEBUG"]

Temping.create :spannable_model do
  with_columns do |t|
    t.date :starting_date
    t.date :ending_date

    t.integer :unique_by_date_range
  end
end

Temping.create :span_model do
  with_columns do |t|
    t.date :start_date
    t.date :end_date
  end

  acts_as_span
end

Temping.create :one_parent_child do
  with_columns do |t|
    t.belongs_to :mama

    t.date :start_date
    t.date :end_date
  end

  acts_as_span

  belongs_to :mama
  has_siblings through: [:mama]

  validates_with ActsAsSpan::NoOverlapValidator, scope: proc { siblings }
  validates_with ActsAsSpan::WithinParentDateSpanValidator, parents: [:mama]
end

Temping.create :two_parent_child do
  with_columns do |t|
    t.belongs_to :mama
    t.belongs_to :papa

    t.date :start_date
    t.date :end_date
  end

  acts_as_span

  belongs_to :mama
  belongs_to :papa
  has_siblings through: [:mama, :papa]

  validates_with ActsAsSpan::NoOverlapValidator, scope: proc { siblings }
  validates_with ActsAsSpan::WithinParentDateSpanValidator, parents: [:mama, :papa]
end

Temping.create :mama do
  with_columns do |t|
    t.date :start_date
    t.date :end_date
  end

  has_many :one_parent_children
  has_many :two_parent_children
end

Temping.create :papa do
  with_columns do |t|
    t.date :start_date
    t.date :end_date
  end

  has_many :one_parent_children
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_span-1.0.0 spec/spec_models.rb