Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/models/share.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Share < ApplicationRecord
ConvertKit
Facebook
Google
HubSpot
LinkedIn
Lobsters
Mastodon
Expand All @@ -19,17 +20,26 @@ class Share < ApplicationRecord
].sort!

UTM_MEDIUMS = %w[
CPC
Email
Newsletter
Organic
PaidPlacement
PaidSocial
PPC
].sort!

UTM_CAMPAIGN = %w[
Blogpromo
LinkedIn-Roadmap-Test
LinkedIn-TLA
Newsletter
Rails-Upgrade-Guide
Re-engagement
Recruitment
Upgraderuby
Upgradejs
Upgradenodejs
Blogpromo
].sort!

UTM_CONTENT = %w[
Expand Down
80 changes: 80 additions & 0 deletions spec/models/share_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
end
end

context "on create with HubSpot as utm_source" do
it "is valid" do
share = build(:share, utm_source: "HubSpot")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with an unrecognized utm_medium" do
it "is not valid" do
share = build(:share, utm_medium: "community")
Expand All @@ -41,6 +49,38 @@
end
end

context "on create with PaidSocial as utm_medium" do
it "is valid" do
share = build(:share, utm_medium: "PaidSocial")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with CPC as utm_medium" do
it "is valid" do
share = build(:share, utm_medium: "CPC")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with Email as utm_medium" do
it "is valid" do
share = build(:share, utm_medium: "Email")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with Newsletter as utm_medium" do
it "is valid" do
share = build(:share, utm_medium: "Newsletter")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with an unrecognized utm_campaign" do
it "is not valid" do
share = build(:share, utm_campaign: "campaignOne")
Expand All @@ -50,6 +90,46 @@
end
end

context "on create with LinkedIn-TLA as utm_campaign" do
it "is valid" do
share = build(:share, utm_campaign: "LinkedIn-TLA")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with LinkedIn-Roadmap-Test as utm_campaign" do
it "is valid" do
share = build(:share, utm_campaign: "LinkedIn-Roadmap-Test")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with Rails-Upgrade-Guide as utm_campaign" do
it "is valid" do
share = build(:share, utm_campaign: "Rails-Upgrade-Guide")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with Newsletter as utm_campaign" do
it "is valid" do
share = build(:share, utm_campaign: "Newsletter")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with Re-engagement as utm_campaign" do
it "is valid" do
share = build(:share, utm_campaign: "Re-engagement")

expect(share.valid?(:create)).to be_truthy
end
end

context "on create with an unrecognized utm_content" do
it "is not valid" do
share = build(:share, utm_content: "Custom")
Expand Down