Write a test for image attachment method, disable DJ in test suite.
parent
82a2841064
commit
57e86ecfef
|
@ -17,11 +17,11 @@ class Image < ApplicationRecord
|
||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
"image/png",
|
"image/png",
|
||||||
"image/gif"]
|
"image/gif"]
|
||||||
|
|
||||||
def set_attachment_by_url(url)
|
def set_attachment_by_url(url)
|
||||||
# Image.new.from_url("http://i.imgur.com/OhLresv.png").save!
|
# Image.new.set_attachment_by_url("http://i.imgur.com/OhLresv.png").save!
|
||||||
self.attachment = open(url)
|
self.attachment = open(url)
|
||||||
self.image_processed_at = Time.now
|
self.attachment_processed_at = Time.now
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
handle_asynchronously :set_attachment_by_url
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
FarmBot::Application.configure do
|
FarmBot::Application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
config.active_job.queue_adapter = nil
|
||||||
|
|
||||||
# The test environment is used exclusively to run your application's
|
# The test environment is used exclusively to run your application's
|
||||||
# test suite. You never need to work with it otherwise. Remember that
|
# test suite. You never need to work with it otherwise. Remember that
|
||||||
|
@ -35,5 +36,5 @@ FarmBot::Application.configure do
|
||||||
# Print deprecation notices to the stderr.
|
# Print deprecation notices to the stderr.
|
||||||
config.active_support.deprecation = :stderr
|
config.active_support.deprecation = :stderr
|
||||||
|
|
||||||
config.log_level = :error
|
config.log_level = :error
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class CreateImages < ActiveRecord::Migration[5.0]
|
||||||
def change
|
def change
|
||||||
create_table :images do |t|
|
create_table :images do |t|
|
||||||
t.integer :device_id
|
t.integer :device_id
|
||||||
t.datetime :image_processed_at
|
t.datetime :attachment_processed_at
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ ActiveRecord::Schema.define(version: 20170111035209) do
|
||||||
|
|
||||||
create_table "images", force: :cascade do |t|
|
create_table "images", force: :cascade do |t|
|
||||||
t.integer "device_id"
|
t.integer "device_id"
|
||||||
t.datetime "image_processed_at"
|
t.datetime "attachment_processed_at"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "attachment_file_name"
|
t.string "attachment_file_name"
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 425 B |
|
@ -4,7 +4,14 @@ describe Image do
|
||||||
let(:device) { FactoryGirl.create(:device) }
|
let(:device) { FactoryGirl.create(:device) }
|
||||||
|
|
||||||
it 'adds URL attachments' do
|
it 'adds URL attachments' do
|
||||||
image = Image.new
|
image = Image.create(device: device)
|
||||||
binding.pry
|
expect(image.attachment_processed_at).to be_nil
|
||||||
|
expect(image.attachment.exists?).to be_falsy
|
||||||
|
|
||||||
|
image.set_attachment_by_url("http://i.imgur.com/OhLresv.png")
|
||||||
|
image.save!
|
||||||
|
|
||||||
|
expect(image.attachment.exists?).to be_truthy
|
||||||
|
expect(image.attachment_processed_at).to be_truthy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue