Sha256: 16b47e70a959d271413975d9191148273d13bd3ad697a826857e31e6e310c442

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

require "rails_helper"

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

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

      it { is_expected.to allow_value("success.js").for(:file_name) }
      it { is_expected.to allow_value("success.jpg").for(:file_name) }
      it { is_expected.to allow_value("filename.extension").for(:file_name) }

      it { is_expected.to_not allow_value("error.c").for(:file_name) }
      it { is_expected.to_not allow_value("without-extension").for(:file_name) }
      it { is_expected.to_not allow_value("with.dot.jpg").for(:file_name) }
      it { is_expected.to_not allow_value("with space.jpg").for(:file_name) }
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.0.6 spec/models/archangel/asset_spec.rb