Sha256: e45b5f559a8af3f8a669de8835467e5f8c455b17ad3a32a963394c690194b6a8

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

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 allow_value("foo-bar.jpg").for(:file_name) }
      it { is_expected.to allow_value("foo_bar.jpg").for(:file_name) }
      it { is_expected.to allow_value("18.jpg").for(:file_name) }

      it { is_expected.to_not allow_value("error").for(:file_name) }
      it { is_expected.to_not allow_value("error.j").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) }
      it { is_expected.to_not allow_value("with/slash.jpg").for(:file_name) }
      it { is_expected.to_not allow_value("with/numbers.18").for(:file_name) }
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
archangel-0.3.0 spec/models/archangel/asset_spec.rb
archangel-0.0.8 spec/models/archangel/asset_spec.rb
archangel-0.0.7 spec/models/archangel/asset_spec.rb