Commit 52460831 authored by Nicolas Dular's avatar Nicolas Dular

Test all tracks in factory and use variable series

parent 402baca0
......@@ -6,19 +6,12 @@ module Gitlab
module InProductMarketing
UnknownTrackError = Class.new(StandardError)
TRACKS = [:create, :verify, :team, :trial].freeze
def self.for(track)
case track
when :create
Gitlab::Email::Message::InProductMarketing::Create
when :verify
Gitlab::Email::Message::InProductMarketing::Verify
when :team
Gitlab::Email::Message::InProductMarketing::Team
when :trial
Gitlab::Email::Message::InProductMarketing::Trial
else
raise UnknownTrackError
end
raise UnknownTrackError unless TRACKS.include?(track)
"Gitlab::Email::Message::InProductMarketing::#{track.to_s.classify}".constantize
end
end
end
......
......@@ -8,14 +8,16 @@ module Gitlab
include Gitlab::Email::Message::InProductMarketing::Helper
include Gitlab::Routing
attr_accessor :format
def initialize(group:, series:, format: :html)
raise ArgumentError, "Only #{total_series} series available for this track." unless series.between?(0, total_series - 1)
@group = group
@series = series
@format = format
end
attr_accessor :format
def subject_line
raise NotImplementedError
end
......@@ -66,9 +68,9 @@ module Gitlab
def progress
if Gitlab.com?
s_('InProductMarketing|This is email %{series} of 3 in the %{track} series.') % { series: series + 1, track: track.to_s.humanize }
s_('InProductMarketing|This is email %{current_series} of %{total_series} in the %{track} series.') % { current_series: series + 1, total_series: total_series, track: track.to_s.humanize }
else
s_('InProductMarketing|This is email %{series} of 3 in the %{track} series. To disable notification emails sent by your local GitLab instance, either contact your administrator or %{unsubscribe_link}.') % { series: series + 1, track: track.to_s.humanize, unsubscribe_link: unsubscribe_link }
s_('InProductMarketing|This is email %{current_series} of %{total_series} in the %{track} series. To disable notification emails sent by your local GitLab instance, either contact your administrator or %{unsubscribe_link}.') % { current_series: series + 1, total_series: total_series, track: track.to_s.humanize, unsubscribe_link: unsubscribe_link }
end
end
......@@ -103,6 +105,10 @@ module Gitlab
attr_reader :group, :series
def total_series
3
end
private
def track
......
......@@ -17053,10 +17053,10 @@ msgstr ""
msgid "InProductMarketing|That's all it takes to get going with GitLab, but if you're new to working with Git, check out our %{basics_link} for helpful tips and tricks for getting started."
msgstr ""
msgid "InProductMarketing|This is email %{series} of 3 in the %{track} series."
msgid "InProductMarketing|This is email %{current_series} of %{total_series} in the %{track} series."
msgstr ""
msgid "InProductMarketing|This is email %{series} of 3 in the %{track} series. To disable notification emails sent by your local GitLab instance, either contact your administrator or %{unsubscribe_link}."
msgid "InProductMarketing|This is email %{current_series} of %{total_series} in the %{track} series. To disable notification emails sent by your local GitLab instance, either contact your administrator or %{unsubscribe_link}."
msgstr ""
msgid "InProductMarketing|Ticketmaster decreased their CI build time by 15X"
......
......@@ -8,6 +8,26 @@ RSpec.describe Gitlab::Email::Message::InProductMarketing::Base do
let(:series) { 0 }
let(:test_class) { Gitlab::Email::Message::InProductMarketing::Create }
describe 'initialize' do
subject { test_class.new(group: group, series: series) }
context 'when series does not exist' do
let(:series) { 3 }
it 'raises error' do
expect { subject }.to raise_error(ArgumentError)
end
end
context 'when series exists' do
let(:series) { 0 }
it 'does not raise error' do
expect { subject }.not_to raise_error(ArgumentError)
end
end
end
describe '#logo_path' do
subject { test_class.new(group: group, series: series).logo_path }
......
......@@ -4,12 +4,21 @@ require 'spec_helper'
RSpec.describe Gitlab::Email::Message::InProductMarketing do
describe '.for' do
using RSpec::Parameterized::TableSyntax
subject { described_class.for(track) }
context 'when track exists' do
let(:track) { :create }
where(:track, :expected_class) do
:create | described_class::Create
:verify | described_class::Verify
:trial | described_class::Trial
:team | described_class::Team
end
it { is_expected.to eq(Gitlab::Email::Message::InProductMarketing::Create) }
with_them do
it { is_expected.to eq(expected_class) }
end
end
context 'when track does not exist' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment