spec/backgrounder/orm/activemodel_spec.rb in carrierwave_backgrounder-0.4.3 vs spec/backgrounder/orm/activemodel_spec.rb in carrierwave_backgrounder-1.0.0.beta
- old
+ new
@@ -6,10 +6,11 @@
before do
@mock_class = Class.new do
def self.before_save(method, opts); nil; end
def self.after_commit(method, opts); nil; end
def avatar_changed?; nil; end
+ def avatar_present?; true; 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
@@ -52,11 +53,11 @@
options_hash = {:avatar => {:mount_on => :some_other_column}}
expect(@mock_class).to receive(:uploader_options).and_return(options_hash)
end
it "returns true if alternate column is changed" do
- expect(instance).to receive(:some_other_column_changed?).and_return(true)
+ expect(instance).to receive(:previous_changes).and_return({:some_other_column => true})
expect(instance.avatar_updated?).to be_truthy
end
end
it "returns true if process_avatar_upload is false" do
@@ -64,31 +65,27 @@
expect(instance.enqueue_avatar_background_job?).to be_truthy
end
it "calls column_changed?" do
expect(instance).to receive(:process_avatar_upload).and_return(false)
- expect(instance).to receive(:avatar_changed?)
expect(instance.enqueue_avatar_background_job?).to be_truthy
end
it "calls previous_changes" do
expect(instance).to receive(:process_avatar_upload).and_return(false)
- expect(instance).to receive(:avatar_changed?).and_return(false)
expect(instance).to receive(:previous_changes).and_return({:avatar => true})
expect(instance.enqueue_avatar_background_job?).to be_truthy
end
it "calls avatar_remote_url" do
expect(instance).to receive(:process_avatar_upload).and_return(false)
- expect(instance).to receive(:avatar_changed?).and_return(false)
expect(instance).to receive(:previous_changes).and_return({})
expect(instance).to receive(:remote_avatar_url).and_return('yup')
expect(instance.enqueue_avatar_background_job?).to be_truthy
end
it "calls avatar_cache" do
expect(instance).to receive(:process_avatar_upload).and_return(false)
- expect(instance).to receive(:avatar_changed?).and_return(false)
expect(instance).to receive(:previous_changes).and_return({})
expect(instance).to receive(:remote_avatar_url).and_return(nil)
expect(instance).to receive(:avatar_cache).and_return('yup')
expect(instance.enqueue_avatar_background_job?).to be_truthy
end