diff options
| author | Luc Donnet | 2018-01-03 11:57:42 +0100 |
|---|---|---|
| committer | Luc Donnet | 2018-01-03 11:57:42 +0100 |
| commit | 7cce4762c11e7d1e78433f6f88d2e12928c398dc (patch) | |
| tree | 3084d95692a70f9c5d5a842aae6f4ec0ea07a1c3 /spec/models/organisation_spec.rb | |
| parent | 6497b23e18385121974f6cbf56d48caf897e69b1 (diff) | |
| parent | 414d0f6c4dd992696354757c4ae700952a7e4dd9 (diff) | |
| download | chouette-core-7cce4762c11e7d1e78433f6f88d2e12928c398dc.tar.bz2 | |
Merge branch 'master' into 5024-prevent-duplicate-referentials-from-being-created-during-parallel-db-transactions--rb201711271659
Diffstat (limited to 'spec/models/organisation_spec.rb')
| -rw-r--r-- | spec/models/organisation_spec.rb | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 1217666f7..595b08058 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -2,8 +2,19 @@ describe Organisation, :type => :model do it { should validate_presence_of(:name) } it { should validate_uniqueness_of(:code) } - it 'should have a valid factory' do - expect(FactoryGirl.build(:organisation)).to be_valid + subject { build_stubbed :organisation } + + it 'has a valid factory' do + expect_it.to be_valid + end + + context 'lines_set' do + it 'has no lines' do + expect( subject.lines_set ).to eq(Set.new()) + end + it 'has two lines' do + expect( build_stubbed(:org_with_lines).lines_set ).to eq(Set.new(%w{C00109 C00108})) + end end # it "create a rule_parameter_set" do @@ -51,4 +62,26 @@ describe Organisation, :type => :model do expect{Organisation.portail_sync}.to change{ Organisation.count }.by(4) end end + + describe "#has_feature?" do + + let(:organisation) { Organisation.new } + + it 'return false if Organisation features is nil' do + organisation.features = nil + expect(organisation.has_feature?(:dummy)).to be_falsy + end + + it 'return true if Organisation features contains given feature' do + organisation.features = %w{present} + expect(organisation.has_feature?(:present)).to be_truthy + end + + it "return false if Organisation features doesn't contains given feature" do + organisation.features = %w{other} + expect(organisation.has_feature?(:absent)).to be_falsy + end + + end + end |
