carrierwaveuploader / carrierwave

Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
https://github.com/carrierwaveuploader/carrierwave
8.78k stars 1.66k forks source link

require rails ~>4.0 (and not >= 4.0.0) since tests are broken in rails 5 #1991

Closed philister closed 8 years ago

philister commented 8 years ago

I just wonder if the tests in master are supposed to work with rails 5? I get 1533 examples, 15 failures, 1 pending with a fresh cloned repo; I'm a little bit confused, please confirm.

Thanks and regards,

    DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from <top (required)> at /media/philipp/ssd128/github/carrierwaveuploader/carrierwave/spec/support/activerecord.rb:30)
.......................................................................................................................................................................................................FF...FFF.............................................*.........F..F.FFFF...FFF..............................................F.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................WARNING: Using the `raise_error` matcher without providing a specific error or message risks false positives, since `raise_error` will match when Ruby raises a `NoMethodError`, `NameError` or `ArgumentError`, potentially allowing the expectation to pass without even executing the method you are intending to call. Actual error raised was #<CarrierWave::IntegrityError: You are not allowed to upload "txt" files, allowed types: (?-mix:jpe?g)>. Instead consider providing a specific error class or message. This message can be supressed by setting: `RSpec::Expectations.configuration.warn_about_potential_false_positives = false`. Called from /media/philipp/ssd128/github/carrierwaveuploader/carrierwave/spec/uploader/extension_whitelist_spec.rb:97:in `block (5 levels) in <top (required)>'.
..................................................................................................................................................................................

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) CarrierWave::ActiveRecord#mount_uploader removing old files normally should be truthy
     # No reason given
     Failure/Error:
       it "should only delete the file once when the file is removed" do
         @event.remove_image = true
         expect_any_instance_of(CarrierWave::SanitizedFile).to receive(:delete).exactly(1).times
         expect(@event.save).to be_truthy
       end

       `it` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).
     # ./spec/orm/activerecord_spec.rb:685:in `block (4 levels) in <top (required)>'

