require 'spec_helper'

describe UserAsset do
    let (:user) {FactoryGirl.create(:user) }
    let (:user_asset){ FactoryGirl.create(:user_asset, asset_type: "image", filename: "my_image.jpg") }

    it "is invalid without filename" do
        expect(user_asset.valid?).to be(true)
        user_asset.filename = ""
        expect(user_asset.valid?).to be(false)
    end

    it "is invalid without asset_type" do
        expect(user_asset.valid?).to be(true)
        user_asset.asset_type = ""
        expect(user_asset.valid?).to be(false)
    end

    it "is invalid without uri" do
        expect(user_asset.valid?).to be(true)
        user_asset.uri = ""
        expect(user_asset.valid?).to be(false)
    end

    it "sets uri in this format", focus: true do
        expect(user_asset.uri).to match(/\/user_assets\/image\/\d{4}-\d{2}-\d{2}\/my_image-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}.jpg/)
    end
end