Sha256: 7343cbce8b8ada481818da4d9b5327bdf0e04349bd09b0e6446ad159cb27de60

Contents?: true

Size: 862 Bytes

Versions: 4

Compression:

Stored size: 862 Bytes

Contents

# frozen_string_literal: true

require "rails_helper"

module Archangel
  RSpec.describe Asset, type: :model do
    context "callbacks" do
      it { expect(subject).to callback(:save_asset_attributes).before(:save) }
    end

    context "validations" do
      it { expect(subject).to validate_presence_of(:file) }
      it { expect(subject).to validate_presence_of(:file_name) }

      it { expect(subject).to allow_value("success.jpg").for(:file_name) }

      it do
        expect(subject).not_to allow_value("without-extension").for(:file_name)
      end
      it do
        expect(subject).not_to allow_value("with.dot.jpg").for(:file_name)
      end
      it do
        expect(subject).not_to allow_value("with space.jpg").for(:file_name)
      end
    end

    context "associations" do
      it { expect(subject).to belong_to(:site) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
archangel-0.0.5 spec/models/archangel/asset_spec.rb
archangel-0.0.4 spec/models/archangel/asset_spec.rb
archangel-0.0.3 spec/models/archangel/asset_spec.rb
archangel-0.0.2 spec/models/archangel/asset_spec.rb