Sha256: 173eb9b798ce7d22a3cc19f01f036dcfb73e9b3ec44da6a16ffc8f4b3a7421bb
Contents?: true
Size: 1.42 KB
Versions: 16
Compression:
Stored size: 1.42 KB
Contents
require 'spec_helper' describe Landable::Asset do def asset_fixture(name) File.expand_path("../../../fixtures/assets/#{name}", __FILE__) end let(:png) { File.open(asset_fixture('panda.png')) } let(:pdf) { File.open(asset_fixture('small.pdf')) } after do png.close pdf.close end it { should_not have_valid(:name).when(nil, '', 'No Spaces') } it { should_not have_valid(:author).when(nil) } it { should_not have_valid(:md5sum).when(nil, '') } it { should_not have_valid(:mime_type).when(nil, '') } it { should_not have_valid(:file_size).when(nil, 1.5) } it "stores an md5sum of its contents" do asset = build(:asset, data: png) expect { asset.valid? }.to change { asset.md5sum }.from(nil).to('0f62ef551dbebcdb7379401528b6115c') end it "requires the md5sum to be unique" do orig = create(:asset, data: png) dupe = build(:asset, data: png) expect(dupe).not_to be_valid expect(dupe.errors_on(:md5sum)).to eql(['has already been taken']) end it "provides access to the other asset with the same contents" do orig = create(:asset, data: png) dupe = build(:asset, data: png) expect(dupe.duplicate_of).to eql(orig) end it "returns a list of pages using the asset" do page = create(:page, body: "panda.png", path: "/testing/assets") asset = create(:asset, data:pdf, name: "panda.png") asset.associated_pages.should eq(["/testing/assets"]) end end
Version data entries
16 entries across 16 versions & 1 rubygems