From f31a79c5bc3678949b7334486daa196a17a5db92 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Tue, 19 Dec 2017 19:42:52 +0100 Subject: Create Organisation#features and FeatureChecker controller concerns. Refs #5339 --- spec/models/organisation_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'spec/models/organisation_spec.rb') diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 359417d88..0d54ed143 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -62,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 true if Organisation features doesn't contains given feature" do + organisation.features = %w{other} + expect(organisation.has_feature?(:absent)).to be_falsy + end + + end + end -- cgit v1.2.3 From 5404543c7438a0f574af49950af52ac27454126d Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Wed, 20 Dec 2017 17:21:38 +0100 Subject: Fixes Organisation#has_feature? spec title. Refs #5339 --- spec/models/organisation_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/models/organisation_spec.rb') diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 0d54ed143..595b08058 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -77,7 +77,7 @@ describe Organisation, :type => :model do expect(organisation.has_feature?(:present)).to be_truthy end - it "return true if Organisation features doesn't contains given feature" do + 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 -- cgit v1.2.3