Sha256: 3a758384e65d68fd1ba8d8e8fab024f00c821a19c1040432af47521aab63450f

Contents?: true

Size: 1.78 KB

Versions: 28

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe FbGraph::PromotablePost do
  let(:published) { FbGraph::PromotablePost.new(12345, :is_published => true) }
  let(:draft)     { FbGraph::PromotablePost.new(12345, :is_published => false) }
  let(:scheduled) { FbGraph::PromotablePost.new(12345, :is_published => false, :scheduled_publish_time => 2.days.from_now.to_i) }

  context 'when published' do
    subject { published }
    its(:publishable?) { should be_false }
    its(:scheduled?) { should be_false }
  end

  context 'when draft' do
    subject { draft }
    its(:publishable?) { should be_true }
    its(:scheduled?) { should be_false }
  end

  context 'when scheduled' do
    subject { scheduled }
    its(:publishable?) { should be_true }
    its(:scheduled?) { should be_true }
  end

  describe '.publish!' do
    it 'should post with is_published=true' do
      mock_graph :post, '12345', 'true', :access_token => 'page_token', :params => {
        :is_published => 'true'
      } do
        draft.publish!(:access_token => 'page_token').should be_true
      end
    end
  end

  describe '.schedule!' do
    it 'should post with scheduled_publish_time=timestamp' do
      scheduled_at = 2.days.from_now
      mock_graph :post, '12345', 'true', :access_token => 'page_token', :params => {
        :scheduled_publish_time => scheduled_at.to_i.to_s
      } do
        draft.schedule!(scheduled_at, :access_token => 'page_token').should be_true
      end
    end
  end

  describe '.unschedule!' do
    it 'should post with scheduled_publish_time=0' do
      scheduled_at = 2.days.from_now
      mock_graph :post, '12345', 'true', :access_token => 'page_token', :params => {
        :scheduled_publish_time => '0'
      } do
        scheduled.unschedule!(:access_token => 'page_token').should be_true
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
fb_graph-2.7.17 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.16 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.15 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.14 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.13 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.12 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.11 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.10 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.9 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.8 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.7 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.6 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.5 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.4 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.3 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.2 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.1 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.7.0 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.6.7 spec/fb_graph/promotable_post_spec.rb
fb_graph-2.6.6 spec/fb_graph/promotable_post_spec.rb