Skip to content

Commit

Permalink
Add marketing message
Browse files Browse the repository at this point in the history
  • Loading branch information
RickCarlino committed Jun 18, 2019
1 parent b210f7d commit 5553adb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/models/alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
]

Expand Down
2 changes: 1 addition & 1 deletion app/mutations/alerts/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Create < Mutations::Command
end

optional do
string :slug
string :slug # Default is `SecureRandom.uuid`
integer :priority, default: 99
end

Expand Down
27 changes: 23 additions & 4 deletions app/mutations/devices/seeders/demo_account_seeder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,30 @@ def webcam_feeds
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
Expand Down
22 changes: 11 additions & 11 deletions spec/models/image_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5553adb

Please sign in to comment.