Failures:

  1) CarrierWave::ActiveRecord#mount_uploader #image should return valid XML when to_xml is called when image is nil
     Failure/Error: hash = Hash.from_xml(@event.to_xml)["event"]

     NoMethodError:
       undefined method `to_xml' for #<Event:0x007f2c36d488c0>
       Did you mean?  to_yaml
     # ./spec/orm/activerecord_spec.rb:94:in `block (4 levels) in <top (required)>'

  2) CarrierWave::ActiveRecord#mount_uploader #image should return valid XML when to_xml is called when image is present
     Failure/Error: expect(Hash.from_xml(@event.to_xml)["event"]["image"]).to eq({"url" => "/uploads/test.jpeg"})

     NoMethodError:
       undefined method `to_xml' for #<Event:0x007f2c36aa2d00>
       Did you mean?  to_yaml
     # ./spec/orm/activerecord_spec.rb:107:in `block (4 levels) in <top (required)>'

  3) CarrierWave::ActiveRecord#mount_uploader #image should respect options[:only] when passed to to_xml for the serializable hash
     Failure/Error: expect(Hash.from_xml(@event.to_xml(only: [:foo]))["event"]["image"]).to be_nil

     NoMethodError:
       undefined method `to_xml' for #<Event:0x007f2c361dc518>
       Did you mean?  to_yaml
     # ./spec/orm/activerecord_spec.rb:138:in `block (4 levels) in <top (required)>'

  4) CarrierWave::ActiveRecord#mount_uploader #image should respect options[:except] when passed to to_xml for the serializable hash
     Failure/Error: expect(Hash.from_xml(@event.to_xml(except: [:image]))["event"]["image"]).to be_nil

     NoMethodError:
       undefined method `to_xml' for #<Event:0x007f2c35f8f530>
       Did you mean?  to_yaml
     # ./spec/orm/activerecord_spec.rb:146:in `block (4 levels) in <top (required)>'

  5) CarrierWave::ActiveRecord#mount_uploader #image should respect both options[:only] and options[:except] when passed to to_xml for the serializable hash
     Failure/Error: expect(Hash.from_xml(@event.to_xml(only: [:foo], except: [:id]))["event"]["image"]).to be_nil

     NoMethodError:
       undefined method `to_xml' for #<Event:0x007f2c35ad6c28>
       Did you mean?  to_yaml
     # ./spec/orm/activerecord_spec.rb:154:in `block (4 levels) in <top (required)>'

  6) CarrierWave::ActiveRecord#mount_uploader removing old files with with mount_on should not remove file if old file had the same path
     Failure/Error: expect(File.exist?(public_path('uploads/old.jpeg'))).to be_truthy

       expected: truthy value
            got: false
     # ./spec/orm/activerecord_spec.rb:842:in `block (3 levels) in <top (required)>'

  7) CarrierWave::ActiveRecord#mount_uploaders #images should set the path to the store dir
     Failure/Error: expect(@event.images[0].current_path).to eq public_path('uploads/test.jpeg')

       expected: "/media/philipp/ssd128/github/carrierwaveuploader/carrierwave/spec/public/uploads/test.jpeg"
            got: "/media/philipp/ssd128/github/carrierwaveuploader/carrierwave/spec/public/uploads/[\"test.jpeg\"]"

       (compared using ==)
     # ./spec/orm/activerecord_spec.rb:868:in `block (4 levels) in <top (required)>'

  8) CarrierWave::ActiveRecord#mount_uploaders #images should return valid JSON when to_json is called when images is present
     Failure/Error: expect(JSON.parse(@event.to_json)["images"]).to eq([{"url" => "/uploads/test.jpeg"}, {"url" => "/uploads/old.jpeg"}])

       expected: [{"url"=>"/uploads/test.jpeg"}, {"url"=>"/uploads/old.jpeg"}]
            got: [{"url"=>"/uploads/%5B%22test.jpeg%22%2C%22old.jpeg%22%5D"}]

       (compared using ==)

       Diff:
       @@ -1,2 +1,2 @@
       -[{"url"=>"/uploads/test.jpeg"}, {"url"=>"/uploads/old.jpeg"}]
       +[{"url"=>"/uploads/%5B%22test.jpeg%22%2C%22old.jpeg%22%5D"}]
     # ./spec/orm/activerecord_spec.rb:883:in `block (4 levels) in <top (required)>'

  9) CarrierWave::ActiveRecord#mount_uploaders #images should return valid JSON when to_json is called on a collection containing uploader from a model
     Failure/Error: expect(JSON.parse({:data => @event.images}.to_json)).to eq({"data"=>[{"url"=>"/uploads/test.jpeg"}]})

       expected: {"data"=>[{"url"=>"/uploads/test.jpeg"}]}
            got: {"data"=>[{"url"=>"/uploads/%5B%22test.jpeg%22%5D"}]}

       (compared using ==)

       Diff:
       @@ -1,2 +1,2 @@
       -"data" => [{"url"=>"/uploads/test.jpeg"}],
       +"data" => [{"url"=>"/uploads/%5B%22test.jpeg%22%5D"}],
     # ./spec/orm/activerecord_spec.rb:891:in `block (4 levels) in <top (required)>'

  10) CarrierWave::ActiveRecord#mount_uploaders #images should return valid XML when to_xml is called when images is nil
      Failure/Error: hash = Hash.from_xml(@event.to_xml)["event"]

      NoMethodError:
        undefined method `to_xml' for #<Event:0x007f2c3a080d50>
        Did you mean?  to_yaml
      # ./spec/orm/activerecord_spec.rb:895:in `block (4 levels) in <top (required)>'

  11) CarrierWave::ActiveRecord#mount_uploaders #images should return valid XML when to_xml is called when images is present
      Failure/Error: expect(Hash.from_xml(@event.to_xml)["event"]["images"]).to eq([{"url" => "/uploads/test.jpeg"}])

      NoMethodError:
        undefined method `to_xml' for #<Event:0x007f2c39f96340>
        Did you mean?  to_yaml
      # ./spec/orm/activerecord_spec.rb:907:in `block (4 levels) in <top (required)>'

  12) CarrierWave::ActiveRecord#mount_uploaders #images should respect options[:only] when passed to to_xml for the serializable hash
      Failure/Error: expect(Hash.from_xml(@event.to_xml(only: [:foo]))["event"]["images"]).to be_nil

      NoMethodError:
        undefined method `to_xml' for #<Event:0x007f2c39c05af0>
        Did you mean?  to_yaml
      # ./spec/orm/activerecord_spec.rb:938:in `block (4 levels) in <top (required)>'

  13) CarrierWave::ActiveRecord#mount_uploaders #images should respect options[:except] when passed to to_xml for the serializable hash
      Failure/Error: expect(Hash.from_xml(@event.to_xml(except: [:images]))["event"]["images"]).to be_nil

      NoMethodError:
        undefined method `to_xml' for #<Event:0x007f2c39b362c8>
        Did you mean?  to_yaml
      # ./spec/orm/activerecord_spec.rb:946:in `block (4 levels) in <top (required)>'

  14) CarrierWave::ActiveRecord#mount_uploaders #images should respect both options[:only] and options[:except] when passed to to_xml for the serializable hash
      Failure/Error: expect(Hash.from_xml(@event.to_xml(only: [:foo], except: [:id]))["event"]["images"]).to be_nil

      NoMethodError:
        undefined method `to_xml' for #<Event:0x007f2c39a0e2b0>
        Did you mean?  to_yaml
      # ./spec/orm/activerecord_spec.rb:954:in `block (4 levels) in <top (required)>'

  15) CarrierWave::ActiveRecord#mount_uploaders removing old files with mount_on should not remove file if old file had the same path
      Failure/Error: expect(File.exist?(public_path('uploads/old.jpeg'))).to be_truthy

        expected: truthy value
             got: false
      # ./spec/orm/activerecord_spec.rb:1539:in `block (3 levels) in <top (required)>'

