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 ...@@ -6,19 +6,12 @@ module Gitlab
module InProductMarketing module InProductMarketing
UnknownTrackError = Class.new(StandardError) UnknownTrackError = Class.new(StandardError)
TRACKS = [:create, :verify, :team, :trial].freeze
def self.for(track) def self.for(track)
case track raise UnknownTrackError unless TRACKS.include?(track)
when :create
Gitlab::Email::Message::InProductMarketing::Create "Gitlab::Email::Message::InProductMarketing::#{track.to_s.classify}".constantize
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
end end
end end
end end
......
...@@ -8,14 +8,16 @@ module Gitlab ...@@ -8,14 +8,16 @@ module Gitlab
include Gitlab::Email::Message::InProductMarketing::Helper include Gitlab::Email::Message::InProductMarketing::Helper
include Gitlab::Routing include Gitlab::Routing
attr_accessor :format
def initialize(group:, series:, format: :html) 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 @group = group
@series = series @series = series
@format = format @format = format
end end
attr_accessor :format
def subject_line def subject_line
raise NotImplementedError raise NotImplementedError
end end
...@@ -66,9 +68,9 @@ module Gitlab ...@@ -66,9 +68,9 @@ module Gitlab
def progress def progress
if Gitlab.com? 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 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
end end
...@@ -103,6 +105,10 @@ module Gitlab ...@@ -103,6 +105,10 @@ module Gitlab
attr_reader :group, :series attr_reader :group, :series
def total_series
3
end
private private
def track def track
......
...@@ -17053,10 +17053,10 @@ msgstr "" ...@@ -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." 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 "" 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 "" 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 "" msgstr ""
msgid "InProductMarketing|Ticketmaster decreased their CI build time by 15X" msgid "InProductMarketing|Ticketmaster decreased their CI build time by 15X"
......
...@@ -8,6 +8,26 @@ RSpec.describe Gitlab::Email::Message::InProductMarketing::Base do ...@@ -8,6 +8,26 @@ RSpec.describe Gitlab::Email::Message::InProductMarketing::Base do
let(:series) { 0 } let(:series) { 0 }
let(:test_class) { Gitlab::Email::Message::InProductMarketing::Create } 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 describe '#logo_path' do
subject { test_class.new(group: group, series: series).logo_path } subject { test_class.new(group: group, series: series).logo_path }
......
...@@ -4,12 +4,21 @@ require 'spec_helper' ...@@ -4,12 +4,21 @@ require 'spec_helper'
RSpec.describe Gitlab::Email::Message::InProductMarketing do RSpec.describe Gitlab::Email::Message::InProductMarketing do
describe '.for' do describe '.for' do
using RSpec::Parameterized::TableSyntax
subject { described_class.for(track) } subject { described_class.for(track) }
context 'when track exists' do 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 end
context 'when track does not exist' do 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