Skip to content

Instantly share code, notes, and snippets.

@knoxjeffrey
Created March 29, 2019 09:41
Show Gist options
  • Save knoxjeffrey/1a9ccb486d21f2205267ffa25c459df5 to your computer and use it in GitHub Desktop.
Save knoxjeffrey/1a9ccb486d21f2205267ffa25c459df5 to your computer and use it in GitHub Desktop.
require 'rails_helper'
describe Members::Charters::JoinedUpForm, type: :model do
context 'validations' do
let(:charter) { create(:charter) }
let(:charter_two) do
create(:charter, progression_to_service_evidence: true)
end
let(:charter_three) do
create(:charter, past_current_partnerships_evidence: true)
end
it 'on form object' do
object = Members::Charters::JoinedUpForm.new(charter)
object_two = Members::Charters::JoinedUpForm.new(charter_two)
object_three = Members::Charters::JoinedUpForm.new(charter_three)
expect(object).to validate_presence_of(:progression_to_service)
expect(object).to validate_presence_of(:past_current_partnerships)
expect(object).to validate_length_of(:progression_to_service)
.is_at_most(500)
expect(object).to validate_length_of(:past_current_partnerships)
.is_at_most(500)
expect(object).to validate_inclusion_of(:progression_to_service_evidence)
.in_array([true, false])
expect(object).to validate_inclusion_of(
:past_current_partnerships_evidence
).in_array([true, false])
expect(object_two).to validate_presence_of(:progression_to_service_ind)
expect(object_three).to validate_presence_of(
:past_current_partnerships_ind
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment