spec/upload_spec.rb in carrierwave-aliyun-0.4.4 vs spec/upload_spec.rb in carrierwave-aliyun-0.5.0

- old
+ new

@@ -7,14 +7,16 @@ describe "Upload" do def setup_db ActiveRecord::Schema.define(:version => 1) do create_table :photos do |t| t.column :image, :string + t.column :content_type, :string end create_table :attachments do |t| t.column :file, :string + t.column :content_type, :string end end end def drop_db @@ -75,18 +77,32 @@ end it "should get uploaded file" do img = open(@photo.image.url) expect(img.size).to eq @file.size + expect(img.content_type).to eq 'image/jpeg' img1 = open(@photo1.image.url) expect(img1.size).to eq @file1.size + expect(img1.content_type).to eq 'image/gif' end it "sholud get small version uploaded file" do expect(open(@photo.image.small.url)).not_to eq nil expect(open(@photo1.image.small.url)).not_to eq nil end + + it "should get Aliyun OSS thumb url with :thumb option" do + url = @photo.image.url(thumb: '@150w_140h.png') + expect(url).to include('.img-') + expect(url).to include('@150w_140h.png') + url1 = @photo.image.url(thumb: '@!150w_140h.jpg') + expect(url1).to include('.img-') + expect(url1).to include('@!150w_140h.jpg') + img1 = open(url) + expect(img1.size).not_to eq 0 + expect(img1.content_type).to eq 'image/png' + end end context "should update zip" do before(:all) do @file = load_file("foo.zip") @@ -98,9 +114,10 @@ end it "should get uploaded file" do attach = open(@attachment.file.url) expect(attach.size).to eq @file.size + expect(attach.content_type).to eq 'application/zip' end it "should delete old file when upload a new file again" do old_url = @attachment.file.url @attachment.file = load_file("foo.gif")