spec/backgrounder/orm/activemodel_spec.rb in carrierwave_backgrounder-0.2.1 vs spec/backgrounder/orm/activemodel_spec.rb in carrierwave_backgrounder-0.2.2

- old
+ new

@@ -9,10 +9,11 @@ def self.after_commit(method, opts); nil; end def avatar_changed?; nil; end def remote_avatar_url; OpenStruct.new(:present? => true); end def remove_avatar?; false; end def previous_changes; {}; end + def self.uploader_options; {}; end end @mock_class.extend CarrierWave::Backgrounder::ORM::ActiveModel end @@ -42,9 +43,21 @@ describe '#trigger_column_background_processing?' do let(:instance) { @mock_class.new } before do @mock_class.process_in_background :avatar + end + + context 'mount_on option is set' do + before do + options_hash = {:avatar => {:mount_on => :some_other_column}} + @mock_class.expects(:uploader_options).returns(options_hash) + end + + it "returns true if alternate column is changed" do + instance.expects(:some_other_column_changed?).returns(true) + expect(instance.avatar_updated?).to be_true + end end it "returns true if process_avatar_upload is false" do instance.expects(:process_avatar_upload) expect(instance.enqueue_avatar_background_job?).to be_true