add test for evenement vie and fix associations
This commit is contained in:
parent
93c5c7af70
commit
27cfe498ab
2 changed files with 28 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
class EvenementVie < ActiveRecord::Base
|
||||
#TODO a tester
|
||||
has_many :formulaires
|
||||
|
||||
def self.for_admi_facile
|
||||
where(use_admi_facile: true)
|
||||
end
|
||||
|
|
26
spec/models/evenement_vie_spec.rb
Normal file
26
spec/models/evenement_vie_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe EvenementVie do
|
||||
describe 'database column' do
|
||||
it { is_expected.to have_db_column(:nom) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
it { is_expected.to have_db_column(:use_admi_facile) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_many(:formulaires) }
|
||||
end
|
||||
|
||||
describe '.for_admi_facile' do
|
||||
let(:evenement_for_admi_facile) { EvenementVie.where(use_admi_facile: true).first }
|
||||
let(:evenement_not_for_admi_facile) { EvenementVie.where(use_admi_facile: false).first }
|
||||
subject { EvenementVie.for_admi_facile }
|
||||
it 'returns elements where use_admi_facile is true' do
|
||||
expect(subject).to include(evenement_for_admi_facile)
|
||||
end
|
||||
it 'does not return elements where use_admi_facile is false' do
|
||||
expect(subject).not_to include(evenement_not_for_admi_facile)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue