Sha256: 0ea88808836eeecad099889f71877611710ce9015b6d379e25e3fc749c96636b

Contents?: true

Size: 723 Bytes

Versions: 8

Compression:

Stored size: 723 Bytes

Contents

require 'spec_helper'

describe Helena::Survey do
  it { expect(subject).to have_many(:versions).with_dependent(:destroy) }
  it { expect(subject).to have_many(:sessions).with_dependent(:destroy) }

  it { expect(subject).to validate_presence_of(:name) }
  it { expect(subject).to validate_presence_of(:language) }
  it { expect(subject).to validate_uniqueness_of(:name) }

  it 'has a valid factory' do
    expect(build :survey).to be_valid
  end

  it 'returns the newest version if there are any' do
    survey = create :survey

    expect(survey.newest_version).to be_nil

    survey.versions.create version: 99
    survey.versions.create version: 0

    expect(survey.reload.newest_version.version).to be 99
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
helena-1.1.0 spec/models/helena/survey_spec.rb
helena-1.0.3 spec/models/helena/survey_spec.rb
helena-1.0.2 spec/models/helena/survey_spec.rb
helena-1.0.1 spec/models/helena/survey_spec.rb
helena-1.0.0.rc4 spec/models/helena/survey_spec.rb
helena-1.0.0.rc3 spec/models/helena/survey_spec.rb
helena-1.0.0.rc2 spec/models/helena/survey_spec.rb
helena-1.0.0.rc1 spec/models/helena/survey_spec.rb