Sha256: 4609d0291f7f88c7ec8272f2125f508655472d8eae7f98722d7b314ff9b04a31

Contents?: true

Size: 1.71 KB

Versions: 9

Compression:

Stored size: 1.71 KB

Contents

require "test_helper"

module PushType
  class UnexposableTest < ActiveSupport::TestCase

    describe '.exposed' do
      let(:new_node!) { TestPage.create! FactoryGirl.attributes_for(:node) }
      it 'should scope all exposed nodes' do
        PushType.stub :unexposed_nodes, [] do
          proc { new_node! }.must_change 'PushType::Node.exposed.count', 1
        end
      end
      it 'should omit any unexposed nodes' do
        PushType.stub :unexposed_nodes, ['test_page'] do
          proc { new_node! }.wont_change 'PushType::Node.exposed.count', 1 
        end
      end
    end

    describe 'exposed?' do
      it 'should be true when not unexposed' do
        PushType.stub :unexposed_nodes, [] do
          TestPage.must_be :exposed?
          TestPage.new.must_be :exposed?
        end
      end
      it 'should be false when unexposed' do
        PushType.stub :unexposed_nodes, ['test_page'] do
          TestPage.wont_be :exposed?
          TestPage.new.wont_be :exposed?
        end
      end
    end

    describe '.descendants' do
      it 'should include subject when not unexposed' do
        PushType.stub :unexposed_nodes, [] do
          PushType::Node.descendants.must_include TestPage
          PushType::Node.descendants(exposed: true).must_include TestPage
          PushType::Node.descendants(exposed: false).wont_include TestPage
        end
      end
      it 'should not include subject when not unexposed' do
        PushType.stub :unexposed_nodes, ['test_page'] do
          PushType::Node.descendants.must_include TestPage
          PushType::Node.descendants(exposed: true).wont_include TestPage
          PushType::Node.descendants(exposed: false).must_include TestPage
        end
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
push_type_core-0.5.1 test/models/concerns/push_type/unexposable_test.rb
push_type_core-0.5.0 test/models/concerns/push_type/unexposable_test.rb
push_type_core-0.5.0.alpha.5 test/models/concerns/push_type/unexposable_test.rb
push_type_core-0.5.0.alpha.4 test/models/concerns/push_type/unexposable_test.rb
push_type_core-0.5.0.alpha.3 test/models/concerns/push_type/unexposable_test.rb
push_type_core-0.5.0.alpha.2 test/models/concerns/push_type/unexposable_test.rb
push_type_core-0.5.0.alpha.1 test/models/concerns/push_type/unexposable_test.rb
push_type_core-0.4.0 test/models/concerns/push_type/unexposable_test.rb
push_type_core-0.4.0.beta.3 test/models/concerns/push_type/unexposable_test.rb