Add marketing message
parent
b210f7deaa
commit
5553adb79f
|
@ -5,7 +5,7 @@ class Alert < ApplicationRecord
|
|||
DOCUMENTATION = { problem_tag: "api.documentation.unread", priority: 300 },
|
||||
TOUR = { problem_tag: "api.tour.not_taken", priority: 200 },
|
||||
USER = { problem_tag: "api.user.not_welcomed", priority: 100 },
|
||||
BULLETIN = { problem_tag: "api.bulletin.unread", priority: 100},
|
||||
BULLETIN = { problem_tag: "api.bulletin.unread", priority: 100 },
|
||||
DEMO = { problem_tag: "api.demo_account.in_use", priority: 100 },
|
||||
]
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module Alerts
|
|||
end
|
||||
|
||||
optional do
|
||||
string :slug
|
||||
string :slug # Default is `SecureRandom.uuid`
|
||||
integer :priority, default: 99
|
||||
end
|
||||
|
||||
|
|
|
@ -20,11 +20,30 @@ module Devices
|
|||
end
|
||||
end
|
||||
|
||||
MARKETING_BULLETIN = GlobalBulletin.find_or_create_by(slug: "buy-a-farmbot") do |gb|
|
||||
gb.href = "https://farm.bot"
|
||||
gb.href_label = "Visit our website"
|
||||
gb.slug = "buy-a-farmbot"
|
||||
gb.title = "Buy a FarmBot"
|
||||
gb.type = "info"
|
||||
gb.content = [
|
||||
"Ready to get a FarmBot of your own? Check out our website to",
|
||||
" learn more about our various products. We offer FarmBots at",
|
||||
" all different price points, sizes, and capabilities so you'",
|
||||
"re sure to find one that suits your needs.",
|
||||
].join("")
|
||||
end
|
||||
|
||||
DEMO_ALERTS = [
|
||||
Alert::DEMO,
|
||||
Alert::BULLETIN.merge(slug: "buy-a-farmbot", priority: 9999),
|
||||
]
|
||||
|
||||
def misc
|
||||
device
|
||||
.alerts
|
||||
.where(problem_tag: UNUSED_ALERTS)
|
||||
.destroy_all
|
||||
device.alerts.where(problem_tag: UNUSED_ALERTS).destroy_all
|
||||
DEMO_ALERTS
|
||||
.map { |p| p.merge(device: device) }
|
||||
.map { |p| Alerts::Create.run!(p) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
require 'spec_helper'
|
||||
require "spec_helper"
|
||||
|
||||
describe Image do
|
||||
let(:device) { FactoryBot.create(:device) }
|
||||
let(:device) { FactoryBot.create(:device) }
|
||||
|
||||
it 'adds URL attachments', :slow do
|
||||
image = Image.create(device: device)
|
||||
expect(image.attachment_processed_at).to be_nil
|
||||
expect(image.attachment.exists?).to be_falsy
|
||||
it "adds URL attachments", :slow do
|
||||
image = Image.create(device: device)
|
||||
expect(image.attachment_processed_at).to be_nil
|
||||
expect(image.attachment.exists?).to be_falsy
|
||||
|
||||
image.set_attachment_by_url(FAKE_ATTACHMENT_URL)
|
||||
image.save!
|
||||
image.set_attachment_by_url(FAKE_ATTACHMENT_URL)
|
||||
image.save!
|
||||
|
||||
expect(image.attachment.exists?).to be_truthy
|
||||
expect(image.attachment_processed_at).to be_truthy
|
||||
end
|
||||
expect(image.attachment.exists?).to be_truthy
|
||||
expect(image.attachment_processed_at).to be_truthy
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue