Sha256: 44a7f3cb7e1d9578569b9f13a378de60c18f68bb58f02b95b3e7d15d62363759

Contents?: true

Size: 1.07 KB

Versions: 23

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Locomotive::Concerns::ContentEntry::FileSize do

  let(:content_type)  { create_content_type }
  let(:content_entry) { build_content_entry }

  subject { content_entry._file_size }

  context 'entry not persisted' do

    it { expect(subject).to eq 0 }

  end

  context 'entry persisted' do

    before { content_entry.save! }

    it { expect(subject).to eq 1309 }

  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.entries_custom_fields.build label: 'File 1', type: 'file'
      content_type.entries_custom_fields.build label: 'File 2', type: 'file'
      content_type.valid?
      content_type.send(:set_label_field)
      content_type.save!
    end
  end

  def build_content_entry
    content_type.entries.build(title: 'LocomotiveCMS', file_1: FixturedAsset.open('5k.png'), file_2: FixturedAsset.open('main.css'))
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

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