Sha256: b4afdb45390d61583b02d8d065ca2def49d314406c2501c2194d50cf66d96c8c

Contents?: true

Size: 1.95 KB

Versions: 4

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

module AlchemyCrm
  describe Newsletter do

    before(:each) do
      @newsletter = Newsletter.create!(:name => 'Newsletter', :layout => 'standard')
      @verified_contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true})
      @subscription = Subscription.create!(:contact => @verified_contact, :newsletter => @newsletter, :verified => true, :wants => true)
      @contact = Contact.create!(:email => 'jon_2@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr')
      @father = Contact.create!({:email => 'father@family.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :tag_list => 'father', :verified => true})
      @mother = Contact.create!({:email => 'mother@family.com', :firstname => 'Jane', :lastname => 'Doe', :salutation => 'ms', :tag_list => 'mother', :verified => true})
      @son = Contact.create!(:email => 'son@family.com', :firstname => 'Jim', :lastname => 'Doe', :salutation => 'mr', :tag_list => 'son')

      @subscription_2 = Subscription.create!(:contact => @contact, :newsletter => @newsletter)

      @contact_group = @newsletter.contact_groups.create!(:name => 'Family', :contact_tag_list => 'father, mother, son')
    end

    describe "Contacts" do

      it "should have collection for all verified subscribers" do
        @newsletter.verified_subscribers.should == [@verified_contact]
      end

      it "should have collection for all verified contact group contacts" do
        @newsletter.verified_contact_group_contacts.should == [@father, @mother]
      end

      it "should have collection for all verified contacts" do
        @newsletter.contacts.should == [@father, @mother, @verified_contact]
      end

    end

    describe "#humanized_name" do

      it "should return a string composed of name and contacts count" do
        @newsletter.humanized_name.should == "Newsletter (3)"
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alchemy_crm-2.0.5 spec/models/alchemy_crm/newsletter_spec.rb
alchemy_crm-2.0.4.1 spec/models/alchemy_crm/newsletter_spec.rb
alchemy_crm-2.1.0a spec/models/alchemy_crm/newsletter_spec.rb
alchemy_crm-2.0.3 spec/models/alchemy_crm/newsletter_spec.rb