Sha256: 4e210f57d7801c6aaa3df98e5d3364d4298febe9f97ea73eb0ff0749be98a9bd

Contents?: true

Size: 1.22 KB

Versions: 27

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

module Locomotive
  module Concerns
    module ContentEntry

      describe Counter do

        let(:content_type) { create_content_type }

        subject { content_type.reload }

        describe 'by default' do

          it { expect(subject.number_of_entries).to be_nil }

        end

        describe 'adding entries' do

          before { 2.times { create_content_entry } }

          it { expect(subject.number_of_entries).to eq(2) }

          describe 'then removing a single entry' do

            before { subject.entries.last.destroy; content_type.reload }

            it { expect(subject.number_of_entries).to eq(1) }

          end

        end

        def create_content_type
          allow_any_instance_of(Locomotive::Site).to receive(:create_default_pages!).and_return(true)
          FactoryGirl.build(:content_type).tap do |content_type|
            content_type.entries_custom_fields.build label: 'Title', type: 'string'
            content_type.valid?
            content_type.send(:set_label_field)
            content_type.save!
          end
        end

        def create_content_entry
          content_type.entries.create!(title: 'LocomotiveCMS')
        end

      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
locomotivecms-3.3.0 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.3.0.rc3 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.3.0.rc2 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.1.2 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.2.1 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.3.0.rc1 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.2.0 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.2.0.rc2 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.2.0.rc1 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.1.1 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.1.0 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.1.0.rc3 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.1.0.rc2 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.1.0.rc1 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.0.1 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.0.0 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.0.0.rc7 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.0.0.rc6 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.0.0.rc5 spec/models/locomotive/concerns/content_entry/counter_spec.rb
locomotivecms-3.0.0.rc4 spec/models/locomotive/concerns/content_entry/counter_spec.rb