Update enterprise email tests

This commit is contained in:
Maikel Linke
2016-02-24 16:21:18 +11:00
parent 4feb7c893b
commit a7e3b2d9df
3 changed files with 11 additions and 6 deletions

View File

@@ -397,7 +397,7 @@ class Enterprise < ActiveRecord::Base
end
def ensure_email_set
self.email = owner.email if email.blank?
self.email = owner.email if email.blank? && owner.present?
end
def enforce_ownership_limit

View File

@@ -47,7 +47,7 @@ feature %q{
fill_in 'enterprise_contact', :with => 'Kirsten or Ren'
fill_in 'enterprise_phone', :with => '0413 897 321'
fill_in 'enterprise_email', :with => 'info@eaterprises.com.au'
fill_in 'enterprise_email_address', :with => 'info@eaterprises.com.au'
fill_in 'enterprise_website', :with => 'http://eaterprises.com.au'
fill_in 'enterprise_address_attributes_address1', :with => '35 Ballantyne St'
@@ -130,7 +130,7 @@ feature %q{
click_link "Contact"
fill_in 'enterprise_contact', :with => 'Kirsten or Ren'
fill_in 'enterprise_phone', :with => '0413 897 321'
fill_in 'enterprise_email', :with => 'info@eaterprises.com.au'
fill_in 'enterprise_email_address', :with => 'info@eaterprises.com.au'
fill_in 'enterprise_website', :with => 'http://eaterprises.com.au'
click_link "Social"
@@ -286,7 +286,7 @@ feature %q{
click_link 'Enterprises'
click_link 'New Enterprise'
fill_in 'enterprise_name', with: 'zzz'
fill_in 'enterprise_email', with: 'bob@example.com'
fill_in 'enterprise_email_address', with: 'bob@example.com'
fill_in 'enterprise_address_attributes_address1', with: 'z'
fill_in 'enterprise_address_attributes_city', with: 'z'
fill_in 'enterprise_address_attributes_zipcode', with: 'z'

View File

@@ -180,7 +180,6 @@ describe Enterprise do
describe "validations" do
subject { FactoryGirl.create(:distributor_enterprise) }
it { should validate_presence_of(:name) }
it { should validate_presence_of(:email) }
it { should validate_uniqueness_of(:permalink) }
it { should ensure_length_of(:description).is_at_most(255) }
@@ -210,9 +209,15 @@ describe Enterprise do
end
it "does not prohibit the saving of an enterprise with no name clash" do
enterprise.email = 'new@email.com'
enterprise.should be_valid
end
it "takes the owner's email address as default email" do
enterprise.email = nil
enterprise.should be_valid
enterprise.email.should be_present
enterprise.email.should eq owner.email
end
end
describe "preferred_shopfront_taxon_order" do