aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/chouette/company_spec.rb
diff options
context:
space:
mode:
authorXinhui2016-02-22 14:17:18 +0100
committerXinhui2016-02-22 14:17:18 +0100
commitd49f47b4ac1db2cd88b96d830772bb7773924601 (patch)
tree191c7b9cda9edf939792e7780df4e7460d685a4a /spec/models/chouette/company_spec.rb
parent633004afc5861a6e8158948ddfecd73bf4dd86a8 (diff)
downloadchouette-core-d49f47b4ac1db2cd88b96d830772bb7773924601.tar.bz2
Merge model from ninoxe gem
Diffstat (limited to 'spec/models/chouette/company_spec.rb')
-rw-r--r--spec/models/chouette/company_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/models/chouette/company_spec.rb b/spec/models/chouette/company_spec.rb
new file mode 100644
index 000000000..3da8b4311
--- /dev/null
+++ b/spec/models/chouette/company_spec.rb
@@ -0,0 +1,48 @@
+require 'spec_helper'
+
+describe Chouette::Company, :type => :model do
+
+ subject { create(:company) }
+
+ it { is_expected.to validate_presence_of :name }
+
+ # it { should validate_presence_of :objectid }
+ it { is_expected.to validate_uniqueness_of :objectid }
+
+ describe "#nullables empty" do
+ it "should set null empty nullable attributes" do
+ subject.organizational_unit = ''
+ subject.operating_department_name = ''
+ subject.code = ''
+ subject.phone = ''
+ subject.fax = ''
+ subject.email = ''
+ subject.nil_if_blank
+ expect(subject.organizational_unit).to be_nil
+ expect(subject.operating_department_name).to be_nil
+ expect(subject.code).to be_nil
+ expect(subject.phone).to be_nil
+ expect(subject.fax).to be_nil
+ expect(subject.email).to be_nil
+ end
+ end
+
+ describe "#nullables non empty" do
+ it "should not set null non epmty nullable attributes" do
+ subject.organizational_unit = 'a'
+ subject.operating_department_name = 'b'
+ subject.code = 'c'
+ subject.phone = 'd'
+ subject.fax = 'z'
+ subject.email = 'r'
+ subject.nil_if_blank
+ expect(subject.organizational_unit).not_to be_nil
+ expect(subject.operating_department_name).not_to be_nil
+ expect(subject.code).not_to be_nil
+ expect(subject.phone).not_to be_nil
+ expect(subject.fax).not_to be_nil
+ expect(subject.email).not_to be_nil
+ end
+ end
+
+end