Sha256: 88e90cc0c8e58965c5a2cd17a54faf305a9357d9dea8557c87c9ec13fb80f6a4

Contents?: true

Size: 1.09 KB

Versions: 24

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

require 'delayed_job_spec_helper'

describe DispatchesController do
  include DelayedJobSpecHelper
  fixtures :all

  it "should record an open" do
    @dispatch = dispatches(:unsent)
    send_dispatch(@dispatch)
    lambda {
      get :read, :id => @dispatch.id, :email => Subscriber.first.email
      response.should be_success, response.body
    }.should change(DispatchOpen, :count).by(1)
  end

  it "should record an unsubscribe" do
    @dispatch = dispatches(:unsent)
    send_dispatch(@dispatch)
    lambda {
      get :unsubscribe, :id => @dispatch.id, :s_id => Subscriber.first.id, :email => Subscriber.first.email
      response.should be_redirect
    }.should change(DispatchUnsubscribe, :count).by(1)
  end

  it "should fail an unsubscribe if the subscriber email and id don't match" do
    @dispatch = dispatches(:unsent)
    send_dispatch(@dispatch)
    lambda { get :unsubscribe, :id => @dispatch.id, :s_id => Subscriber.first.id + 340, :email => Subscriber.first.email }.should raise_error
  end
end

def send_dispatch(dispatch)
  dispatch.deliver!
  work_off
  work_off
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.9 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.8 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.7 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.6 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.5 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.4 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.3 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.2 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.1 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.1.0 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.18 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.17 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.16 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.15 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.14 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.13 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.12 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.11 lib/forge/spec/controllers/dispatches_controller_spec.rb
forge-cli-0.0.10 lib/forge/spec/controllers/dispatches_controller_spec.rb