Sha256: 2c9111faf7f6d4551288b94f8ab0f0a39dd2666a724a59ef9f6cab798bcdc2db

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/ar_spec_helper')
  
describe "Mailee" do

  before(:each) do
    Mailee::Config.site = "http://api.bdb28c0a0a4a3.softa.server:3000"
    @moment = Time.now.strftime('%Y%m%d%H%M%S')
  end
  
  it "should create if news is checked" do
    foo = Foo.create :name => "rest_test_foo_#{@moment}", :email => "rest_test_foo_#{@moment}@test.com", :news => true
    found = Mailee::Contact.find_by_email("rest_test_foo_#{@moment}@test.com")
    found.internal_id.to_i.should be foo.id
    # ==
    bar = Bar.create :other_name => "rest_test_bar_#{@moment}", :other_email => "rest_test_bar_#{@moment}@test.com", :other_news => true
    found = Mailee::Contact.find_by_email("rest_test_bar_#{@moment}@test.com")
    found.internal_id.to_i.should be bar.id
  end

  it "should not create if news is not checked" do
    foo = Foo.create :name => "rest_test_foo_#{@moment}", :email => "rest_test_foo_#{@moment}@test.com", :news => false
    found = Mailee::Contact.find_by_email("rest_test_foo_#{@moment}@test.com")
    found.should be nil
    # ==
    bar = Bar.create :other_name => "rest_test_bar_#{@moment}", :other_email => "rest_test_bar_#{@moment}@test.com", :other_news => false
    found = Mailee::Contact.find_by_email("rest_test_bar_#{@moment}@test.com")
    found.should be nil
  end

  it "should create if news is updated" do
    foo = Foo.create :name => "rest_test_foo_#{@moment}", :email => "rest_test_foo_#{@moment}@test.com", :news => false
    foo.update_attribute :news, true
    found = Mailee::Contact.find_by_email("rest_test_foo_#{@moment}@test.com")
    found.internal_id.to_i.should be foo.id
    # ==
    bar = Bar.create :other_name => "rest_test_bar_#{@moment}", :other_email => "rest_test_bar_#{@moment}@test.com", :other_news => false
    bar.update_attribute :other_news, true
    found = Mailee::Contact.find_by_email("rest_test_bar_#{@moment}@test.com")
    found.internal_id.to_i.should be bar.id
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mailee-0.3.0 spec/mailee-api-ar.rb
mailee-0.2.1 spec/mailee-api-ar.rb