spec/feature/crud_workflows_spec.rb in saviour-0.5.6 vs spec/feature/crud_workflows_spec.rb in saviour-0.5.7

- old
+ new

@@ -1,8 +1,8 @@ require 'spec_helper' -describe "saving a new file" do +describe "CRUD" do before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) } let(:uploader) { Class.new(Saviour::BaseUploader) { store_dir { "/store/dir" } @@ -229,8 +229,26 @@ b = a.dup b.save! expect(Saviour::Config.storage.exists?(b[:file])).to be_truthy expect(Saviour::Config.storage.read(a[:file])).to eq Saviour::Config.storage.read(b[:file]) + end + end + + describe "presence" do + it "false when no assigned file" do + a = klass.create! + expect(a.file?).to be_falsey + end + + it "true when no persisted but assigned" do + a = klass.create! + a.file = Saviour::StringSource.new("contents", "file.txt") + expect(a.file?).to be_truthy + end + + it "true when persisted and assigned" do + a = klass.create! file: Saviour::StringSource.new("contents", "file.txt") + expect(a.file?).to be_truthy end end end