Sha256: 0076749171711b1318c6bb26c26296d7bf30df29e25d4ea8c0c51f29d8ce57c0

Contents?: true

Size: 1.1 KB

Versions: 44

Compression:

Stored size: 1.1 KB

Contents

require "rails_helper"

describe ::Dorsale::Alexandrie::Attachment, type: :model do
  it { is_expected.to belong_to :attachable }
  it { is_expected.to belong_to :sender }

  it { is_expected.to validate_presence_of :attachable }
  it { is_expected.to validate_presence_of :file }

  it { is_expected.to_not validate_presence_of :sender }

  it "factory should be valid" do
    expect(create(:alexandrie_attachment)).to be_valid
  end

  it "should assign default name" do
    attachment = create(:alexandrie_attachment, name: nil)
    expect(attachment.name).to eq "pdf.pdf"
  end

  it "download_filename should be valid" do
    attachment = create(:alexandrie_attachment)
    expect(attachment.download_filename).to eq "pdf.pdf"

    attachment = create(:alexandrie_attachment, name: "hello")
    expect(attachment.download_filename).to eq "hello.pdf"

    attachment = create(:alexandrie_attachment, name: "hello.pdf")
    expect(attachment.download_filename).to eq "hello.pdf"

    attachment = create(:alexandrie_attachment, name: "hello.xls")
    expect(attachment.download_filename).to eq "hello-xls.pdf"
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
dorsale-3.1.3 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.1.2 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.1.1 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.1.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.0.3 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.0.2 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.0.1 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.0.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.7.3 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.7.2 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.7.1 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.7.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.6.8 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.6.7 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.6.6 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.6.5 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.6.4 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.6.3 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.6.2 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-2.6.1 spec/models/dorsale/alexandrie/attachment_spec.rb