Sha256: 23afb3cbeddb7f8afa05f02da3b409e4f252df32b72e13810963ed5c12f86451

Contents?: true

Size: 1.21 KB

Versions: 57

Compression:

Stored size: 1.21 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 belong_to :attachment_type }

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

  it { is_expected.to_not validate_presence_of :attachment_type }
  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

57 entries across 57 versions & 1 rubygems

Version Path
dorsale-4.0.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.20.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.19.1 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.19.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.18.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.17.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.16.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.15.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.11 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.10 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.9 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.8 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.7 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.6 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.5 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.3 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.2 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.1 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.14.0 spec/models/dorsale/alexandrie/attachment_spec.rb
dorsale-3.13.0 spec/models/dorsale/alexandrie/attachment_spec.rb