summaryrefslogtreecommitdiff
path: root/spec/helpers/emails_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/emails_helper_spec.rb')
-rw-r--r--spec/helpers/emails_helper_spec.rb72
1 files changed, 71 insertions, 1 deletions
diff --git a/spec/helpers/emails_helper_spec.rb b/spec/helpers/emails_helper_spec.rb
index bc5fe05ab52..96ac4015c77 100644
--- a/spec/helpers/emails_helper_spec.rb
+++ b/spec/helpers/emails_helper_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe EmailsHelper do
context "and format is unknown" do
it "returns plain text" do
- expect(helper.closure_reason_text(merge_request, format: :text)).to eq("via merge request #{merge_request.to_reference} (#{merge_request_presenter.web_url})")
+ expect(helper.closure_reason_text(merge_request, format: 'unknown')).to eq("via merge request #{merge_request.to_reference} (#{merge_request_presenter.web_url})")
end
end
end
@@ -110,6 +110,76 @@ RSpec.describe EmailsHelper do
end
end
+ describe '#say_hi' do
+ let(:user) { create(:user, name: 'John') }
+
+ it 'returns the greeting message for the given user' do
+ expect(say_hi(user)).to eq('Hi John!')
+ end
+ end
+
+ describe '#say_hello' do
+ let(:user) { build(:user, name: 'John') }
+
+ it 'returns the greeting message for the given user' do
+ expect(say_hello(user)).to eq('Hello, John!')
+ end
+ end
+
+ describe '#two_factor_authentication_disabled_text' do
+ it 'returns the message that 2FA is disabled' do
+ expect(two_factor_authentication_disabled_text).to eq(
+ _('Two-factor authentication has been disabled for your GitLab account.')
+ )
+ end
+ end
+
+ describe '#re_enable_two_factor_authentication_text' do
+ context 'format is html' do
+ it 'returns HTML' do
+ expect(re_enable_two_factor_authentication_text(format: :html)).to eq(
+ "If you want to re-enable two-factor authentication, visit the " \
+ "#{link_to('two-factor authentication settings', profile_two_factor_auth_url, target: :_blank, rel: 'noopener noreferrer')} page."
+ )
+ end
+ end
+
+ context 'format is not specified' do
+ it 'returns text' do
+ expect(re_enable_two_factor_authentication_text).to eq(
+ "If you want to re-enable two-factor authentication, visit #{profile_two_factor_auth_url}"
+ )
+ end
+ end
+ end
+
+ describe '#admin_changed_password_text' do
+ context 'format is html' do
+ it 'returns HTML' do
+ expect(admin_changed_password_text(format: :html)).to eq(
+ "An administrator changed the password for your GitLab account on " \
+ "#{link_to(Gitlab.config.gitlab.url, Gitlab.config.gitlab.url, target: :_blank, rel: 'noopener noreferrer')}."
+ )
+ end
+ end
+
+ context 'format is not specified' do
+ it 'returns text' do
+ expect(admin_changed_password_text).to eq(
+ "An administrator changed the password for your GitLab account on #{Gitlab.config.gitlab.url}."
+ )
+ end
+ end
+ end
+
+ describe '#contact_your_administrator_text' do
+ it 'returns the message to contact the administrator' do
+ expect(contact_your_administrator_text).to eq(
+ _('Please contact your administrator with any questions.')
+ )
+ end
+ end
+
describe 'password_reset_token_valid_time' do
def validate_time_string(time_limit, expected_string)
Devise.reset_password_within = time_limit