Sha256: 5258d18993005dea8306cebe9bea42f0c01ab9d50d57bf2aad5ce50d7e854ef7

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Silvermoon::ActionControllerExtension do

  before(:each) do
    ActionController::Base.send :include, subject
    @controller = ActionController::Base.new
  end

  it "adds notifiers to controller notifiers" do
    ActionController::Base.notifies :facebook, :twitter
    @controller.controller_notifiers.should == [:facebook, :twitter]
  end

  it "should notify with controller specified notifiers" do
    ActionController::Base.notifies :facebook

    with_config_file(STUB_CONFIG) do
      Silvermoon.should_receive(:notify).with('title', 'content', 'url', {}, [:facebook])
    end

    @controller.notify 'title', 'content', 'url'
  end

  it "should notify with all specified notifiers if no notifiers are defined" do
    with_config_file(STUB_CONFIG) do
      ActionController::Base.notifies nil

      Silvermoon.should_receive(:notify).with('title', 'content', 'url', {}, [])

      @controller.notify 'title', 'content', 'url'
    end
  end

  it "should override controller specified notifiers if passed on notify" do
    ActionController::Base.notifies :facebook

    with_config_file(STUB_CONFIG) do
      Silvermoon.should_receive(:notify).with('title', 'content', 'url', {}, :twitter)

      @controller.notify 'title', 'content', 'url', {}, :twitter
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
silvermoon-0.1 spec/silvermoon/action_controller_extension_spec.rb