Finished in 12.62 seconds (files took 1.64 seconds to load)
1533 examples, 15 failures, 1 pending

Failed examples:

rspec ./spec/orm/activerecord_spec.rb:93 # CarrierWave::ActiveRecord#mount_uploader #image should return valid XML when to_xml is called when image is nil
rspec ./spec/orm/activerecord_spec.rb:102 # CarrierWave::ActiveRecord#mount_uploader #image should return valid XML when to_xml is called when image is present
rspec ./spec/orm/activerecord_spec.rb:133 # CarrierWave::ActiveRecord#mount_uploader #image should respect options[:only] when passed to to_xml for the serializable hash
rspec ./spec/orm/activerecord_spec.rb:141 # CarrierWave::ActiveRecord#mount_uploader #image should respect options[:except] when passed to to_xml for the serializable hash
rspec ./spec/orm/activerecord_spec.rb:149 # CarrierWave::ActiveRecord#mount_uploader #image should respect both options[:only] and options[:except] when passed to to_xml for the serializable hash
rspec ./spec/orm/activerecord_spec.rb:839 # CarrierWave::ActiveRecord#mount_uploader removing old files with with mount_on should not remove file if old file had the same path
rspec ./spec/orm/activerecord_spec.rb:864 # CarrierWave::ActiveRecord#mount_uploaders #images should set the path to the store dir
rspec ./spec/orm/activerecord_spec.rb:878 # CarrierWave::ActiveRecord#mount_uploaders #images should return valid JSON when to_json is called when images is present
rspec ./spec/orm/activerecord_spec.rb:886 # CarrierWave::ActiveRecord#mount_uploaders #images should return valid JSON when to_json is called on a collection containing uploader from a model
rspec ./spec/orm/activerecord_spec.rb:894 # CarrierWave::ActiveRecord#mount_uploaders #images should return valid XML when to_xml is called when images is nil
rspec ./spec/orm/activerecord_spec.rb:902 # CarrierWave::ActiveRecord#mount_uploaders #images should return valid XML when to_xml is called when images is present
rspec ./spec/orm/activerecord_spec.rb:933 # CarrierWave::ActiveRecord#mount_uploaders #images should respect options[:only] when passed to to_xml for the serializable hash
rspec ./spec/orm/activerecord_spec.rb:941 # CarrierWave::ActiveRecord#mount_uploaders #images should respect options[:except] when passed to to_xml for the serializable hash
rspec ./spec/orm/activerecord_spec.rb:949 # CarrierWave::ActiveRecord#mount_uploaders #images should respect both options[:only] and options[:except] when passed to to_xml for the serializable hash
rspec ./spec/orm/activerecord_spec.rb:1536 # CarrierWave::ActiveRecord#mount_uploaders removing old files with mount_on should not remove file if old file had the same path
ozgg commented 8 years ago

It doesn't seem to work with rails5 and rspec + factorygirl for me, too. If I try to "upload" image, I get undefined methodcached?' for nil:NilClass`. But the author is looking for a new maintainer for carrierwave because of absence of time to develop it further :(

connorshea commented 8 years ago

At least there's only 15 failures, hopefully someone can dedicate the time to fix this!

mshibuya commented 8 years ago

All specs are passing in the master now, including Ralis 5 builds 🌟

connorshea commented 8 years ago

@mshibuya

s-41fe0de09829dd438adaf7ca624562099d1848dd

Thank you! ❤️