adds model validations for legislation proposals
This commit is contained in:
@@ -27,6 +27,7 @@ class Legislation::Proposal < ActiveRecord::Base
|
|||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :summary, presence: true
|
validates :summary, presence: true
|
||||||
validates :author, presence: true
|
validates :author, presence: true
|
||||||
|
validates :process, presence: true
|
||||||
|
|
||||||
validates :title, length: { in: 4..Legislation::Proposal.title_max_length }
|
validates :title, length: { in: 4..Legislation::Proposal.title_max_length }
|
||||||
validates :description, length: { maximum: Legislation::Proposal.description_max_length }
|
validates :description, length: { maximum: Legislation::Proposal.description_max_length }
|
||||||
|
|||||||
@@ -816,6 +816,14 @@ LOREM_IPSUM
|
|||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :legislation_proposal, class: 'Legislation::Proposal' do
|
||||||
|
title "Example proposal for a legislation"
|
||||||
|
summary "This law should include..."
|
||||||
|
terms_of_service '1'
|
||||||
|
process factory: :legislation_process
|
||||||
|
author factory: :user
|
||||||
|
end
|
||||||
|
|
||||||
factory :site_customization_page, class: 'SiteCustomization::Page' do
|
factory :site_customization_page, class: 'SiteCustomization::Page' do
|
||||||
slug "example-page"
|
slug "example-page"
|
||||||
title "Example page"
|
title "Example page"
|
||||||
|
|||||||
30
spec/models/legislation/proposal_spec.rb
Normal file
30
spec/models/legislation/proposal_spec.rb
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe Legislation::Proposal do
|
||||||
|
let(:proposal) { build(:legislation_proposal) }
|
||||||
|
|
||||||
|
it "should be valid" do
|
||||||
|
expect(proposal).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not be valid without a process" do
|
||||||
|
proposal.process = nil
|
||||||
|
expect(proposal).to_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not be valid without an author" do
|
||||||
|
proposal.author = nil
|
||||||
|
expect(proposal).to_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not be valid without a title" do
|
||||||
|
proposal.title = nil
|
||||||
|
expect(proposal).to_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not be valid without a summary" do
|
||||||
|
proposal.summary = nil
|
||||||
|
expect(proposal).to_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user